From 2d31a2eacf3500d1c477562686f617f92da93b7b Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 29 Nov 2025 10:18:52 +0330 Subject: [PATCH] list of values --- src/pages/theme/Values.tsx | 85 +++++++++++++++++++++++++ src/pages/theme/hooks/useThemeData.ts | 8 +++ src/pages/theme/service/ThemeService.ts | 10 +++ src/pages/theme/type/Types.ts | 23 +++++++ src/router/Main.tsx | 2 + 5 files changed, 128 insertions(+) create mode 100644 src/pages/theme/Values.tsx diff --git a/src/pages/theme/Values.tsx b/src/pages/theme/Values.tsx new file mode 100644 index 0000000..2d373bd --- /dev/null +++ b/src/pages/theme/Values.tsx @@ -0,0 +1,85 @@ +import { type FC } from 'react' +import { useGetThemeValues } from './hooks/useThemeData' +import { useParams } from 'react-router-dom' +import PageTitle from '@/components/PageTitle' +import Td from '@/components/Td' +import { Eye } from 'iconsax-react' +import TrashWithConfrim from '@/components/TrashWithConfrim' +import { toast } from 'react-toastify' + +const Values: FC = () => { + const { id } = useParams() + const { data, isLoading } = useGetThemeValues(id!) + + if (isLoading) { + return
در حال بارگذاری...
+ } + + const themeInfo = data?.results?.data?.[0]?.theme + + return ( +
+ + + {themeInfo && ( +
+
+
+ عنوان تم: + {themeInfo.title} +
+
+ نوع ورودی: + {themeInfo.inputType} +
+
+
+ )} + +
+ + + + + + + { + data?.results?.data && data.results.data.length > 0 ? ( + data.results.data.map((item) => { + return ( + + + + ) + }) + ) : ( + + + + ) + } + +
+ + +
+ + +
+ + { + toast.error('این قابلیت در حال توسعه است') + }} + isLoading={false} + /> +
+
+ هیچ مقداری یافت نشد +
+
+
+ ) +} + +export default Values \ No newline at end of file diff --git a/src/pages/theme/hooks/useThemeData.ts b/src/pages/theme/hooks/useThemeData.ts index 496e16b..e32dd8f 100644 --- a/src/pages/theme/hooks/useThemeData.ts +++ b/src/pages/theme/hooks/useThemeData.ts @@ -48,3 +48,11 @@ export const useDeleteTheme = () => { }, }); }; + +export const useGetThemeValues = (id: string) => { + return useQuery({ + queryKey: ["theme-values", id], + queryFn: () => api.getThemeValues(id), + enabled: !!id, + }); +}; diff --git a/src/pages/theme/service/ThemeService.ts b/src/pages/theme/service/ThemeService.ts index d431177..b1eaa8f 100644 --- a/src/pages/theme/service/ThemeService.ts +++ b/src/pages/theme/service/ThemeService.ts @@ -3,6 +3,7 @@ import type { CreateThemeType, GetThemesResponseType, GetThemeByIdResponseType, + GetThemeValuesResponseType, } from "../type/Types"; export const getThemes = async (): Promise => { @@ -38,3 +39,12 @@ export const deleteTheme = async (id: string) => { const { data } = await axios.delete(`/admin/category/theme/${id}`); return data; }; + +export const getThemeValues = async ( + id: string +): Promise => { + const { data } = await axios.get( + `/admin/category/theme-value/${id}/values` + ); + return data; +}; diff --git a/src/pages/theme/type/Types.ts b/src/pages/theme/type/Types.ts index 69aaf7e..3ba0f53 100644 --- a/src/pages/theme/type/Types.ts +++ b/src/pages/theme/type/Types.ts @@ -28,3 +28,26 @@ export type GetThemeByIdResponseType = { data: ThemeType; }; }; + +export type CreateThemeValueType = { + theme: string; + name: string; + value: string; +}; + +export type ThemeValueType = { + _id: string; + theme: ThemeType; + name: string; + value: number; + createdAt: string; + updatedAt: string; +}; + +export type GetThemeValuesResponseType = { + status: number; + success: boolean; + results: { + data: ThemeValueType[]; + }; +}; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 944f5aa..baf33b9 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -86,6 +86,7 @@ import Cancels from '@/pages/orders/Cancels' import ThemeList from '@/pages/theme/List' import CreateTheme from '@/pages/theme/Create' import UpdateTheme from '@/pages/theme/Update' +import Values from '@/pages/theme/Values' const MainRouter: FC = () => { const { hasSubMenu } = useSharedStore() @@ -210,6 +211,7 @@ const MainRouter: FC = () => { } /> } /> } /> + } />