ads-web-sdkm 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +369 -0
  2. package/dist/AdsCarousel.css +1 -0
  3. package/dist/AdsCarousel.d.ts +1 -0
  4. package/dist/AdsCarousel.js +519 -0
  5. package/dist/AdsCarousel.js.map +1 -0
  6. package/dist/Brandshop.css +1 -0
  7. package/dist/Brandshop.d.ts +1 -0
  8. package/dist/Brandshop.js +918 -0
  9. package/dist/Brandshop.js.map +1 -0
  10. package/dist/Brandshops.css +1 -0
  11. package/dist/Brandshops.d.ts +1 -0
  12. package/dist/Brandshops.js +103 -0
  13. package/dist/Brandshops.js.map +1 -0
  14. package/dist/Image-zvdPHg5N.js +35 -0
  15. package/dist/Image-zvdPHg5N.js.map +1 -0
  16. package/dist/ReactQueryProvider-D__k2BsQ.js +6755 -0
  17. package/dist/ReactQueryProvider-D__k2BsQ.js.map +1 -0
  18. package/dist/ads-CChrT00a.js +4470 -0
  19. package/dist/ads-CChrT00a.js.map +1 -0
  20. package/dist/api/queries/useGetAds.d.ts +16 -0
  21. package/dist/api/queries/useGetBrandshop.d.ts +14 -0
  22. package/dist/api/queries/useGetBrandshopList.d.ts +11 -0
  23. package/dist/api/queries/useGetCollection.d.ts +11 -0
  24. package/dist/api/services/getAds.d.ts +14 -0
  25. package/dist/api/services/getBrandshop.d.ts +13 -0
  26. package/dist/api/services/getBrandshopList.d.ts +11 -0
  27. package/dist/api/services/getCollection.d.ts +4 -0
  28. package/dist/components/Brandshop/Banner.d.ts +6 -0
  29. package/dist/components/Brandshop/BannerSection.d.ts +15 -0
  30. package/dist/components/Brandshop/BannerWithLink.d.ts +8 -0
  31. package/dist/components/Brandshop/Brandshop.d.ts +16 -0
  32. package/dist/components/Brandshop/BrandshopContent.d.ts +3 -0
  33. package/dist/components/Brandshop/BrandshopError.d.ts +6 -0
  34. package/dist/components/Brandshop/BrandshopSection.d.ts +18 -0
  35. package/dist/components/Brandshop/BrandshopSkeleton.d.ts +1 -0
  36. package/dist/components/Brandshop/CategorySection.d.ts +14 -0
  37. package/dist/components/Brandshop/NavigationSection.d.ts +16 -0
  38. package/dist/components/Brandshop/ProductSliderSection.d.ts +18 -0
  39. package/dist/components/Brandshop/index.d.ts +1 -0
  40. package/dist/components/Brandshops/Brandshops.d.ts +11 -0
  41. package/dist/components/Brandshops/BrandshopsList.d.ts +3 -0
  42. package/dist/components/Brandshops/BrandshopsSkeleton.d.ts +6 -0
  43. package/dist/components/Brandshops/index.d.ts +1 -0
  44. package/dist/components/Card/Card.d.ts +8 -0
  45. package/dist/components/Carousel/AdBanner.d.ts +17 -0
  46. package/dist/components/Carousel/AdBanners.d.ts +24 -0
  47. package/dist/components/Carousel/AdCarousel.d.ts +43 -0
  48. package/dist/components/Carousel/AdSkeleton.d.ts +8 -0
  49. package/dist/components/Carousel/AdsCarousel.d.ts +24 -0
  50. package/dist/components/Carousel/index.d.ts +1 -0
  51. package/dist/components/Chip/Chip.d.ts +6 -0
  52. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +18 -0
  53. package/dist/components/Image/Image.d.ts +13 -0
  54. package/dist/components/ProductsCarousel/CouponBadge.d.ts +8 -0
  55. package/dist/components/ProductsCarousel/DiscountChip.d.ts +12 -0
  56. package/dist/components/ProductsCarousel/PriceDisplay.d.ts +8 -0
  57. package/dist/components/ProductsCarousel/ProductCard.d.ts +15 -0
  58. package/dist/components/ProductsCarousel/ProductCardSkeleton.d.ts +5 -0
  59. package/dist/components/ProductsCarousel/ProductSliderSkeleton.d.ts +5 -0
  60. package/dist/components/ProductsCarousel/ProductTitle.d.ts +5 -0
  61. package/dist/components/ProductsCarousel/ProductsCarousel.d.ts +11 -0
  62. package/dist/hooks/use-async-memo.d.ts +1 -0
  63. package/dist/hooks/use-is-platform.d.ts +8 -0
  64. package/dist/hooks/useDetectScrolledToBottom.d.ts +5 -0
  65. package/dist/hooks/useSwipeThreshold.d.ts +4 -0
  66. package/dist/providers/ReactQueryProvider.d.ts +5 -0
  67. package/dist/types/ads.d.ts +116 -0
  68. package/dist/types/brandshop.d.ts +62 -0
  69. package/dist/types/brandshopsList.d.ts +32 -0
  70. package/dist/types/configTypes.d.ts +16 -0
  71. package/dist/types/enums.d.ts +8 -0
  72. package/dist/types/products.d.ts +72 -0
  73. package/dist/types/tenures.d.ts +11 -0
  74. package/dist/types/types.d.ts +2 -0
  75. package/dist/utils/analytics/trackAdsEvent.d.ts +16 -0
  76. package/dist/utils/analytics/trackBrandshopEvents.d.ts +15 -0
  77. package/dist/utils/helpers/ads.d.ts +3 -0
  78. package/dist/utils/helpers/authToken.d.ts +5 -0
  79. package/dist/utils/helpers/discountChip.d.ts +14 -0
  80. package/dist/utils/helpers/getBaseUrl.d.ts +4 -0
  81. package/dist/utils/helpers/mergeClasses.d.ts +1 -0
  82. package/dist/utils/helpers/price-utils.d.ts +1 -0
  83. package/dist/utils/helpers/productDiscounts.d.ts +3 -0
  84. package/dist/utils/helpers/products.d.ts +4 -0
  85. package/dist/utils/helpers/text.d.ts +1 -0
  86. package/dist/utils/helpers/translate.d.ts +63 -0
  87. package/dist/utils/helpers/utilities.d.ts +1 -0
  88. package/dist/utils/validations/ads.d.ts +7 -0
  89. package/package.json +81 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Brandshop.js","sources":["../src/api/services/getBrandshop.ts","../src/api/queries/useGetBrandshop.ts","../src/components/Brandshop/BannerWithLink.tsx","../src/components/Brandshop/Banner.tsx","../src/utils/analytics/trackBrandshopEvents.ts","../src/components/Brandshop/BannerSection.tsx","../src/components/Brandshop/CategorySection.tsx","../src/components/Brandshop/NavigationSection.tsx","../src/types/products.ts","../src/utils/helpers/productDiscounts.ts","../src/components/Card/Card.tsx","../src/components/Chip/Chip.tsx","../src/utils/helpers/discountChip.ts","../src/utils/helpers/translate.ts","../src/components/ProductsCarousel/DiscountChip.tsx","../src/assets/tag.svg","../src/components/ProductsCarousel/CouponBadge.tsx","../src/components/ProductsCarousel/PriceDisplay.tsx","../src/components/ProductsCarousel/ProductTitle.tsx","../src/components/ProductsCarousel/ProductCard.tsx","../src/components/ProductsCarousel/ProductsCarousel.tsx","../src/utils/helpers/products.ts","../src/api/services/getCollection.ts","../src/api/queries/useGetCollection.ts","../src/components/ProductsCarousel/ProductCardSkeleton.tsx","../src/components/ProductsCarousel/ProductSliderSkeleton.tsx","../src/components/Brandshop/ProductSliderSection.tsx","../src/components/Brandshop/BrandshopSection.tsx","../src/utils/helpers/utilities.ts","../src/hooks/useDetectScrolledToBottom.ts","../src/components/Brandshop/BrandshopSkeleton.tsx","../src/components/Brandshop/BrandshopContent.tsx","../src/assets/error.svg","../src/components/Brandshop/BrandshopError.tsx","../src/components/ErrorBoundary/ErrorBoundary.tsx","../src/components/Brandshop/Brandshop.tsx"],"sourcesContent":["import { generateAccessToken } from '@/utils/helpers/authToken';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { getBaseUrl } from '@/utils/helpers/getBaseUrl';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport {\r\n type TBrandshopApiResponse,\r\n type TBrandshopData,\r\n} from '@/types/brandshop';\r\n\r\ntype TGetBrandshopProps = {\r\n deviceType: string;\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n brandshopId: string;\r\n adServerApiKey: string;\r\n};\r\n\r\nexport const getBrandshop = async ({\r\n deviceType,\r\n language,\r\n brandshopId,\r\n environment,\r\n adServerApiKey,\r\n}: TGetBrandshopProps): Promise<TBrandshopData> => {\r\n const [token, timestamp] = await generateAccessToken(adServerApiKey);\r\n const adServerBaseUrl = getBaseUrl('adServer', environment);\r\n\r\n try {\r\n const res = await fetch(\r\n `${adServerBaseUrl}/api/v2/brandshop/server/${brandshopId}`,\r\n {\r\n headers: {\r\n device: deviceType,\r\n lang: language,\r\n 'auth-token': token,\r\n 'auth-timestamp': timestamp,\r\n },\r\n },\r\n );\r\n\r\n const brandshopResponse: TBrandshopApiResponse = await res.json();\r\n return brandshopResponse.data;\r\n } catch (error) {\r\n throw new Error(`Failed to fetch brandshop details - ${error}`);\r\n }\r\n};\r\n","import { useQuery } from '@tanstack/react-query';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport { getBrandshop } from '../services/getBrandshop';\r\n\r\ntype TGetBrandshopProps = {\r\n deviceType: string;\r\n language: TLanguage;\r\n brandshopId: string;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n enabled?: boolean;\r\n};\r\nexport const GET_BRANDSHOP_QUERY_KEY = 'brandshop';\r\n\r\nexport const useGetBrandshopQuery = ({\r\n deviceType,\r\n language,\r\n brandshopId,\r\n environment,\r\n adServerApiKey,\r\n enabled,\r\n}: TGetBrandshopProps) => {\r\n const brandshopQueryKey = [\r\n GET_BRANDSHOP_QUERY_KEY,\r\n brandshopId,\r\n deviceType,\r\n language,\r\n ];\r\n\r\n return useQuery({\r\n queryKey: brandshopQueryKey,\r\n queryFn: () =>\r\n getBrandshop({\r\n deviceType,\r\n language,\r\n brandshopId,\r\n environment,\r\n adServerApiKey,\r\n }),\r\n enabled,\r\n });\r\n};\r\n","import styles from './Brandshop.module.css';\r\nimport { Image } from '../Image/Image';\r\n\r\ntype BannerWithLinkProps = {\r\n image: string;\r\n text: string;\r\n alt: string;\r\n onClick: () => void;\r\n};\r\n\r\nexport const BannerWithLink = ({\r\n image,\r\n text,\r\n alt,\r\n onClick,\r\n}: BannerWithLinkProps) => {\r\n if (!image) return null;\r\n\r\n return (\r\n <button type=\"button\" className={styles.bannerButton} onClick={onClick}>\r\n <Image src={image} alt={alt} className={styles.bannerImage} />\r\n <div className={styles.bannerCta}>{text}</div>\r\n </button>\r\n );\r\n};\r\n","import styles from './Brandshop.module.css';\r\nimport { Image } from '../Image/Image';\r\n\r\ntype BannerProps = {\r\n image: string;\r\n alt: string;\r\n};\r\n\r\nexport const Banner = ({ image, alt }: BannerProps) => {\r\n return (\r\n <div className={styles.banner}>\r\n <Image src={image} alt={alt} className={styles.bannerImage} fetchPriority='high' />\r\n </div>\r\n );\r\n};\r\n","import { TTrackEvents } from '@/types/configTypes';\r\n\r\ntype TBrandshopLoginStatus = 'logged_in' | 'guest';\r\n\r\ntype TBrandshopEventNamesEnum =\r\n | 'ads_bs_pageload'\r\n | 'ads_bs_pageend'\r\n | 'ads_bs_section_view'\r\n | 'ads_bs_content_click';\r\n\r\ntype TBrandshopEventProperties = {\r\n userStatus: TBrandshopLoginStatus;\r\n platform: 'Web';\r\n brandName?: string;\r\n sectionName?: string;\r\n sectionOrder?: string;\r\n contentName?: string;\r\n contentOrder?: string;\r\n};\r\n\r\nexport const trackBrandshopEvent = (\r\n eventName: TBrandshopEventNamesEnum,\r\n props: TBrandshopEventProperties,\r\n trackEvent?: TTrackEvents,\r\n) => {\r\n switch (eventName) {\r\n case 'ads_bs_pageload':\r\n case 'ads_bs_pageend': {\r\n const { brandName, userStatus, platform } = props;\r\n trackEvent?.(eventName, {\r\n brand_name: brandName,\r\n user_status: userStatus,\r\n platform,\r\n });\r\n break;\r\n }\r\n\r\n case 'ads_bs_section_view': {\r\n const { brandName, sectionName, sectionOrder, userStatus, platform } =\r\n props;\r\n trackEvent?.(eventName, {\r\n brand_name: brandName,\r\n section_name: sectionName,\r\n section_order: sectionOrder,\r\n user_status: userStatus,\r\n platform,\r\n });\r\n break;\r\n }\r\n\r\n case 'ads_bs_content_click': {\r\n const { contentName, contentOrder, userStatus, platform } = props;\r\n trackEvent?.(eventName, {\r\n content_name: contentName,\r\n content_order: contentOrder,\r\n user_status: userStatus,\r\n platform,\r\n });\r\n break;\r\n }\r\n }\r\n};\r\n","import { type TLinkClickEvent } from '@/types/ads';\r\nimport { type TBrandshopDataItem } from '@/types/brandshop';\r\nimport { buildLinkDestination } from '@/utils/helpers/ads';\r\nimport { BannerWithLink } from './BannerWithLink';\r\nimport { Banner } from './Banner';\r\nimport styles from './Brandshop.module.css';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport { type TTrackEvents } from '@/types/configTypes';\r\n\r\ntype BannerSectionProps = {\r\n title: string;\r\n hideTitle: boolean;\r\n banners: TBrandshopDataItem[];\r\n isLoggedin: boolean;\r\n sectionTitle: string;\r\n onBannerClick: (link: TLinkClickEvent) => void;\r\n trackBrandshopHandler?: TTrackEvents;\r\n};\r\n\r\nexport const BannerSection = ({\r\n title,\r\n hideTitle,\r\n banners,\r\n isLoggedin,\r\n sectionTitle,\r\n onBannerClick,\r\n trackBrandshopHandler,\r\n}: BannerSectionProps) => {\r\n const handleLinkClick = (bannerItem: TBrandshopDataItem) => {\r\n if (!bannerItem?.link?.link_destination) return;\r\n trackBrandshopEvent(\r\n 'ads_bs_content_click',\r\n {\r\n contentName: sectionTitle,\r\n contentOrder: bannerItem.display_order.toString(),\r\n userStatus: isLoggedin ? 'logged_in' : 'guest',\r\n platform: 'Web',\r\n },\r\n trackBrandshopHandler,\r\n );\r\n const payload = buildLinkDestination(bannerItem.link.link_destination);\r\n if (!payload) return;\r\n onBannerClick(payload);\r\n };\r\n\r\n if (banners.length === 0) return null;\r\n\r\n return (\r\n <div className={styles.sectionContainer}>\r\n {!hideTitle && <h2 className={styles.sectionTitle}>{title}</h2>}\r\n\r\n {banners.map((banner) => {\r\n return banner.link ? (\r\n <BannerWithLink\r\n key={banner.tracking_id}\r\n image={banner.image as string}\r\n text={banner.link.link_text}\r\n alt={title}\r\n onClick={() => handleLinkClick(banner)}\r\n />\r\n ) : (\r\n <Banner\r\n key={banner.tracking_id}\r\n image={banner.image as string}\r\n alt={title}\r\n />\r\n );\r\n })}\r\n </div>\r\n );\r\n};\r\n","import { type TLinkClickEvent } from '@/types/ads';\r\nimport { type TBrandshopDataItem } from '@/types/brandshop';\r\nimport { buildLinkDestination } from '@/utils/helpers/ads';\r\nimport styles from './Brandshop.module.css';\r\nimport { type TTrackEvents } from '@/types/configTypes';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport { Image } from '../Image/Image';\r\n\r\ntype CategorySectionProps = {\r\n title: string;\r\n hideTitle: boolean;\r\n categories: TBrandshopDataItem[];\r\n isLoggedin: boolean;\r\n onCategoryClick: (link: TLinkClickEvent) => void;\r\n trackBrandshopHandler?: TTrackEvents;\r\n};\r\n\r\nexport const CategorySection = ({\r\n title,\r\n hideTitle,\r\n categories,\r\n isLoggedin,\r\n onCategoryClick,\r\n trackBrandshopHandler,\r\n}: CategorySectionProps) => {\r\n const handleLinkClick = (categoryItem: TBrandshopDataItem) => {\r\n if (!categoryItem?.link?.link_destination) return;\r\n trackBrandshopEvent(\r\n 'ads_bs_content_click',\r\n {\r\n contentName: categoryItem.category_name,\r\n contentOrder: categoryItem.display_order.toString(),\r\n userStatus: isLoggedin ? 'logged_in' : 'guest',\r\n platform: 'Web',\r\n },\r\n trackBrandshopHandler,\r\n );\r\n const payload = buildLinkDestination(categoryItem.link.link_destination);\r\n if (!payload) return;\r\n onCategoryClick(payload);\r\n };\r\n\r\n if (categories.length < 2) return null;\r\n\r\n const limitedCategories = categories.slice(0, 6);\r\n const sortedCategories = [...limitedCategories].sort(\r\n (a, b) => a.display_order - b.display_order,\r\n );\r\n const gridColumns =\r\n limitedCategories.length === 2 || limitedCategories.length === 4 ? 2 : 3;\r\n\r\n return (\r\n <div className={styles.sectionContainer}>\r\n {!hideTitle && <h2 className={styles.sectionTitle}>{title}</h2>}\r\n\r\n <div\r\n className={`${styles.categoryContainer} ${\r\n styles[`cols${gridColumns}`]\r\n } ${limitedCategories.length === 6 ? styles.categoryShrinkGap : ''}`}\r\n >\r\n {sortedCategories.map((category) => {\r\n if (!category) return null;\r\n\r\n return (\r\n <button\r\n key={category.tracking_id}\r\n className={styles.categoryTile}\r\n onClick={() => handleLinkClick(category)}\r\n >\r\n <div className={styles.categoryImageWrapper}>\r\n {category.image && (\r\n <Image\r\n src={category.image}\r\n alt={category.category_name ?? title}\r\n className={styles.categoryImage}\r\n />\r\n )}\r\n </div>\r\n\r\n {category.category_name && (\r\n <span\r\n className={`${styles.categoryName} ${\r\n limitedCategories.length === 6\r\n ? styles.categoryNameShrink\r\n : ''\r\n }`}\r\n >\r\n {category.category_name}\r\n </span>\r\n )}\r\n </button>\r\n );\r\n })}\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import { type TNavigationLinkItem } from '@/types/brandshop';\r\nimport { type TLinkClickEvent } from '@/types/ads';\r\nimport { buildLinkDestination } from '@/utils/helpers/ads';\r\nimport { type TTrackEvents } from '@/types/configTypes';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport styles from './Brandshop.module.css';\r\nimport { Image } from '../Image/Image';\r\n\r\ntype NavigationSectionProps = {\r\n title: string;\r\n hideTitle: boolean;\r\n logo: string;\r\n navigationLinks: TNavigationLinkItem[];\r\n isLoggedin: boolean;\r\n brandshopName?: string;\r\n onLinkClick: (link: TLinkClickEvent) => void;\r\n trackBrandshopHandler?: TTrackEvents;\r\n};\r\n\r\nexport const NavigationSection = ({\r\n title,\r\n hideTitle,\r\n logo,\r\n navigationLinks,\r\n isLoggedin,\r\n brandshopName,\r\n onLinkClick,\r\n trackBrandshopHandler,\r\n}: NavigationSectionProps) => {\r\n const handleLinkClick = (navigationItem: TNavigationLinkItem) => {\r\n trackBrandshopEvent(\r\n 'ads_bs_content_click',\r\n {\r\n contentName: navigationItem.link.link_text,\r\n contentOrder: navigationItem.link.link_display_order.toString(),\r\n userStatus: isLoggedin ? 'logged_in' : 'guest',\r\n platform: 'Web',\r\n },\r\n trackBrandshopHandler,\r\n );\r\n const payload = buildLinkDestination(navigationItem.link.link_destination);\r\n if (payload) onLinkClick(payload);\r\n };\r\n if (navigationLinks.length === 0) return null;\r\n\r\n const sortedNavigationLinks = [...navigationLinks].sort(\r\n (a, b) => a.link.link_display_order - b.link.link_display_order,\r\n );\r\n\r\n return (\r\n <div\r\n className={`${styles.sectionContainer} ${styles.navigationSectionContainer}`}\r\n >\r\n {!hideTitle && <h2 className={styles.sectionTitle}>{title}</h2>}\r\n\r\n <div className={styles.navigationSection}>\r\n {logo && (\r\n <h1>\r\n <Image\r\n src={logo}\r\n alt={brandshopName ?? title}\r\n className={styles.navigationLogo}\r\n />\r\n </h1>\r\n )}\r\n <div className={styles.navigationLinks}>\r\n {sortedNavigationLinks.map((navigationLink) => (\r\n <button\r\n key={navigationLink.tracking_id}\r\n className={styles.navigationLink}\r\n onClick={() => handleLinkClick(navigationLink)}\r\n >\r\n {navigationLink.link.link_text}\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","export enum DiscountValueTypesEnum {\r\n PERCENTAGE = 'PERCENTAGE',\r\n AMOUNT = 'AMOUNT',\r\n}\r\n\r\nexport enum DiscountTypesEnum {\r\n PROMOTION = 1,\r\n COUPON = 2,\r\n}\r\n\r\nexport type TPrice = {\r\n is_price_dropped: boolean;\r\n currency: string;\r\n base: string;\r\n final: string;\r\n final_float_price: string;\r\n};\r\n\r\nexport type TDiscount = {\r\n order: DiscountTypesEnum;\r\n name: string;\r\n description: string;\r\n type: DiscountValueTypesEnum;\r\n value: string;\r\n discount_value: string;\r\n price_after_discount: string;\r\n};\r\n\r\nexport type TProductDiscount = {\r\n value: string;\r\n priceAfterDiscount: string;\r\n};\r\n\r\nexport type TDiscountsMap = {\r\n promotion: TProductDiscount | null;\r\n coupon: TProductDiscount | null;\r\n};\r\n\r\n// Collection Item Types\r\nexport type TColorVariant = {\r\n offering_id: string;\r\n variant_id: string;\r\n slug: string;\r\n id: string;\r\n name: string;\r\n value: string;\r\n decorator: string;\r\n};\r\n\r\nexport type TCollectionItem = {\r\n offering_id: string;\r\n variant_id: string;\r\n title: string;\r\n slug: string;\r\n brand: string;\r\n main_image: string;\r\n formatted_main_image: string;\r\n gallery: string[];\r\n price: TPrice;\r\n stock_quantity: number;\r\n discounts: TDiscount[];\r\n colors: TColorVariant[];\r\n categories_tree: string[];\r\n dimensions: string;\r\n};\r\n\r\n// API Response Types\r\nexport type TApiError = {\r\n message: string;\r\n severity: string;\r\n details: string;\r\n};\r\n\r\nexport type TCollectionData = {\r\n collection_id: string;\r\n total_items: number;\r\n items: TCollectionItem[];\r\n};\r\n\r\nexport type TCollectionResponse = {\r\n success: boolean;\r\n data: TCollectionData | null;\r\n error: TApiError | null;\r\n};\r\n","import {\r\n DiscountTypesEnum,\r\n DiscountValueTypesEnum,\r\n type TDiscountsMap,\r\n type TDiscount,\r\n} from '@/types/products';\r\n\r\n// Helper function to get discount value display\r\nconst getDiscountValue = (discount: TDiscount, currency: string): string => {\r\n if (discount.type === DiscountValueTypesEnum.PERCENTAGE) {\r\n return `${discount.value}%`;\r\n }\r\n return `${discount.discount_value} ${currency}`;\r\n};\r\n\r\n// Helper function to get discounts map\r\nexport const getDiscounts = (discounts: TDiscount[], currency: string) => {\r\n return discounts.reduce(\r\n (acc, discount) => {\r\n if (discount.order === DiscountTypesEnum.PROMOTION) {\r\n return {\r\n ...acc,\r\n promotion: {\r\n value: getDiscountValue(discount, currency),\r\n priceAfterDiscount: discount.price_after_discount,\r\n },\r\n };\r\n }\r\n if (discount.order === DiscountTypesEnum.COUPON) {\r\n return {\r\n ...acc,\r\n coupon: {\r\n value: getDiscountValue(discount, currency),\r\n priceAfterDiscount: discount.price_after_discount,\r\n },\r\n };\r\n }\r\n return acc;\r\n },\r\n { promotion: null, coupon: null } as TDiscountsMap,\r\n );\r\n};\r\n","import React from 'react';\r\n\r\ntype TCardProps = {\r\n children: React.ReactNode;\r\n className?: string;\r\n};\r\n\r\nexport const Card = ({ children, className }: TCardProps) => {\r\n return <div className={className}>{children}</div>;\r\n};\r\n","import styles from './Chip.module.css';\r\n\r\ntype TChipProps = {\r\n children: React.ReactNode;\r\n className?: string;\r\n};\r\n\r\nexport function Chip({ children, className }: Readonly<TChipProps>) {\r\n return <div className={`${styles.chip} ${className}`}>{children}</div>;\r\n}\r\n","type TDiscountChipProps = {\r\n label: string;\r\n variant: 'coupon' | 'promotion' | 'priceDrop';\r\n};\r\n\r\ntype TChipInput = {\r\n saveLabelText: string;\r\n couponText: string;\r\n priceDropText: string;\r\n promotionValue?: string;\r\n hasCoupon?: boolean;\r\n isPriceDropped?: boolean;\r\n};\r\n\r\nexport const getDiscountChipDetails = (\r\n props: TChipInput,\r\n): TDiscountChipProps | null => {\r\n const {\r\n promotionValue,\r\n hasCoupon,\r\n isPriceDropped,\r\n saveLabelText,\r\n couponText,\r\n priceDropText,\r\n } = props;\r\n if (isPriceDropped) {\r\n return {\r\n label: priceDropText,\r\n variant: 'priceDrop',\r\n };\r\n }\r\n if (hasCoupon) {\r\n return {\r\n label: couponText,\r\n variant: 'coupon',\r\n };\r\n }\r\n if (promotionValue) {\r\n return {\r\n label: `${saveLabelText} ${promotionValue}`,\r\n variant: 'promotion',\r\n };\r\n }\r\n\r\n return null;\r\n};\r\n","import { type TLanguage } from '@/types/types';\r\n\r\nexport const translations = {\r\n en: {\r\n couponBadge: {\r\n extra: 'Extra',\r\n offAtCheckout: 'off at checkout',\r\n },\r\n discountChip: {\r\n save: 'Save',\r\n onlineExclusive: 'Online exclusive offer',\r\n priceDrop: 'Price drop',\r\n },\r\n mylo: {\r\n from: 'From',\r\n perMonth: '/mo with',\r\n },\r\n },\r\n ar: {\r\n couponBadge: {\r\n extra: 'خصم إضافي',\r\n offAtCheckout: 'يطبق عند الدفع',\r\n },\r\n discountChip: {\r\n save: 'هتوفر',\r\n onlineExclusive: 'عرض أونلاين حصري',\r\n priceDrop: 'سعر أقل',\r\n },\r\n mylo: {\r\n from: 'يبدأ من',\r\n perMonth: '/الشهر مع',\r\n },\r\n },\r\n} as const;\r\n\r\nexport const getTranslation = (language: TLanguage) => translations[language];\r\n","import { type TProductDiscount } from '@/types/products';\r\nimport { Chip } from '../Chip/Chip';\r\nimport { getDiscountChipDetails } from '@/utils/helpers/discountChip';\r\nimport styles from './ProductsCarousel.module.css';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { getTranslation } from '@/utils/helpers/translate';\r\n\r\ntype TDiscountChipProps = {\r\n language: TLanguage;\r\n promotionValue?: string;\r\n coupon?: TProductDiscount | null;\r\n isPriceDropped?: boolean;\r\n className?: string;\r\n};\r\n\r\nconst variantStyles = {\r\n coupon: styles.discountChipCoupon,\r\n promotion: styles.discountChipPromotion,\r\n priceDrop: styles.discountChipPriceDrop,\r\n};\r\n\r\nexport function DiscountChip({\r\n language,\r\n promotionValue,\r\n coupon,\r\n isPriceDropped,\r\n className,\r\n}: Readonly<TDiscountChipProps>) {\r\n const translate = getTranslation(language);\r\n\r\n const discountChipDetails = getDiscountChipDetails({\r\n promotionValue,\r\n hasCoupon: !!coupon,\r\n isPriceDropped,\r\n saveLabelText: translate.discountChip.save,\r\n couponText: translate.discountChip.onlineExclusive,\r\n priceDropText: translate.discountChip.priceDrop,\r\n });\r\n\r\n if (!discountChipDetails) return null;\r\n\r\n return (\r\n <Chip\r\n className={`${className} ${variantStyles[discountChipDetails.variant]}`}\r\n >\r\n {discountChipDetails.label}\r\n </Chip>\r\n );\r\n}\r\n","export default \"data:image/svg+xml,%3csvg%20width='14'%20height='14'%20viewBox='0%200%2014%2014'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.94%206.38667L6.94%200.386667C6.7%200.146667%206.36667%200%206%200H1.33333C0.6%200%200%200.6%200%201.33333V6C0%206.36667%200.146667%206.7%200.393333%206.94667L6.39333%2012.9467C6.63333%2013.1867%206.96667%2013.3333%207.33333%2013.3333C7.7%2013.3333%208.03333%2013.1867%208.27333%2012.94L12.94%208.27333C13.1867%208.03333%2013.3333%207.7%2013.3333%207.33333C13.3333%206.96667%2013.18%206.62667%2012.94%206.38667ZM2.33333%203.33333C1.78%203.33333%201.33333%202.88667%201.33333%202.33333C1.33333%201.78%201.78%201.33333%202.33333%201.33333C2.88667%201.33333%203.33333%201.78%203.33333%202.33333C3.33333%202.88667%202.88667%203.33333%202.33333%203.33333Z'%20fill='%231AA573'/%3e%3c/svg%3e\"","import styles from './ProductsCarousel.module.css';\r\nimport tag from '@/assets/tag.svg';\r\nimport { Image } from '../Image/Image';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { getTranslation } from '@/utils/helpers/translate';\r\n\r\ntype TCouponBadgeProps = {\r\n value: string;\r\n language: TLanguage;\r\n};\r\n\r\nexport function CouponBadge({ value, language }: Readonly<TCouponBadgeProps>) {\r\n const translate = getTranslation(language);\r\n\r\n return (\r\n <div className={styles.couponBadge}>\r\n <Image alt=\"tag\" src={tag} width={13.3} height={13.3} />\r\n <span>\r\n {`${translate.couponBadge.extra} ${value} ${translate.couponBadge.offAtCheckout}`}\r\n </span>\r\n </div>\r\n );\r\n}\r\n","import type { TPrice, TDiscount } from '@/types/products';\r\nimport styles from './ProductsCarousel.module.css';\r\nimport { getDiscounts } from '@/utils/helpers/productDiscounts';\r\n\r\ntype TPriceDisplayProps = {\r\n price: TPrice;\r\n discounts: TDiscount[];\r\n};\r\n\r\nexport function PriceDisplay({\r\n price,\r\n discounts,\r\n}: Readonly<TPriceDisplayProps>) {\r\n const { promotion } = getDiscounts(discounts, price.currency);\r\n const hasDiscount = promotion?.priceAfterDiscount;\r\n\r\n return (\r\n <div className={styles.priceWrapper}>\r\n <span\r\n className={`${styles.priceCurrency} ${hasDiscount && styles.withPromotion}`}\r\n >\r\n {price.currency}\r\n </span>\r\n <span\r\n className={`${styles.priceAmount} ${hasDiscount && styles.withPromotion}`}\r\n >\r\n {promotion ? promotion.priceAfterDiscount : price.base}\r\n </span>\r\n {hasDiscount && (\r\n <span className={styles.priceOriginal}>{price.base}</span>\r\n )}\r\n </div>\r\n );\r\n}\r\n","import styles from './ProductsCarousel.module.css';\r\n\r\ntype TProductLinkProps = {\r\n title: string;\r\n};\r\n\r\nexport function ProductTitle({ title }: Readonly<TProductLinkProps>) {\r\n return <div className={styles.ProductTitle}>{title}</div>;\r\n}\r\n","import { getDiscounts } from '@/utils/helpers/productDiscounts';\r\nimport type { TDiscount, TPrice } from '@/types/products';\r\nimport { Card } from '../Card/Card';\r\nimport { Image } from '../Image/Image';\r\nimport { DiscountChip } from './DiscountChip';\r\nimport { CouponBadge } from './CouponBadge';\r\nimport { PriceDisplay } from './PriceDisplay';\r\nimport styles from './ProductsCarousel.module.css';\r\nimport { ProductTitle } from './ProductTitle';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { getInstallmentInfoPLP } from 'mylo-online-checkout-sdk';\r\nimport myloENIcon from '@/assets/mylo-en.svg';\r\nimport myloARIcon from '@/assets/mylo.svg';\r\nimport { useAsyncMemo } from '@/hooks/use-async-memo';\r\nimport { type TMyloGetInstallmentInfoPLP } from '@/types/tenures';\r\nimport { parsePriceToNumber } from '@/utils/helpers/price-utils';\r\nimport Skeleton from '../Carousel/AdSkeleton';\r\nimport { getTranslation } from '@/utils/helpers/translate';\r\n\r\nconst MYLO_MINIMUM_PRICE_THRESHOLD = 500;\r\n\r\ntype TProductCardProps = {\r\n id: string;\r\n title: string;\r\n brand: string;\r\n image: string;\r\n price: TPrice;\r\n discounts: TDiscount[];\r\n language: TLanguage;\r\n className?: string;\r\n};\r\n\r\nexport function ProductCard({\r\n id,\r\n title,\r\n brand,\r\n image,\r\n price,\r\n discounts = [],\r\n language,\r\n className,\r\n}: Readonly<TProductCardProps>) {\r\n const { promotion, coupon } = getDiscounts(discounts, price.currency);\r\n const translate = getTranslation(language);\r\n\r\n // const [myloInstallmentInfo, isMyloInstallmentInfoLoading] =\r\n // useAsyncMemo<TMyloGetInstallmentInfoPLP | null>(\r\n // () => getInstallmentInfoPLP(Number(price.final.replaceAll(',', ''))),\r\n // [price.final],\r\n // );\r\n\r\n // const installmentText = `${translate.mylo.from} ${myloInstallmentInfo?.amount ?? '0'}${translate.mylo.perMonth}`;\r\n\r\n return (\r\n <Card key={id} className={`${styles.card} ${className}`}>\r\n <header className={styles.header}>\r\n <div className={styles.imageContainer}>\r\n <Image className={styles.image} src={image} alt={title} />\r\n </div>\r\n\r\n <div className={styles.topControls}>\r\n <DiscountChip\r\n language={language}\r\n coupon={coupon}\r\n promotionValue={promotion?.value}\r\n isPriceDropped={price.is_price_dropped}\r\n />\r\n </div>\r\n </header>\r\n\r\n <footer className={styles.footer}>\r\n <div className={styles.priceSection}>\r\n <PriceDisplay price={price} discounts={discounts} />\r\n </div>\r\n {/* {isMyloInstallmentInfoLoading ? (\r\n <Skeleton className={styles.myloSkeleton} />\r\n ) : (\r\n parsePriceToNumber(price.final) >= MYLO_MINIMUM_PRICE_THRESHOLD && (\r\n <div className={styles.myloContainer}>\r\n <p className={styles.myloText}>{installmentText}</p>\r\n <Image\r\n className={styles.myloIcon}\r\n src={language === 'en' ? myloENIcon : myloARIcon}\r\n alt=\"mylo\"\r\n />\r\n </div>\r\n )\r\n )} */}\r\n <h4 className={styles.brand}>{brand}</h4>\r\n\r\n <ProductTitle title={title} />\r\n\r\n {coupon && <CouponBadge value={coupon.value} language={language} />}\r\n </footer>\r\n </Card>\r\n );\r\n}\r\n","import {\r\n AdCarousel,\r\n AdCarouselContent,\r\n AdCarouselItem,\r\n AdCarouselNext,\r\n AdCarouselPrevious,\r\n AdCarouselPagination,\r\n AdCarouselApi,\r\n} from '../Carousel/AdCarousel';\r\nimport { useState, useEffect } from 'react';\r\nimport { ProductCard } from '../ProductsCarousel/ProductCard';\r\nimport styles from './ProductsCarousel.module.css';\r\nimport { TCollectionItem } from '@/types/products';\r\nimport { TLanguage } from '@/types/types';\r\n\r\ntype ProductsCarouselProps = {\r\n products: TCollectionItem[];\r\n onProductClick: (product: TCollectionItem, index: number) => void;\r\n slidesToScroll?: number;\r\n language: TLanguage;\r\n};\r\n\r\nexport function ProductsCarousel({\r\n slidesToScroll,\r\n products,\r\n onProductClick,\r\n language,\r\n}: Readonly<ProductsCarouselProps>) {\r\n const [api, setApi] = useState<AdCarouselApi>();\r\n const [current, setCurrent] = useState(0);\r\n const [count, setCount] = useState(0);\r\n const [canScrollPrev, setCanScrollPrev] = useState(false);\r\n const [canScrollNext, setCanScrollNext] = useState(false);\r\n\r\n useEffect(() => {\r\n if (!api) {\r\n return;\r\n }\r\n\r\n const updateCarouselState = () => {\r\n setCount(api.scrollSnapList().length);\r\n setCurrent(api.selectedScrollSnap());\r\n setCanScrollPrev(api.canScrollPrev());\r\n setCanScrollNext(api.canScrollNext());\r\n };\r\n\r\n updateCarouselState();\r\n\r\n api.on('select', updateCarouselState);\r\n\r\n api.on('reInit', updateCarouselState);\r\n\r\n return () => {\r\n api.off('select', updateCarouselState);\r\n api.off('reInit', updateCarouselState);\r\n };\r\n }, [api]);\r\n\r\n return (\r\n <div className={styles.container}>\r\n <AdCarousel\r\n opts={{\r\n align: 'start',\r\n slidesToScroll: slidesToScroll ?? 1,\r\n direction: language === 'ar' ? 'rtl' : 'ltr',\r\n }}\r\n setApi={setApi}\r\n className={styles.carousel}\r\n >\r\n <AdCarouselContent className={styles.carouselContent}>\r\n {products.map((product, index) => (\r\n <AdCarouselItem\r\n key={`${product.offering_id}-${index}`}\r\n className={styles.carouselItem}\r\n onClick={() => onProductClick(product, index)}\r\n >\r\n <ProductCard\r\n id={product.offering_id}\r\n brand={product.brand}\r\n image={product.formatted_main_image}\r\n price={product.price}\r\n title={product.title}\r\n discounts={product.discounts}\r\n language={language}\r\n />\r\n </AdCarouselItem>\r\n ))}\r\n </AdCarouselContent>\r\n\r\n {canScrollPrev && (\r\n <AdCarouselPrevious\r\n className={styles.navButtonPrev}\r\n iconClassName={styles.navButtonPrevIcon}\r\n />\r\n )}\r\n {canScrollNext && (\r\n <AdCarouselNext\r\n className={styles.navButtonNext}\r\n iconClassName={styles.navButtonNextIcon}\r\n />\r\n )}\r\n </AdCarousel>\r\n\r\n <AdCarouselPagination\r\n slidesCount={count}\r\n currentIndex={current}\r\n onClick={(index) => api?.scrollTo(index)}\r\n showProgress={false}\r\n containerClassName={styles.paginationContainer}\r\n buttonClassName={styles.paginationButton}\r\n dotClassName={styles.paginationDot}\r\n activeDotClassName={styles.paginationActiveDot}\r\n />\r\n </div>\r\n );\r\n}\r\n","import { LinkDestination } from '@/types/ads';\r\nimport { TCollectionItem } from '@/types/products';\r\n\r\nexport const mapProductToLinkDestination = (\r\n product: TCollectionItem,\r\n): LinkDestination => {\r\n return {\r\n type: 'single product',\r\n val: [product.offering_id],\r\n filters: [\r\n {\r\n key: 'slug',\r\n value: [product.slug],\r\n },\r\n ],\r\n };\r\n};\r\n","import { generateAccessToken } from '@/utils/helpers/authToken';\r\nimport { getBaseUrl } from '@/utils/helpers/getBaseUrl';\r\nimport {\r\n type TCollectionData,\r\n type TCollectionResponse,\r\n} from '@/types/products';\r\nimport { type TGetCollectionProps } from '../queries/useGetCollection';\r\n\r\nexport const getCollection = async ({\r\n language,\r\n collectionId,\r\n environment,\r\n adServerApiKey,\r\n}: TGetCollectionProps): Promise<TCollectionData | null> => {\r\n const [token, timestamp] = await generateAccessToken(adServerApiKey);\r\n const adServerBaseUrl = getBaseUrl('adServer', environment);\r\n\r\n try {\r\n const res = await fetch(\r\n `${adServerBaseUrl}/api/v2/brandshop/server/collection/${collectionId}`,\r\n {\r\n headers: {\r\n lang: language,\r\n device: 'web',\r\n 'auth-token': token,\r\n 'auth-timestamp': timestamp,\r\n 'accept-language': language,\r\n },\r\n },\r\n );\r\n\r\n const collectionResponse: TCollectionResponse = await res.json();\r\n return collectionResponse.data;\r\n } catch (error) {\r\n throw new Error(`Failed to fetch collection data - ${error}`);\r\n }\r\n};\r\n","import { useQuery } from '@tanstack/react-query';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport { getCollection } from '../services/getCollection';\r\n\r\nexport type TGetCollectionProps = {\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n collectionId: string;\r\n adServerApiKey: string;\r\n};\r\nexport const GET_COLLECTION_QUERY_KEY = 'collection';\r\n\r\nexport const useGetCollectionQuery = ({\r\n language,\r\n collectionId,\r\n environment,\r\n adServerApiKey,\r\n}: TGetCollectionProps) => {\r\n const collectionQueryKey = [GET_COLLECTION_QUERY_KEY, collectionId, language];\r\n\r\n return useQuery({\r\n queryKey: collectionQueryKey,\r\n queryFn: () =>\r\n getCollection({\r\n language,\r\n collectionId,\r\n environment,\r\n adServerApiKey,\r\n }),\r\n });\r\n};\r\n","import Skeleton from '../Carousel/AdSkeleton';\r\nimport styles from './ProductCardSkeleton.module.css';\r\n\r\ntype TProductCardSkeletonProps = {\r\n className?: string;\r\n};\r\n\r\nexport const ProductCardSkeleton = (props: TProductCardSkeletonProps) => {\r\n const { className } = props;\r\n\r\n return (\r\n <div className={`${styles.card} ${className || ''}`}>\r\n <Skeleton className={styles.imageSkeleton} />\r\n <Skeleton className={styles.titleSkeleton} />\r\n <Skeleton className={styles.descriptionSkeleton} />\r\n <Skeleton className={styles.priceSkeleton} />\r\n <Skeleton className={styles.buttonSkeleton} />\r\n </div>\r\n );\r\n};\r\n","import Skeleton from '../Carousel/AdSkeleton';\r\nimport { ProductCardSkeleton } from './ProductCardSkeleton';\r\nimport styles from './ProductSliderSkeleton.module.css';\r\n\r\ntype TProductSliderSkeletonProps = {\r\n length?: number;\r\n};\r\n\r\nexport const ProductSliderSkeleton = (props: TProductSliderSkeletonProps) => {\r\n const { length } = props;\r\n const skeletonLength = length ?? 5;\r\n\r\n return (\r\n <div className={styles.container}>\r\n <div className={styles.header}>\r\n <Skeleton className={styles.titleSkeleton} />\r\n </div>\r\n <div className={styles.carouselWrapper}>\r\n <div className={styles.carouselContainer}>\r\n {Array.from({ length: skeletonLength }, (_, index) => (\r\n <div key={index} className={styles.cardWrapper}>\r\n <ProductCardSkeleton />\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import { ProductsCarousel } from '../ProductsCarousel/ProductsCarousel';\r\nimport { TCollectionItem } from '@/types/products';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport { TEnvironment, TTrackEvents } from '@/types/configTypes';\r\nimport { buildLinkDestination } from '@/utils/helpers/ads';\r\nimport { TLinkClickEvent } from '@/types/ads';\r\nimport { mapProductToLinkDestination } from '@/utils/helpers/products';\r\nimport { type TLanguage } from '@/types/types';\r\nimport styles from './Brandshop.module.css';\r\nimport { type TBrandshopCollection } from '@/types/brandshop';\r\nimport { useGetCollectionQuery } from '@/api/queries/useGetCollection';\r\nimport { ProductSliderSkeleton } from '../ProductsCarousel/ProductSliderSkeleton';\r\n\r\ntype ProductSliderSectionProps = {\r\n products: TBrandshopCollection;\r\n title: string;\r\n hideTitle: boolean;\r\n isLoggedin: boolean;\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n trackBrandshopHandler?: TTrackEvents;\r\n onProductClick: (data: TLinkClickEvent) => void;\r\n};\r\n\r\nexport function ProductSliderSection({\r\n products,\r\n title,\r\n hideTitle,\r\n isLoggedin,\r\n language,\r\n environment,\r\n adServerApiKey,\r\n trackBrandshopHandler,\r\n onProductClick,\r\n}: Readonly<ProductSliderSectionProps>) {\r\n const { data, isLoading, error } = useGetCollectionQuery({\r\n language,\r\n collectionId: products.collection_id ?? '',\r\n environment,\r\n adServerApiKey,\r\n });\r\n const handleLinkClick = (productItem: TCollectionItem, index: number) => {\r\n trackBrandshopEvent(\r\n 'ads_bs_content_click',\r\n {\r\n contentName: productItem.title,\r\n contentOrder: (index + 1).toString(),\r\n userStatus: isLoggedin ? 'logged_in' : 'guest',\r\n platform: 'Web',\r\n },\r\n trackBrandshopHandler,\r\n );\r\n\r\n // Map product to LinkDestination and build the payload\r\n const linkDestination = mapProductToLinkDestination(productItem);\r\n const payload = buildLinkDestination(linkDestination);\r\n\r\n if (!payload) return;\r\n onProductClick(payload);\r\n };\r\n\r\n if (isLoading) return <ProductSliderSkeleton />;\r\n\r\n if (error || !data) return null;\r\n\r\n return (\r\n <div className={styles.sectionContainer}>\r\n {!hideTitle && <h2 className={styles.sectionTitle}>{title}</h2>}\r\n <ProductsCarousel\r\n products={data.items}\r\n onProductClick={(product, index) => handleLinkClick(product, index)}\r\n language={language}\r\n />\r\n </div>\r\n );\r\n}\r\n","import { TBrandshopSection } from '@/types/brandshop';\r\nimport { BannerSection } from './BannerSection';\r\nimport { CategorySection } from './CategorySection';\r\nimport { NavigationSection } from './NavigationSection';\r\nimport { type TLinkClickEvent } from '@/types/ads';\r\nimport { type TEnvironment, type TTrackEvents } from '@/types/configTypes';\r\nimport { useInView } from 'react-intersection-observer';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport { ProductSliderSection } from './ProductSliderSection';\r\nimport { TLanguage } from '@/types/types';\r\n\r\ntype BrandshopSectionProps = {\r\n section: TBrandshopSection;\r\n isLoggedin: boolean;\r\n brandName: string;\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n brandshopName?: string;\r\n onLinkClick: (data: TLinkClickEvent) => void;\r\n trackBrandshopHandler?: TTrackEvents;\r\n};\r\n\r\nexport const BrandshopSection = ({\r\n section,\r\n onLinkClick,\r\n trackBrandshopHandler,\r\n isLoggedin,\r\n brandName,\r\n language,\r\n environment,\r\n adServerApiKey,\r\n brandshopName,\r\n}: BrandshopSectionProps) => {\r\n const {\r\n section_type,\r\n section_title,\r\n show_section_title,\r\n data,\r\n section_display_order,\r\n } = section;\r\n\r\n const { ref } = useInView({\r\n onChange: (inView) => {\r\n if (inView) {\r\n trackBrandshopEvent(\r\n 'ads_bs_section_view',\r\n {\r\n brandName,\r\n sectionName: section_title,\r\n sectionOrder: section_display_order.toString(),\r\n userStatus: isLoggedin ? 'logged_in' : 'guest',\r\n platform: 'Web',\r\n },\r\n trackBrandshopHandler,\r\n );\r\n }\r\n },\r\n });\r\n\r\n return (\r\n <div ref={ref} style={{ width: '100%' }}>\r\n {(() => {\r\n switch (section_type) {\r\n case 'nav':\r\n return (\r\n <NavigationSection\r\n title={section_title}\r\n hideTitle={!show_section_title}\r\n logo={data[0].logo ?? ''}\r\n navigationLinks={data[0].navigation_links ?? []}\r\n onLinkClick={onLinkClick}\r\n isLoggedin={isLoggedin}\r\n trackBrandshopHandler={trackBrandshopHandler}\r\n brandshopName={brandshopName}\r\n />\r\n );\r\n\r\n case 'category':\r\n return (\r\n <CategorySection\r\n title={section_title}\r\n hideTitle={!show_section_title}\r\n categories={data}\r\n onCategoryClick={onLinkClick}\r\n isLoggedin={isLoggedin}\r\n trackBrandshopHandler={trackBrandshopHandler}\r\n />\r\n );\r\n\r\n case 'banner':\r\n return (\r\n <BannerSection\r\n title={section_title}\r\n banners={data}\r\n hideTitle={!show_section_title}\r\n onBannerClick={onLinkClick}\r\n isLoggedin={isLoggedin}\r\n sectionTitle={section_title}\r\n trackBrandshopHandler={trackBrandshopHandler}\r\n />\r\n );\r\n case 'productSlider':\r\n return (\r\n <ProductSliderSection\r\n products={data[0]}\r\n title={section_title}\r\n hideTitle={!show_section_title}\r\n isLoggedin={isLoggedin}\r\n trackBrandshopHandler={trackBrandshopHandler}\r\n onProductClick={onLinkClick}\r\n language={language}\r\n environment={environment}\r\n adServerApiKey={adServerApiKey}\r\n />\r\n );\r\n\r\n default:\r\n return null;\r\n }\r\n })()}\r\n </div>\r\n );\r\n};\r\n","export const debounce = <T extends unknown[]>(\r\n callback: (...args: T) => void,\r\n delay: number,\r\n): ((...args: T) => void) => {\r\n let timeoutId: ReturnType<typeof setTimeout>;\r\n\r\n return (...args: T) => {\r\n clearTimeout(timeoutId);\r\n timeoutId = setTimeout(() => {\r\n callback(...args);\r\n }, delay);\r\n };\r\n};\r\n","import { debounce } from '@/utils/helpers/utilities';\r\nimport { useEffect, useState } from 'react';\r\n\r\n/**\r\n * Hook to detect if the user has scrolled to (or near) the bottom of the page.\r\n * @param offset distance in pixels from the bottom to trigger earlier (default: 5px)\r\n */\r\nexport function useDetectScrolledToBottom(offset: number = 5): boolean {\r\n const [isBottom, setIsBottom] = useState(false);\r\n\r\n useEffect(() => {\r\n const handleScroll = () => {\r\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\r\n const windowHeight = window.innerHeight;\r\n const fullHeight = document.documentElement.scrollHeight;\r\n\r\n const reachedBottom = scrollTop + windowHeight >= fullHeight - offset;\r\n setIsBottom(reachedBottom);\r\n };\r\n\r\n const debouncedScroll = debounce(handleScroll, 100);\r\n\r\n window.addEventListener('scroll', debouncedScroll, { passive: true });\r\n debouncedScroll();\r\n\r\n return () => {\r\n window.removeEventListener('scroll', debouncedScroll);\r\n };\r\n }, [offset]);\r\n\r\n return isBottom;\r\n}\r\n","import Skeleton from '../Carousel/AdSkeleton';\r\nimport styles from './Brandshop.module.css';\r\n\r\nexport function BrandshopSkeleton() {\r\n const NAVIGATION_ITEMS_COUNT = 3;\r\n const CATEGORY_ITEMS_COUNT = 2;\r\n\r\n return (\r\n <div className={styles.brandshopContainerSkeleton}>\r\n <Skeleton className={styles.bannerSkeleton} />\r\n\r\n <div className={styles.navContainerSkeleton}>\r\n {Array.from({ length: NAVIGATION_ITEMS_COUNT }).map((_, index) => (\r\n <Skeleton key={index} className={styles.navPillSkeleton} />\r\n ))}\r\n </div>\r\n\r\n <div\r\n className={styles.categoryGridSkeleton}\r\n style={{\r\n gridTemplateColumns: `repeat(${Math.min(CATEGORY_ITEMS_COUNT, 2)}, 1fr)`,\r\n }}\r\n >\r\n {Array.from({ length: CATEGORY_ITEMS_COUNT }).map((_, index) => (\r\n <Skeleton key={index} className={styles.categoryTileSkeleton} />\r\n ))}\r\n </div>\r\n\r\n <Skeleton className={styles.promoSkeleton} />\r\n </div>\r\n );\r\n}\r\n","import { useEffect } from 'react';\r\nimport { useGetBrandshopQuery } from '@/api/queries/useGetBrandshop';\r\nimport { useIsPlatform } from '@/hooks/use-is-platform';\r\nimport { AdsDeviceType } from '@/types/ads';\r\nimport { type TBrandshopProps } from './Brandshop';\r\nimport { BrandshopSection } from './BrandshopSection';\r\nimport { trackBrandshopEvent } from '@/utils/analytics/trackBrandshopEvents';\r\nimport { useDetectScrolledToBottom } from '@/hooks/useDetectScrolledToBottom';\r\nimport { BrandshopSkeleton } from './BrandshopSkeleton';\r\nimport styles from './Brandshop.module.css';\r\n\r\nexport function BrandshopContent({\r\n language,\r\n brandshopId,\r\n environment,\r\n adServerApiKey,\r\n isLoggedin,\r\n brandshop,\r\n onLinkClick,\r\n trackBrandshopHandler,\r\n}: Readonly<TBrandshopProps>) {\r\n const { isLaptop, isDesktop } = useIsPlatform();\r\n const deviceType =\r\n isLaptop || isDesktop ? AdsDeviceType.Web : AdsDeviceType.Mobile;\r\n\r\n let data = brandshop;\r\n\r\n const {\r\n data: brandshopData,\r\n isLoading,\r\n error,\r\n } = useGetBrandshopQuery({\r\n language,\r\n brandshopId,\r\n environment,\r\n adServerApiKey,\r\n deviceType,\r\n enabled: !brandshop,\r\n });\r\n\r\n data ??= brandshopData;\r\n\r\n const isBottomReached = useDetectScrolledToBottom();\r\n\r\n const brandName = data?.name || '';\r\n const userStatus = isLoggedin ? 'logged_in' : 'guest';\r\n const platform = 'Web';\r\n\r\n useEffect(() => {\r\n window.scrollTo(0, 0);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (!data) return;\r\n trackBrandshopEvent(\r\n 'ads_bs_pageload',\r\n { brandName, userStatus, platform },\r\n trackBrandshopHandler,\r\n );\r\n }, [data]);\r\n\r\n useEffect(() => {\r\n if (!data || !isBottomReached) return;\r\n trackBrandshopEvent(\r\n 'ads_bs_pageend',\r\n { brandName, userStatus, platform },\r\n trackBrandshopHandler,\r\n );\r\n }, [isBottomReached]);\r\n\r\n if (isLoading) return <BrandshopSkeleton />;\r\n if (error) {\r\n throw new Error(\r\n `brandshop with id ${brandshopId} failed to load} - ${error?.message || 'unknown error'}`,\r\n );\r\n }\r\n\r\n const content = data?.content;\r\n if (!Array.isArray(content)) return null;\r\n\r\n const sortedSections = [...content].sort(\r\n (a, b) => a.section_display_order - b.section_display_order,\r\n );\r\n\r\n return (\r\n <div className={styles.brandshopContent}>\r\n {sortedSections.map((section) => (\r\n <BrandshopSection\r\n key={section.tracking_id}\r\n section={section}\r\n onLinkClick={onLinkClick}\r\n isLoggedin={isLoggedin}\r\n brandName={brandName}\r\n trackBrandshopHandler={trackBrandshopHandler}\r\n language={language}\r\n environment={environment}\r\n adServerApiKey={adServerApiKey}\r\n brandshopName={data?.name}\r\n />\r\n ))}\r\n </div>\r\n );\r\n}\r\n","export default \"data:image/svg+xml,%3csvg%20width='49'%20height='48'%20viewBox='0%200%2049%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M24.4941%2020.0311V24.0242M24.5%2030H24.52M22.7708%206.98426L6.27321%2034.9912C5.4892%2036.3221%206.45019%2038%207.9965%2038H40.9918C42.5381%2038%2043.4991%2036.3221%2042.7151%2034.9912L26.2174%206.98426C25.4444%205.67192%2023.5439%205.67191%2022.7708%206.98426ZM25%2030C25%2030.2761%2024.7761%2030.5%2024.5%2030.5C24.2239%2030.5%2024%2030.2761%2024%2030C24%2029.7239%2024.2239%2029.5%2024.5%2029.5C24.7761%2029.5%2025%2029.7239%2025%2030Z'%20stroke='%23DA1E28'%20stroke-width='4'%20stroke-linecap='round'/%3e%3c/svg%3e\"","import errorIcon from '@/assets/error.svg';\r\nimport styles from './Brandshop.module.css';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { Image } from '../Image/Image';\r\n\r\nfunction BrandshopError({ language }: Readonly<{ language: TLanguage }>) {\r\n const isArabic = language === 'ar';\r\n\r\n const heading = isArabic ? 'حدث خطأ ما' : 'Something went wrong';\r\n const description = isArabic\r\n ? 'نواجه مشكلة في تحميل هذه الصفحة. يرجى الانتظار قليلاً؛ سيتم حلها قريباً.'\r\n : \"We're having trouble loading this page. Please bear with us; it should be resolved shortly.\";\r\n const buttonLabel = isArabic ? 'إعادة المحاولة' : 'Try again';\r\n\r\n return (\r\n <div className={styles.brandshopError}>\r\n <Image src={errorIcon} className={styles.errorIcon} alt=\"error\" />\r\n <div className={styles.errorContent}>\r\n <div className={styles.errorText}>\r\n <h2>{heading}</h2>\r\n <p>{description}</p>\r\n </div>\r\n <button\r\n className={styles.errorButton}\r\n onClick={() => window.location.reload()}\r\n >\r\n {buttonLabel}\r\n </button>\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\nexport default BrandshopError;\r\n","import { Component, ErrorInfo, ReactNode } from 'react';\r\n\r\ninterface ErrorBoundaryProps {\r\n children: ReactNode;\r\n fallback: ReactNode;\r\n}\r\n\r\ninterface ErrorBoundaryState {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n}\r\n\r\nclass ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\r\n constructor(props: ErrorBoundaryProps) {\r\n super(props);\r\n this.state = { hasError: false, error: null, errorInfo: null };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\r\n return { hasError: true, error: error, errorInfo: null };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\r\n this.setState({ error, errorInfo });\r\n }\r\n\r\n render(): ReactNode {\r\n if (this.state.hasError) {\r\n return this.props.fallback;\r\n }\r\n\r\n return this.props.children;\r\n }\r\n}\r\n\r\nexport default ErrorBoundary;\r\n","import { type TLanguage } from '@/types/types';\r\nimport { type TTrackEvents, type TEnvironment } from '@/types/configTypes';\r\nimport { ReactQueryProvider } from '@/providers/ReactQueryProvider';\r\nimport { BrandshopContent } from './BrandshopContent';\r\nimport { type TLinkClickEvent } from '@/types/ads';\r\nimport BrandshopError from './BrandshopError';\r\nimport ErrorBoundary from '../ErrorBoundary/ErrorBoundary';\r\nimport { type TBrandshopData } from '@/types/brandshop';\r\n\r\nexport type TBrandshopProps = {\r\n language: TLanguage;\r\n brandshopId: string;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n isLoggedin: boolean;\r\n brandshop?: TBrandshopData;\r\n onLinkClick: (event: TLinkClickEvent) => void;\r\n trackBrandshopHandler?: TTrackEvents;\r\n};\r\n\r\nexport default function Brandshop(props: Readonly<TBrandshopProps>) {\r\n return (\r\n <ReactQueryProvider>\r\n <ErrorBoundary fallback={<BrandshopError language={props.language} />}>\r\n <BrandshopContent {...props} />\r\n </ErrorBoundary>\r\n </ReactQueryProvider>\r\n );\r\n}\r\n"],"names":["getBrandshop","deviceType","language","brandshopId","environment","adServerApiKey","token","timestamp","generateAccessToken","adServerBaseUrl","getBaseUrl","error","GET_BRANDSHOP_QUERY_KEY","useGetBrandshopQuery","enabled","useQuery","BannerWithLink","image","text","alt","onClick","styles","jsx","Image","Banner","trackBrandshopEvent","eventName","props","trackEvent","brandName","userStatus","platform","sectionName","sectionOrder","contentName","contentOrder","BannerSection","title","hideTitle","banners","isLoggedin","sectionTitle","onBannerClick","trackBrandshopHandler","handleLinkClick","bannerItem","payload","buildLinkDestination","jsxs","banner","CategorySection","categories","onCategoryClick","categoryItem","limitedCategories","sortedCategories","a","b","gridColumns","category","NavigationSection","logo","navigationLinks","brandshopName","onLinkClick","navigationItem","sortedNavigationLinks","navigationLink","DiscountValueTypesEnum","DiscountTypesEnum","getDiscountValue","discount","currency","getDiscounts","discounts","acc","Card","children","className","Chip","getDiscountChipDetails","promotionValue","hasCoupon","isPriceDropped","saveLabelText","couponText","priceDropText","translations","getTranslation","variantStyles","DiscountChip","coupon","translate","discountChipDetails","tag","CouponBadge","value","PriceDisplay","price","promotion","hasDiscount","ProductTitle","ProductCard","id","brand","ProductsCarousel","slidesToScroll","products","onProductClick","api","setApi","useState","current","setCurrent","count","setCount","canScrollPrev","setCanScrollPrev","canScrollNext","setCanScrollNext","useEffect","updateCarouselState","AdCarousel","AdCarouselContent","product","index","AdCarouselItem","AdCarouselPrevious","AdCarouselNext","AdCarouselPagination","mapProductToLinkDestination","getCollection","collectionId","GET_COLLECTION_QUERY_KEY","useGetCollectionQuery","ProductCardSkeleton","Skeleton","ProductSliderSkeleton","length","skeletonLength","_","ProductSliderSection","data","isLoading","productItem","linkDestination","BrandshopSection","section","section_type","section_title","show_section_title","section_display_order","ref","useInView","inView","debounce","callback","delay","timeoutId","args","useDetectScrolledToBottom","offset","isBottom","setIsBottom","debouncedScroll","scrollTop","windowHeight","fullHeight","reachedBottom","BrandshopSkeleton","BrandshopContent","brandshop","isLaptop","isDesktop","useIsPlatform","AdsDeviceType","brandshopData","isBottomReached","content","sortedSections","errorIcon","BrandshopError","isArabic","heading","description","buttonLabel","ErrorBoundary","Component","errorInfo","Brandshop","ReactQueryProvider"],"mappings":";;;;;AAiBO,MAAMA,KAAe,OAAO;AAAA,EACjC,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AACF,MAAmD;AACjD,QAAM,CAACC,GAAOC,CAAS,IAAI,MAAMC,EAAoBH,CAAc,GAC7DI,IAAkBC,EAAW,YAAYN,CAAW;AAE1D,MAAI;AAcF,YADiD,OAZrC,MAAM;AAAA,MAChB,GAAGK,CAAe,4BAA4BN,CAAW;AAAA,MACzD;AAAA,QACE,SAAS;AAAA,UACP,QAAQF;AAAA,UACR,MAAMC;AAAA,UACN,cAAcI;AAAA,UACd,kBAAkBC;AAAA,QAAA;AAAA,MACpB;AAAA,IACF,GAGyD,KAAA,GAClC;AAAA,EAC3B,SAASI,GAAO;AACd,UAAM,IAAI,MAAM,uCAAuCA,CAAK,EAAE;AAAA,EAChE;AACF,GChCaC,KAA0B,aAE1BC,KAAuB,CAAC;AAAA,EACnC,YAAAZ;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,SAAAS;AACF,MAQSC,EAAS;AAAA,EACd,UARwB;AAAA,IACxBH;AAAA,IACAT;AAAA,IACAF;AAAA,IACAC;AAAA,EAAA;AAAA,EAKA,SAAS,MACPF,GAAa;AAAA,IACX,YAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAC;AAAA,EAAA,CACD;AAAA,EACH,SAAAS;AAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GC/BUE,KAAiB,CAAC;AAAA,EAC7B,OAAAC;AAAA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BAAAC,EAAC,QAAI,UAAAiK,EAAA,CAAQ;AAAA,QACb,gBAAAjK,EAAC,OAAG,UAAAkK,EAAA,CAAY;AAAA,MAAA,GAClB;AAAA,MACA,gBAAAlK;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWD,EAAO;AAAA,UAClB,SAAS,MAAM,OAAO,SAAS,OAAA;AAAA,UAE9B,UAAAoK;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;AClBA,MAAMC,WAAsBC,EAAkD;AAAA,EAC5E,YAAYhK,GAA2B;AACrC,UAAMA,CAAK,GACX,KAAK,QAAQ,EAAE,UAAU,IAAO,OAAO,MAAM,WAAW,KAAA;AAAA,EAC1D;AAAA,EAEA,OAAO,yBAAyBhB,GAAkC;AAChE,WAAO,EAAE,UAAU,IAAM,OAAAA,GAAc,WAAW,KAAA;AAAA,EACpD;AAAA,EAEA,kBAAkBA,GAAciL,GAA4B;AAC1D,SAAK,SAAS,EAAE,OAAAjL,GAAO,WAAAiL,EAAA,CAAW;AAAA,EACpC;AAAA,EAEA,SAAoB;AAClB,WAAI,KAAK,MAAM,WACN,KAAK,MAAM,WAGb,KAAK,MAAM;AAAA,EACpB;AACF;ACdA,SAAwBC,GAAUlK,GAAkC;AAClE,2BACGmK,GAAA,EACC,UAAA,gBAAAxK,EAACoK,IAAA,EAAc,4BAAWL,IAAA,EAAe,UAAU1J,EAAM,SAAA,CAAU,GACjE,UAAA,gBAAAL,EAACoJ,IAAA,EAAkB,GAAG/I,EAAA,CAAO,GAC/B,GACF;AAEJ;"}
@@ -0,0 +1 @@
1
+ ._brandshopsContainer_1t4ra_1{display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;width:100%;gap:16px}._brandshopsButtonsContainer_1t4ra_19,._skeletonBrandshopsContainer_1t4ra_21{width:100%;gap:32px;align-items:center;display:flex;flex-wrap:nowrap;overflow-x:auto;padding:16px 0}._BrandshopTitle_1t4ra_41{font-size:24px;font-weight:600;color:#000}._brandshopButton_1t4ra_53,._skeletonBrandshopButton_1t4ra_55{cursor:pointer;border-radius:100%;display:flex;align-items:center;justify-content:center;flex-shrink:0}._brandshopLogo_1t4ra_73,._skeletonBrandshopLogo_1t4ra_75{width:110px;height:110px;border-radius:100%;object-fit:cover}@media (max-width: 1024px){._brandshopsButtonsContainer_1t4ra_19,._skeletonBrandshopsContainer_1t4ra_21{scrollbar-width:none;gap:12px;padding:0}._brandshopsButtonsContainer_1t4ra_19::-webkit-scrollbar{display:none}._brandshopLogo_1t4ra_73,._skeletonBrandshopLogo_1t4ra_75{width:80px;height:80px}}._skeletonBrandshopLogo_1t4ra_75,._skeletonTitle_1t4ra_131{background-color:#e2e2e2;animation:_pulse_1t4ra_1 2s cubic-bezier(.4,0,.6,1) infinite}._skeletonTitle_1t4ra_131{width:200px;height:36px;border-radius:8px}@keyframes _pulse_1t4ra_1{0%,to{opacity:1}50%{opacity:.5}}
@@ -0,0 +1 @@
1
+ export * from './components/Brandshops/index'
@@ -0,0 +1,103 @@
1
+ import { jsxs as l, jsx as s } from "react/jsx-runtime";
2
+ import { g as B, a as _, u as b, R as k } from "./ReactQueryProvider-D__k2BsQ.js";
3
+ import { I as m } from "./Image-zvdPHg5N.js";
4
+ const g = async ({
5
+ language: n,
6
+ environment: r,
7
+ adServerApiKey: e
8
+ }) => {
9
+ const [a, d] = await B(e), i = _("adServer", r);
10
+ try {
11
+ return (await (await fetch(
12
+ `${i}/api/v2/brandshop/server/active`,
13
+ {
14
+ headers: {
15
+ lang: n,
16
+ "auth-token": a,
17
+ "auth-timestamp": d
18
+ }
19
+ }
20
+ )).json()).data.brandshops;
21
+ } catch (h) {
22
+ throw new Error(`Failed to fetch brandshop list - ${h}`);
23
+ }
24
+ }, L = "brandshops", y = ({
25
+ language: n,
26
+ environment: r,
27
+ adServerApiKey: e
28
+ }) => b({
29
+ queryKey: [L, n],
30
+ queryFn: () => g({
31
+ language: n,
32
+ environment: r,
33
+ adServerApiKey: e
34
+ })
35
+ }), f = "_brandshopsContainer_1t4ra_1", C = "_brandshopsButtonsContainer_1t4ra_19", v = "_skeletonBrandshopsContainer_1t4ra_21", N = "_BrandshopTitle_1t4ra_41", T = "_brandshopButton_1t4ra_53", w = "_skeletonBrandshopButton_1t4ra_55", S = "_brandshopLogo_1t4ra_73", Q = "_skeletonBrandshopLogo_1t4ra_75", R = "_skeletonTitle_1t4ra_131", o = {
36
+ brandshopsContainer: f,
37
+ brandshopsButtonsContainer: C,
38
+ skeletonBrandshopsContainer: v,
39
+ BrandshopTitle: N,
40
+ brandshopButton: T,
41
+ skeletonBrandshopButton: w,
42
+ brandshopLogo: S,
43
+ skeletonBrandshopLogo: Q,
44
+ skeletonTitle: R
45
+ };
46
+ function E({
47
+ count: n = 3,
48
+ title: r
49
+ }) {
50
+ return /* @__PURE__ */ l("div", { className: o.brandshopsContainer, children: [
51
+ r && /* @__PURE__ */ s("div", { className: o.skeletonTitle }),
52
+ /* @__PURE__ */ s("div", { className: o.skeletonBrandshopsContainer, children: Array.from({ length: n }).map((e, a) => /* @__PURE__ */ s("div", { className: o.skeletonBrandshopButton, children: /* @__PURE__ */ s("div", { className: o.skeletonBrandshopLogo }) }, a)) })
53
+ ] });
54
+ }
55
+ function K({
56
+ adServerApiKey: n,
57
+ environment: r,
58
+ language: e,
59
+ onBrandshopClick: a,
60
+ title: d
61
+ }) {
62
+ const { data: i, error: h, isLoading: p } = y({
63
+ adServerApiKey: n,
64
+ environment: r,
65
+ language: e
66
+ });
67
+ if (h)
68
+ throw new Error(
69
+ `brandshop list failed to load} - ${h?.message || "unknown error"}`
70
+ );
71
+ if (p)
72
+ return /* @__PURE__ */ s(E, { title: d });
73
+ if (!i)
74
+ return null;
75
+ const c = [...i].sort((t, u) => t.created_at - u.created_at);
76
+ return /* @__PURE__ */ l("div", { className: o.brandshopsContainer, children: [
77
+ d && /* @__PURE__ */ s("h1", { className: o.BrandshopTitle, children: d }),
78
+ /* @__PURE__ */ s("div", { className: o.brandshopsButtonsContainer, children: c.map((t) => /* @__PURE__ */ s(
79
+ "button",
80
+ {
81
+ className: o.brandshopButton,
82
+ onClick: () => a(t.slug ?? t.id),
83
+ children: /* @__PURE__ */ s(
84
+ m,
85
+ {
86
+ className: o.brandshopLogo,
87
+ src: t.logo_url,
88
+ alt: t.name,
89
+ fetchPriority: "high"
90
+ }
91
+ )
92
+ },
93
+ t.id
94
+ )) })
95
+ ] });
96
+ }
97
+ function I(n) {
98
+ return /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s(K, { ...n }) });
99
+ }
100
+ export {
101
+ I as Brandshops
102
+ };
103
+ //# sourceMappingURL=Brandshops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Brandshops.js","sources":["../src/api/services/getBrandshopList.ts","../src/api/queries/useGetBrandshopList.ts","../src/components/Brandshops/BrandshopsSkeleton.tsx","../src/components/Brandshops/BrandshopsList.tsx","../src/components/Brandshops/Brandshops.tsx"],"sourcesContent":["import { generateAccessToken } from '@/utils/helpers/authToken';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { getBaseUrl } from '@/utils/helpers/getBaseUrl';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport {\r\n type TBrandshopsList,\r\n type TBrandshopsListSuccessResponse,\r\n} from '@/types/brandshopsList';\r\n\r\ntype TGetBrandshopsListProps = {\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n};\r\n\r\nexport const getBrandshopsList = async ({\r\n language,\r\n environment,\r\n adServerApiKey,\r\n}: TGetBrandshopsListProps): Promise<TBrandshopsList[]> => {\r\n const [token, timestamp] = await generateAccessToken(adServerApiKey);\r\n const adServerBaseUrl = getBaseUrl('adServer', environment);\r\n\r\n try {\r\n const res = await fetch(\r\n `${adServerBaseUrl}/api/v2/brandshop/server/active`,\r\n {\r\n headers: {\r\n lang: language,\r\n 'auth-token': token,\r\n 'auth-timestamp': timestamp,\r\n },\r\n },\r\n );\r\n\r\n const brandshopListResponse: TBrandshopsListSuccessResponse =\r\n await res.json();\r\n return brandshopListResponse.data.brandshops;\r\n } catch (error) {\r\n throw new Error(`Failed to fetch brandshop list - ${error}`);\r\n }\r\n};\r\n","import { useQuery } from '@tanstack/react-query';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport { getBrandshopsList } from '../services/getBrandshopList';\r\n\r\ntype TGetBrandshopsListProps = {\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n};\r\nexport const GET_BRANDSHOPS_LIST_QUERY_KEY = 'brandshops';\r\n\r\nexport const useGetBrandshopsListQuery = ({\r\n language,\r\n environment,\r\n adServerApiKey,\r\n}: TGetBrandshopsListProps) => {\r\n const brandshopsListQueryKey = [GET_BRANDSHOPS_LIST_QUERY_KEY, language];\r\n\r\n return useQuery({\r\n queryKey: brandshopsListQueryKey,\r\n queryFn: () =>\r\n getBrandshopsList({\r\n language,\r\n environment,\r\n adServerApiKey,\r\n }),\r\n });\r\n};\r\n","import styles from './BrandshopsList.module.css';\r\n\r\ntype BrandshopsSkeletonProps = {\r\n count?: number;\r\n title?: string;\r\n};\r\n\r\nexport function BrandshopsSkeleton({\r\n count = 3,\r\n title,\r\n}: Readonly<BrandshopsSkeletonProps>) {\r\n return (\r\n <div className={styles.brandshopsContainer}>\r\n {title && <div className={styles.skeletonTitle} />}\r\n <div className={styles.skeletonBrandshopsContainer}>\r\n {Array.from({ length: count }).map((_, index) => (\r\n <div key={index} className={styles.skeletonBrandshopButton}>\r\n <div className={styles.skeletonBrandshopLogo} />\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n );\r\n}\r\n","import { useGetBrandshopsListQuery } from '@/api/queries/useGetBrandshopList';\r\nimport { TBrandshopsProps } from './Brandshops';\r\nimport styles from './BrandshopsList.module.css';\r\nimport { BrandshopsSkeleton } from './BrandshopsSkeleton';\r\nimport { Image } from '../Image/Image';\r\n\r\nexport function BrandshopsList({\r\n adServerApiKey,\r\n environment,\r\n language,\r\n onBrandshopClick,\r\n title,\r\n}: Readonly<TBrandshopsProps>) {\r\n const { data, error, isLoading } = useGetBrandshopsListQuery({\r\n adServerApiKey,\r\n environment,\r\n language,\r\n });\r\n\r\n if (error) {\r\n throw new Error(\r\n `brandshop list failed to load} - ${error?.message || 'unknown error'}`,\r\n );\r\n }\r\n\r\n if (isLoading) {\r\n return <BrandshopsSkeleton title={title} />;\r\n }\r\n\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n const sortedSections = [...data].sort((a, b) => a.created_at - b.created_at);\r\n\r\n return (\r\n <div className={styles.brandshopsContainer}>\r\n {title && <h1 className={styles.BrandshopTitle}>{title}</h1>}\r\n <div className={styles.brandshopsButtonsContainer}>\r\n {sortedSections.map((item) => (\r\n <button\r\n key={item.id}\r\n className={styles.brandshopButton}\r\n onClick={() => onBrandshopClick(item.slug ?? item.id)}\r\n >\r\n <Image\r\n className={styles.brandshopLogo}\r\n src={item.logo_url}\r\n alt={item.name}\r\n fetchPriority=\"high\"\r\n />\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n );\r\n}\r\n","import { ReactQueryProvider } from '@/providers/ReactQueryProvider';\r\nimport { type TEnvironment } from '@/types/configTypes';\r\nimport { type TLanguage } from '@/types/types';\r\nimport { BrandshopsList } from './BrandshopsList';\r\n\r\nexport type TBrandshopsProps = {\r\n language: TLanguage;\r\n environment: TEnvironment;\r\n adServerApiKey: string;\r\n onBrandshopClick: (brandshopID: string) => void;\r\n title?: string;\r\n};\r\n\r\nexport default function Brandshops(props: Readonly<TBrandshopsProps>) {\r\n return (\r\n <ReactQueryProvider>\r\n <BrandshopsList {...props} />\r\n </ReactQueryProvider>\r\n );\r\n}\r\n"],"names":["getBrandshopsList","language","environment","adServerApiKey","token","timestamp","generateAccessToken","adServerBaseUrl","getBaseUrl","error","GET_BRANDSHOPS_LIST_QUERY_KEY","useGetBrandshopsListQuery","useQuery","BrandshopsSkeleton","count","title","jsxs","styles","jsx","_","index","BrandshopsList","onBrandshopClick","data","isLoading","sortedSections","a","b","item","Image","Brandshops","props","ReactQueryProvider"],"mappings":";;;AAeO,MAAMA,IAAoB,OAAO;AAAA,EACtC,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AACF,MAA2D;AACzD,QAAM,CAACC,GAAOC,CAAS,IAAI,MAAMC,EAAoBH,CAAc,GAC7DI,IAAkBC,EAAW,YAAYN,CAAW;AAE1D,MAAI;AAcF,YADE,OAZU,MAAM;AAAA,MAChB,GAAGK,CAAe;AAAA,MAClB;AAAA,QACE,SAAS;AAAA,UACP,MAAMN;AAAA,UACN,cAAcG;AAAA,UACd,kBAAkBC;AAAA,QAAA;AAAA,MACpB;AAAA,IACF,GAIU,KAAA,GACiB,KAAK;AAAA,EACpC,SAASI,GAAO;AACd,UAAM,IAAI,MAAM,oCAAoCA,CAAK,EAAE;AAAA,EAC7D;AACF,GC/BaC,IAAgC,cAEhCC,IAA4B,CAAC;AAAA,EACxC,UAAAV;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AACF,MAGSS,EAAS;AAAA,EACd,UAH6B,CAACF,GAA+BT,CAAQ;AAAA,EAIrE,SAAS,MACPD,EAAkB;AAAA,IAChB,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAC;AAAA,EAAA,CACD;AAAA,CACJ;;;;;;;;;;;ACpBI,SAASU,EAAmB;AAAA,EACjC,OAAAC,IAAQ;AAAA,EACR,OAAAC;AACF,GAAsC;AACpC,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAO,qBACpB,UAAA;AAAA,IAAAF,KAAS,gBAAAG,EAAC,OAAA,EAAI,WAAWD,EAAO,eAAe;AAAA,IAChD,gBAAAC,EAAC,OAAA,EAAI,WAAWD,EAAO,6BACpB,UAAA,MAAM,KAAK,EAAE,QAAQH,EAAA,CAAO,EAAE,IAAI,CAACK,GAAGC,MACrC,gBAAAF,EAAC,OAAA,EAAgB,WAAWD,EAAO,yBACj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AAA,CACH;AAAA,EAAA,GACF;AAEJ;AC3CA,SAAwBE,EAAWC,GAAmC;AACpE,2BACGC,GAAA,EACC,UAAA,gBAAAd,EAACG,GAAA,EAAgB,GAAGU,GAAO,GAC7B;AAEJ;"}
@@ -0,0 +1,35 @@
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { useState as c } from "react";
3
+ import { d as f } from "./ReactQueryProvider-D__k2BsQ.js";
4
+ function D({
5
+ src: o,
6
+ alt: a,
7
+ className: t,
8
+ fallback: e,
9
+ onError: s,
10
+ fetchPriority: r,
11
+ width: m,
12
+ height: g
13
+ }) {
14
+ const [i, l] = c(!1);
15
+ return /* @__PURE__ */ u(
16
+ "img",
17
+ {
18
+ src: o,
19
+ alt: a,
20
+ width: m,
21
+ height: g,
22
+ className: t,
23
+ style: i ? { backgroundColor: "#D2D2D2" } : void 0,
24
+ onError: (n) => {
25
+ n.currentTarget.src = e ?? f, l(!0), s?.();
26
+ },
27
+ fetchPriority: r ?? "auto",
28
+ loading: r === "high" ? "eager" : "lazy"
29
+ }
30
+ );
31
+ }
32
+ export {
33
+ D as I
34
+ };
35
+ //# sourceMappingURL=Image-zvdPHg5N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image-zvdPHg5N.js","sources":["../src/components/Image/Image.tsx"],"sourcesContent":["import { useState } from 'react';\r\nimport defaultFallbackImg from '@/assets/fallback-image.svg';\r\n\r\ntype FetchPriority = 'high' | 'low' | 'auto';\r\n\r\ntype ImageProps = {\r\n src: string;\r\n alt: string;\r\n className?: string;\r\n fallback?: string;\r\n onError?: () => void;\r\n fetchPriority?: FetchPriority;\r\n width?: number;\r\n height?: number;\r\n};\r\nexport function Image({\r\n src,\r\n alt,\r\n className,\r\n fallback,\r\n onError,\r\n fetchPriority,\r\n width,\r\n height,\r\n}: Readonly<ImageProps>) {\r\n const [hasError, setHasError] = useState(false);\r\n return (\r\n <img\r\n src={src}\r\n alt={alt}\r\n width={width}\r\n height={height}\r\n className={className}\r\n style={hasError ? { backgroundColor: '#D2D2D2' } : undefined}\r\n onError={(e) => {\r\n (e.currentTarget as HTMLImageElement).src =\r\n fallback ?? defaultFallbackImg;\r\n setHasError(true);\r\n onError?.();\r\n }}\r\n fetchPriority={fetchPriority ?? 'auto'}\r\n loading={fetchPriority === 'high' ? 'eager' : 'lazy'}\r\n />\r\n );\r\n}\r\n"],"names":["Image","src","alt","className","fallback","onError","fetchPriority","width","height","hasError","setHasError","useState","jsx","e","defaultFallbackImg"],"mappings":";;;AAeO,SAASA,EAAM;AAAA,EACpB,KAAAC;AAAA,EACA,KAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AACF,GAAyB;AACvB,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK;AAC9C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAX;AAAA,MACA,KAAAC;AAAA,MACA,OAAAK;AAAA,MACA,QAAAC;AAAA,MACA,WAAAL;AAAA,MACA,OAAOM,IAAW,EAAE,iBAAiB,cAAc;AAAA,MACnD,SAAS,CAACI,MAAM;AACb,QAAAA,EAAE,cAAmC,MACpCT,KAAYU,GACdJ,EAAY,EAAI,GAChBL,IAAA;AAAA,MACF;AAAA,MACA,eAAeC,KAAiB;AAAA,MAChC,SAASA,MAAkB,SAAS,UAAU;AAAA,IAAA;AAAA,EAAA;AAGpD;"}