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 ( +
+
+
+ {t('restaurant.list_restaurant')} +
+
+ + { + isLoading ? + + : +
+ + + + + + + { + restaurantsList.map((item: RestaurantType) => { + return ( + + + + + + ) + }) + } + +
+ + + + + + + +
+ + +
+ {item.address || '-'} + {item.address && ( + handleCopyAddress(item.address)} + /> + )} +
+
+ + +
+ {item.isActive ? t('restaurant.active') : t('restaurant.inactive')} +
+
+
+ {moment(item.createdAt).format('jYYYY-jMM-jDD HH:mm')} +
+
+
+ + {restaurantsList.length === 0 && ( +
+
هیچ رستورانی یافت نشد
+
+ )} +
+ } +
+ ) +} + +export default RestaurantsList \ No newline at end of file diff --git a/src/pages/dmenu/service/IconService.ts b/src/pages/dmenu/service/IconService.ts index 0f310f2..4958413 100644 --- a/src/pages/dmenu/service/IconService.ts +++ b/src/pages/dmenu/service/IconService.ts @@ -5,6 +5,7 @@ import { GroupIconsResponse, IconsResponse, ReportsResponse, + RestaurantsResponse, } from "../types/Types"; export const getIcons = async (): Promise => { @@ -41,3 +42,8 @@ export const getReports = async (): Promise => { const { data } = await axios.get("/admin/dmenu/contacts"); return data; }; + +export const getRestaurants = async (): Promise => { + const { data } = await axios.get("/admin/dmenu/restaurants"); + return data; +}; diff --git a/src/pages/dmenu/types/Types.ts b/src/pages/dmenu/types/Types.ts index 64f80f4..0c4dd30 100644 --- a/src/pages/dmenu/types/Types.ts +++ b/src/pages/dmenu/types/Types.ts @@ -1,4 +1,4 @@ -import { IResponse } from "../../../../types/response.types"; +import { IResponse } from "../../../types/response.types"; export type CreateGroupIconType = { name: string; @@ -58,3 +58,51 @@ export type ReportItem = { export interface ReportsResponse extends IResponse { statusCode: number; } + +export type ScoreType = { + scoreAmount: string; + scoreCredit: string; + birthdayScore: string; + purchaseScore: string; + referrerScore: string; + registerScore: string; + purchaseAmount: string; + marriageDateScore: string; +}; + +export type RestaurantType = { + id: string; + createdAt: string; + updatedAt: string; + deletedAt: string | null; + name: string; + slug: string; + logo: string; + address: string | null; + menuColor: string | null; + latitude: number | null; + longitude: number | null; + serviceArea: string | null; + isActive: boolean; + establishedYear: number | null; + phone: string; + instagram: string | null; + telegram: string | null; + whatsapp: string | null; + description: string | null; + seoTitle: string | null; + seoDescription: string | null; + tagNames: string | null; + images: string | null; + vat: number; + domain: string; + score: ScoreType; + plan: string; + subscriptionId: string; + subscriptionEndDate: string; + subscriptionStartDate: string; +}; + +export interface RestaurantsResponse extends IResponse { + statusCode: number; +} diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 837bb31..5e29f02 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -80,6 +80,7 @@ import PermissionLogs from '../pages/accessLogs/PermissionLogs' import IconsList from '../pages/dmenu/icon/List' import GroupIconList from '../pages/dmenu/icon/GroupList' import WarningsList from '../pages/dmenu/report/List.tsx' +import RestaurantsList from '../pages/dmenu/restaurant/List.tsx' // import WarningsList from '../pages/dmenu/reports/List' // TODO: Create this component const MainRouter: FC = () => { @@ -173,6 +174,7 @@ const MainRouter: FC = () => { } /> } /> } /> + } /> diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index 9afb75d..3ec5a7f 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -2,7 +2,7 @@ import { FC, useEffect } from 'react' import LogoImage from '../assets/images/logo.svg' import LogoSmall from '../assets/images/logo-small.svg' import { useTranslation } from 'react-i18next' -import { Card, Code, CodeCircle, DocumentLike, DocumentText, Element3, Gallery, Headphone, Home2, Logout, Message, Messages3, Money3, NotificationStatus, People, Profile, Receipt21, Setting2, SmsTracking, Teacher, TicketDiscount, UserSquare, Activity, Icon, Category, Warning2 } from 'iconsax-react' +import { Card, Code, CodeCircle, DocumentLike, DocumentText, Element3, Gallery, Headphone, Home2, Logout, Message, Messages3, Money3, NotificationStatus, People, Profile, Receipt21, Setting2, SmsTracking, Teacher, TicketDiscount, UserSquare, Activity, Icon, Category, Warning2, Building } from 'iconsax-react' import SideBarItem from './SideBarItem' import { useLocation } from 'react-router-dom' import { Pages } from '../config/Pages' @@ -334,6 +334,16 @@ const SideBar: FC = () => { activeName='dmenu' /> + +
+ } + title={t('sidebar.restaurants')} + isActive={isActive('restaurants')} + link={Pages.dmenu.restaurants.list} + activeName='dmenu' + /> +
}