diff --git a/src/app/settings/financial/page.tsx b/src/app/settings/financial/page.tsx index 0b266a7..9d778a0 100644 --- a/src/app/settings/financial/page.tsx +++ b/src/app/settings/financial/page.tsx @@ -103,33 +103,33 @@ export default function Financial() { key={item._id} className="p-5 border rounded-3xl border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 shadow-sm hover:shadow-md transition-all duration-200" > -
-
+
+
{getTransactionType(item.type)} {item.project_title && ( - + ({item.project_title}) )}
-
+
{formatDate(item.createdAt)}
-
-
+
+
{t("settings.financial.amountPaid")}:{" "} {Number(item.amount).toLocaleString(amountLocale)}{" "} {t("settings.toman")}
-
+
{t("settings.status")}: diff --git a/src/app/shops/discover/page.tsx b/src/app/shops/discover/page.tsx index a710021..b1120eb 100644 --- a/src/app/shops/discover/page.tsx +++ b/src/app/shops/discover/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import Container from "@/components/elements/Container"; import LocalePageShell from "@/components/i18n/LocalePageShell"; import PageTitle from "@/components/settings/PageTitle"; @@ -9,18 +9,46 @@ import TabNavigation from "@/components/TabNavigation"; import ShopProductGrid from "@/components/shops/ShopProductGrid"; import BoldIcon from "@/components/ui/BoldIcon"; import { cn } from "@/lib/utils"; +import useAxios from "@/hooks/useAxios"; import useInfiniteScroll from "@/hooks/useInfiniteScroll"; import { IShopProductListing } from "@/types/types"; import { useTranslation } from "react-i18next"; +const ALL_ID = "__all__"; +const PINTEREST_ID = "__pinterest__"; + +type ShopCategory = { category: string; sub_categories?: unknown[] }; + export default function ShopDiscoverPage() { const { t } = useTranslation("common"); - const [pinterestOnly, setPinterestOnly] = useState(false); + const { request } = useAxios(); + const [activeFilter, setActiveFilter] = useState(ALL_ID); + const [categories, setCategories] = useState([]); + + useEffect(() => { + request<{ categories?: ShopCategory[] }>("GET", "/shop-categories", null, { + noToast: true, + }) + .then((res) => + setCategories( + (res?.categories ?? []).map((c) => c.category).filter(Boolean) + ) + ) + .catch(() => setCategories([])); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const chips = useMemo(() => [ALL_ID, PINTEREST_ID, ...categories], [categories]); const { data, isLoading } = useInfiniteScroll({ endpoint: "/shop-products/discover", - queryKey: ["shop-products-discover", String(pinterestOnly)], - params: pinterestOnly ? { pinterest: "true" } : {}, + queryKey: ["shop-products-discover", activeFilter], + params: + activeFilter === PINTEREST_ID + ? { pinterest: "true" } + : activeFilter === ALL_ID + ? {} + : { category: activeFilter }, }); const listings: IShopProductListing[] = @@ -33,32 +61,37 @@ export default function ShopDiscoverPage() { {t("shops.discoverTitle")} -
- - +
+ {chips.map((c) => { + const active = activeFilter === c; + const isPinterest = c === PINTEREST_ID; + const label = + c === ALL_ID + ? t("shops.allFilter") + : isPinterest + ? t("shops.pinterestFilter") + : c; + return ( + + ); + })}