mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-05-20 18:34:53 +00:00
Improve Item page
Add 500 page and dedicated 404 page Add fake cache to tester API Adjust some styles for better readability and usability
This commit is contained in:
parent
40c19335cf
commit
383f22bdf8
11 changed files with 297 additions and 91 deletions
|
@ -1,19 +1,32 @@
|
|||
import Items from '%/lib/test-data.js';
|
||||
|
||||
let cache = {};
|
||||
|
||||
|
||||
async function fakeDelay(timeout = 1000) {
|
||||
await new Promise(resolve => setTimeout(resolve, timeout));
|
||||
}
|
||||
|
||||
export async function getAnnouncements() {
|
||||
if (cache.announcement_banner !== undefined) {
|
||||
return cache.announcement_banner;
|
||||
}
|
||||
|
||||
const data = {
|
||||
image: "/BannerExampleImage.jpg",
|
||||
};
|
||||
await fakeDelay(2000)
|
||||
cache.announcement_banner = data;
|
||||
await fakeDelay(5000)
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getPopularToday() {
|
||||
if (cache.popular_today !== undefined) {
|
||||
return cache.popular_today;
|
||||
}
|
||||
|
||||
const data = Items;
|
||||
cache.popular_today = data;
|
||||
await fakeDelay(2000)
|
||||
return data;
|
||||
}
|
||||
|
@ -33,6 +46,24 @@ export async function getMenuItems() {
|
|||
items: Items,
|
||||
},
|
||||
];
|
||||
await fakeDelay(2000)
|
||||
await fakeDelay(20)
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getItemByUUID(uuid) {
|
||||
let data;
|
||||
|
||||
Items.forEach((item) => {
|
||||
if (item.uuid === uuid) {
|
||||
data = item;
|
||||
}
|
||||
})
|
||||
|
||||
await fakeDelay(1000)
|
||||
|
||||
if (!data) {
|
||||
throw new Error("Resource could not be found");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue