diff --git a/src/config/Pages.ts b/src/config/Pages.ts index d8549fa..3b93268 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -130,5 +130,8 @@ export const Pages = { warnings: { list: "/dmenu/reports/list", }, + restaurants: { + list: "/dmenu/restaurants/list", + }, }, }; diff --git a/src/langs/fa.json b/src/langs/fa.json index 8b4956b..1460603 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -77,7 +77,8 @@ "icons": "آیکون ها", "dmenu": "دی منو", "groups_icon": "گروه های آیکون", - "reports": "گزارش ها" + "reports": "گزارش ها", + "restaurants": "رستوران ها" }, "slider": { "new_slider": "اسلایدر جدید", @@ -869,5 +870,17 @@ "date": "تاریخ", "detail": "جزییات" }, + "restaurant": { + "list_restaurant": "لیست رستورانها", + "name": "نام", + "phone": "شماره تماس", + "address": "آدرس", + "domain": "دامنه", + "status": "وضعیت", + "plan": "پلن", + "created_at": "تاریخ ایجاد", + "active": "فعال", + "inactive": "غیرفعال" + }, "cancel": "لغو" } diff --git a/src/pages/dmenu/hooks/useIconData.ts b/src/pages/dmenu/hooks/useIconData.ts index 4027947..1815ff7 100644 --- a/src/pages/dmenu/hooks/useIconData.ts +++ b/src/pages/dmenu/hooks/useIconData.ts @@ -46,3 +46,10 @@ export const useGetReports = () => { queryFn: api.getReports, }); }; + +export const useGetRestaurants = () => { + return useQuery({ + queryKey: ["restaurants"], + queryFn: api.getRestaurants, + }); +}; diff --git a/src/pages/dmenu/icon/GroupList.tsx b/src/pages/dmenu/icon/GroupList.tsx index 30af8dc..9d0c569 100644 --- a/src/pages/dmenu/icon/GroupList.tsx +++ b/src/pages/dmenu/icon/GroupList.tsx @@ -10,7 +10,7 @@ import PageLoading from '../../../components/PageLoading' import TrashWithConfrim from '../../../components/TrashWithConfrim' import { toast } from 'react-toastify' import { ErrorType } from '../../../helpers/types' -import { GroupIconType } from './types/Types' +import { GroupIconType } from '../types/Types' const GroupIconList: FC = () => { diff --git a/src/pages/dmenu/icon/List.tsx b/src/pages/dmenu/icon/List.tsx index 6cf147c..d36e029 100644 --- a/src/pages/dmenu/icon/List.tsx +++ b/src/pages/dmenu/icon/List.tsx @@ -10,7 +10,7 @@ import PageLoading from '../../../components/PageLoading' import TrashWithConfrim from '../../../components/TrashWithConfrim' import { toast } from 'react-toastify' import { ErrorType } from '../../../helpers/types' -import { IconType } from './types/Types' +import { IconType } from '../types/Types' import moment from 'moment-jalaali' const IconsList: FC = () => { diff --git a/src/pages/dmenu/icon/components/CreateGroupIcon.tsx b/src/pages/dmenu/icon/components/CreateGroupIcon.tsx index 4dc9974..843c739 100644 --- a/src/pages/dmenu/icon/components/CreateGroupIcon.tsx +++ b/src/pages/dmenu/icon/components/CreateGroupIcon.tsx @@ -8,7 +8,7 @@ import * as Yup from 'yup' import { toast } from 'react-toastify' import { TickCircle } from 'iconsax-react' import { useCreateGroupIcon } from '../../hooks/useIconData' -import { CreateGroupIconType } from '../types/Types' +import { CreateGroupIconType } from '../../types/Types' import { ErrorType } from '../../../../helpers/types' interface CreateGroupIconProps { diff --git a/src/pages/dmenu/icon/components/CreateIcon.tsx b/src/pages/dmenu/icon/components/CreateIcon.tsx index 2fb9a60..0010aa8 100644 --- a/src/pages/dmenu/icon/components/CreateIcon.tsx +++ b/src/pages/dmenu/icon/components/CreateIcon.tsx @@ -10,7 +10,7 @@ import { toast } from 'react-toastify' import { TickCircle } from 'iconsax-react' import { useCreateIcon, useGetGroupIcons } from '../../hooks/useIconData' import { useSingleUpload } from '../../../service/hooks/useServiceData' -import { CreateIconType, GroupIconType } from '../types/Types' +import { CreateIconType, GroupIconType } from '../../types/Types' import { ErrorType } from '../../../../helpers/types' interface CreateIconProps { diff --git a/src/pages/dmenu/restaurant/List.tsx b/src/pages/dmenu/restaurant/List.tsx new file mode 100644 index 0000000..cb674d6 --- /dev/null +++ b/src/pages/dmenu/restaurant/List.tsx @@ -0,0 +1,109 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' +import { useGetRestaurants } from '../hooks/useIconData' +import PageLoading from '../../../components/PageLoading' +import Td from '../../../components/Td' +import { RestaurantType } from '../types/Types' +import moment from 'moment-jalaali' +import { Copy } from 'iconsax-react' +import { toast } from 'react-toastify' + +const RestaurantsList: FC = () => { + + const { t } = useTranslation('global') + const { data: restaurants, isLoading } = useGetRestaurants() + + const restaurantsList = (restaurants as { data?: RestaurantType[] })?.data || [] + + const handleCopyAddress = async (address: string | null) => { + if (!address) return + + try { + await navigator.clipboard.writeText(address) + toast.success('کپی شد') + } catch { + toast.error('خطا در کپی کردن') + } + } + + return ( +
| + | + | + | + | + | + | + | + |
| + | + |
+
+ {item.address || '-'}
+ {item.address && (
+
+ |
+ + | + |
+
+ {item.isActive ? t('restaurant.active') : t('restaurant.inactive')}
+
+ |
+
+
+ {moment(item.createdAt).format('jYYYY-jMM-jDD HH:mm')}
+
+ |
+ + |