From cf7ac6964d58279ca4150e2a096bbf1353348137 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 10 Sep 2023 17:09:31 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Implementing=20data=20m?= =?UTF-8?q?appings=20=F0=9F=9A=97=20Transforming=20car=20data=20?= =?UTF-8?q?=F0=9F=8F=A0=20Processing=20stay=20listings=20=F0=9F=8C=9F=20Pr?= =?UTF-8?q?eparing=20experiences=20data=20=F0=9F=93=A6=20Importing=20requi?= =?UTF-8?q?red=20images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/listings.ts | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/data/listings.ts diff --git a/src/data/listings.ts b/src/data/listings.ts new file mode 100644 index 0000000..7070b80 --- /dev/null +++ b/src/data/listings.ts @@ -0,0 +1,100 @@ +import __stayListing from "./jsons/__stayListing.json"; +import __carsListing from "./jsons/__carsListing.json"; +import __experiencesListing from "./jsons/__experiencesListing.json"; +import { + DEMO_STAY_CATEGORIES, + DEMO_EXPERIENCES_CATEGORIES, +} from "./taxonomies"; +import { CarDataType, ExperiencesDataType, StayDataType } from "./types"; +import { DEMO_AUTHORS } from "./authors"; +import car1 from "@/images/cars/1.png"; +import car2 from "@/images/cars/2.png"; +import car3 from "@/images/cars/3.png"; +import car4 from "@/images/cars/4.png"; +import car5 from "@/images/cars/5.png"; +import car6 from "@/images/cars/6.png"; +import car7 from "@/images/cars/7.png"; +import car8 from "@/images/cars/8.png"; +import car9 from "@/images/cars/9.png"; +import car10 from "@/images/cars/10.png"; +import car11 from "@/images/cars/11.png"; +import car12 from "@/images/cars/12.png"; +import car13 from "@/images/cars/13.png"; +import car14 from "@/images/cars/14.png"; +import car15 from "@/images/cars/15.png"; +import car16 from "@/images/cars/16.png"; +import { Route } from "@/routers/types"; +const carsImgs = [ + car1, + car2, + car3, + car4, + car5, + car6, + car7, + car8, + car9, + car10, + car11, + car12, + car13, + car14, + car15, + car16, +]; + +const DEMO_STAY_LISTINGS = __stayListing.map((post, index): StayDataType => { + // ########## GET CATEGORY BY CAT ID ######## // + const category = DEMO_STAY_CATEGORIES.filter( + (taxonomy) => taxonomy.id === post.listingCategoryId + )[0]; + + return { + ...post, + id: `stayListing_${index}_`, + saleOff: !index ? "-20% today" : post.saleOff, + isAds: !index ? true : post.isAds, + author: DEMO_AUTHORS.filter((user) => user.id === post.authorId)[0], + listingCategory: category, + href: post.href as Route, + }; +}); + +const DEMO_EXPERIENCES_LISTINGS = __experiencesListing.map( + (post, index): ExperiencesDataType => { + // ########## GET CATEGORY BY CAT ID ######## // + const category = DEMO_EXPERIENCES_CATEGORIES.filter( + (taxonomy) => taxonomy.id === post.listingCategoryId + )[0]; + + return { + ...post, + id: `experiencesListing_${index}_`, + saleOff: !index ? "-20% today" : post.saleOff, + isAds: !index ? true : post.isAds, + author: DEMO_AUTHORS.filter((user) => user.id === post.authorId)[0], + listingCategory: category, + href: post.href as Route, + }; + } +); + +const DEMO_CAR_LISTINGS = __carsListing.map((post, index): CarDataType => { + // ########## GET CATEGORY BY CAT ID ######## // + const category = DEMO_EXPERIENCES_CATEGORIES.filter( + (taxonomy) => taxonomy.id === post.listingCategoryId + )[0]; + + return { + ...post, + id: `carsListing_${index}_`, + saleOff: !index ? "-20% today" : post.saleOff, + isAds: !index ? true : post.isAds, + author: DEMO_AUTHORS.filter((user) => user.id === post.authorId)[0], + listingCategory: category, + featuredImage: carsImgs[index], + href: post.href as Route, + }; +}); + +export { DEMO_STAY_LISTINGS, DEMO_EXPERIENCES_LISTINGS, DEMO_CAR_LISTINGS };