From 05a167aedb7a296da42fcc2bcd0567df88451b61 Mon Sep 17 00:00:00 2001
From: Syed Talha Ejaz
Date: Tue, 18 Feb 2025 14:27:36 +0500
Subject: [PATCH 1/3] handled all the changes in the enatega admin
---
.../lib/api/graphql/queries/orders/index.ts | 81 +++--
.../restaurant/layout-restaurant.context.tsx | 28 +-
.../restaurant/add-on/add-form/index.tsx | 43 ++-
.../restaurant/category/add-form/index.tsx | 5 +
.../food/form/add-form/food.index.tsx | 5 +-
.../food/form/add-form/variations.tsx | 26 +-
.../view/header/table-header/index.tsx | 45 ++-
.../super-admin/dispatch/view/main/index.tsx | 90 +++--
.../food-management/category/index.tsx | 1 +
.../table/columns/dispatch-columns.tsx | 275 ++++++++------
.../lib/ui/useable-components/table/index.tsx | 48 ++-
.../upload/upload-image.tsx | 334 ++++--------------
.../lib/utils/constants/url.ts | 4 +-
.../lib/utils/interfaces/add-on.interface.ts | 6 +
.../utils/interfaces/category.interface.ts | 1 +
.../utils/interfaces/dispatch.interface.ts | 7 +-
.../lib/utils/interfaces/layout.interface.ts | 5 +
.../lib/utils/interfaces/table.interface.ts | 10 +-
18 files changed, 527 insertions(+), 487 deletions(-)
diff --git a/enatega-multivendor-admin/lib/api/graphql/queries/orders/index.ts b/enatega-multivendor-admin/lib/api/graphql/queries/orders/index.ts
index 33e6660b..2cf0beb9 100644
--- a/enatega-multivendor-admin/lib/api/graphql/queries/orders/index.ts
+++ b/enatega-multivendor-admin/lib/api/graphql/queries/orders/index.ts
@@ -1,41 +1,58 @@
import { gql } from '@apollo/client';
export const GET_ACTIVE_ORDERS = gql`
- query GetActiveOrders($restaurantId: ID) {
- getActiveOrders(restaurantId: $restaurantId) {
- _id
- zone {
- _id
- }
- orderId
- restaurant {
+ query GetActiveOrders(
+ $restaurantId: ID
+ $page: Int
+ $rowsPerPage: Int
+ $actions: [String]
+ $search: String
+ ) {
+ getActiveOrders(
+ restaurantId: $restaurantId
+ page: $page
+ rowsPerPage: $rowsPerPage
+ actions: $actions
+ search: $search
+ ) {
+ totalCount
+ orders {
_id
- name
- image
- address
- location {
- coordinates
+ zone {
+ _id
}
- }
- deliveryAddress {
- location {
- coordinates
+ orderId
+ restaurant {
+ _id
+ name
+ image
+ address
+ location {
+ coordinates
+ }
+ }
+ deliveryAddress {
+ location {
+ coordinates
+ }
+ deliveryAddress
+ }
+ user {
+ name
+ phone
+ }
+ paymentMethod
+ orderStatus
+ isPickedUp
+ status
+ isActive
+ createdAt
+ rider {
+ _id
+ name
+ username
+ available
}
- deliveryAddress
- }
-
- paymentMethod
- orderStatus
- isPickedUp
- status
- isActive
- createdAt
- rider {
- _id
- name
- username
- available
- assigned
}
}
}
diff --git a/enatega-multivendor-admin/lib/context/restaurant/layout-restaurant.context.tsx b/enatega-multivendor-admin/lib/context/restaurant/layout-restaurant.context.tsx
index 6d36e609..33a06d4b 100644
--- a/enatega-multivendor-admin/lib/context/restaurant/layout-restaurant.context.tsx
+++ b/enatega-multivendor-admin/lib/context/restaurant/layout-restaurant.context.tsx
@@ -6,11 +6,14 @@ import { createContext, useState } from 'react';
// Interface
import {
ICategory,
+ IOptions,
IProvider,
ISubCategory,
RestaurantLayoutContextData,
RestaurantLayoutContextProps,
} from '@/lib/utils/interfaces';
+
+// Utils
import { SELECTED_RESTAURANT } from '../../utils/constants';
import { onUseLocalStorage } from '../../utils/methods';
@@ -21,10 +24,22 @@ export const RestaurantLayoutContext =
);
export const RestaurantLayoutProvider = ({ children }: IProvider) => {
+ // States
+ const [isAddOptionsVisible, setIsAddOptionsVisible] = useState(false);
+ const [option, setOption] = useState(null);
const [restaurantLayoutContextData, setRestaurantLayoutContextData] =
useState({
restaurantId: onUseLocalStorage('get', SELECTED_RESTAURANT),
} as RestaurantLayoutContextData);
+ const [isAddSubCategoriesVisible, setIsAddSubCategoriesVisible] = useState({
+ bool: false,
+ parentCategoryId: '',
+ });
+ const [category, setCategory] = useState(null);
+ const [isSubCategoryModalOpen, setIsSubCategoryModalOpen] =
+ useState(false);
+ const [subCategories, setSubCategories] = useState([]);
+ const [subCategoryParentId, setSubCategoryParentId] = useState('');
// Handlers
const onSetRestaurantLayoutContextData = (
@@ -35,15 +50,6 @@ export const RestaurantLayoutProvider = ({ children }: IProvider) => {
...data,
}));
};
- const [isAddSubCategoriesVisible, setIsAddSubCategoriesVisible] = useState({
- bool: false,
- parentCategoryId: '',
- });
- const [category, setCategory] = useState(null);
- const [isSubCategoryModalOpen, setIsSubCategoryModalOpen] =
- useState(false);
- const [subCategories, setSubCategories] = useState([]);
- const [subCategoryParentId, setSubCategoryParentId] = useState('');
const value: RestaurantLayoutContextProps = {
restaurantLayoutContextData,
onSetRestaurantLayoutContextData,
@@ -57,6 +63,10 @@ export const RestaurantLayoutProvider = ({ children }: IProvider) => {
setIsSubCategoryModalOpen,
subCategoryParentId,
setSubCategoryParentId,
+ isAddOptionsVisible,
+ setIsAddOptionsVisible,
+ option,
+ setOption
};
return (
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/add-on/add-form/index.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/add-on/add-form/index.tsx
index 491a5b1f..b8313f3d 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/add-on/add-form/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/add-on/add-form/index.tsx
@@ -8,8 +8,16 @@ import { Sidebar } from 'primereact/sidebar';
import { IAddonForm } from '@/lib/utils/interfaces/forms';
// Components
+import CustomButton from '@/lib/ui/useable-components/button';
+import CustomMultiSelectComponent from '@/lib/ui/useable-components/custom-multi-select';
+import CustomTextAreaField from '@/lib/ui/useable-components/custom-text-area-field';
+import CustomTextField from '@/lib/ui/useable-components/input-field';
+import CustomNumberField from '@/lib/ui/useable-components/number-input-field';
+import TextIconClickable from '@/lib/ui/useable-components/text-icon-clickable';
+import OptionsAddForm from '@/lib/ui/screen-components/protected/restaurant/options/add-form';
// Utilities and Constants
+import { AddonsErrors, OptionErrors } from '@/lib/utils/constants';
//Toast
import useToast from '@/lib/hooks/useToast';
@@ -23,13 +31,6 @@ import {
} from '@/lib/api/graphql';
import { RestaurantLayoutContext } from '@/lib/context/restaurant/layout-restaurant.context';
import { useQueryGQL } from '@/lib/hooks/useQueryQL';
-import CustomButton from '@/lib/ui/useable-components/button';
-import CustomMultiSelectComponent from '@/lib/ui/useable-components/custom-multi-select';
-import CustomTextAreaField from '@/lib/ui/useable-components/custom-text-area-field';
-import CustomTextField from '@/lib/ui/useable-components/input-field';
-import CustomNumberField from '@/lib/ui/useable-components/number-input-field';
-import TextIconClickable from '@/lib/ui/useable-components/text-icon-clickable';
-import { AddonsErrors, OptionErrors } from '@/lib/utils/constants';
import {
IAddonAddFormComponentProps,
IDropdownSelectItem,
@@ -72,13 +73,17 @@ export default function AddonAddForm({
addon,
position = 'right',
isAddAddonVisible,
+
}: IAddonAddFormComponentProps) {
// Hooks
const t = useTranslations();
const { showToast } = useToast();
// Context
- const { restaurantLayoutContextData } = useContext(RestaurantLayoutContext);
+ const { restaurantLayoutContextData , setIsAddOptionsVisible,
+ option,
+ setOption,
+ isAddOptionsVisible,} = useContext(RestaurantLayoutContext);
const restaurantId = restaurantLayoutContextData?.restaurantId || '';
const [initialValues, setInitialValues] = useState({
@@ -218,14 +223,14 @@ export default function AddonAddForm({
visible={isAddAddonVisible}
position={position}
onHide={onHide}
- className="w-full sm:w-[450px]"
+ className="w-full sm:w-[500px]"
>
- {addon ? t('Edit') : t('Add')} {t('Option')}
+ {addon ? t('Edit') : t('Add')} {t('Addons')}
@@ -274,7 +279,7 @@ export default function AddonAddForm({
)}
+
{
+ setIsAddOptionsVisible(false);
+ setOption(null);
+ }}
+ isAddOptionsVisible={isAddOptionsVisible}
+ />
);
}
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/category/add-form/index.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/category/add-form/index.tsx
index 92b38606..fb7402e1 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/category/add-form/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/category/add-form/index.tsx
@@ -55,6 +55,7 @@ export default function CategoryAddForm({
category,
position = 'right',
isAddCategoryVisible,
+ refetchCategories
}: ICategoryAddFormComponentProps) {
// Hooks
const t = useTranslations();
@@ -136,6 +137,10 @@ export default function CategoryAddForm({
message: `${t('Category has been')} ${category ? t('edited') : t('added')} ${t('successfully')}.`,
duration: 3000,
});
+ // Safely call refetchCategories if it exists
+ if (typeof refetchCategories === 'function') {
+ refetchCategories();
+ }
onHide();
},
onError: (error) => {
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/food.index.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/food.index.tsx
index afea6033..91ca3773 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/food.index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/food.index.tsx
@@ -107,7 +107,7 @@ export default function FoodDetails({
GET_CATEGORY_BY_RESTAURANT_ID,
{ id: restaurantId ?? '' },
{
- fetchPolicy: 'cache-and-network',
+ fetchPolicy: 'no-cache',
enabled: !!restaurantId,
}
) as IQueryResult;
@@ -136,7 +136,7 @@ export default function FoodDetails({
data?.restaurant?.categories.map((category: ICategory) => {
return { label: category.title, code: category._id };
}),
- []
+ [data?.restaurant?.categories]
);
const subCategoriesDropdown = useMemo(
@@ -425,6 +425,7 @@ export default function FoodDetails({
}}
isAddCategoryVisible={isAddCategoryVisible}
subCategories={subCategories}
+ refetchCategories = {refetchCategories}
/>
);
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/variations.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/variations.tsx
index 6688b187..9220e6b5 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/variations.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/food/form/add-form/variations.tsx
@@ -82,6 +82,8 @@ export default function VariationAddForm({
useContext(FoodsContext);
const {
restaurantLayoutContextData: { restaurantId },
+ option,
+ setOption
} = useContext(RestaurantLayoutContext);
// Constants
@@ -471,15 +473,21 @@ export default function VariationAddForm({
-
- {
- setIsAddAddonVisible(false);
- setAddon(null);
- }}
- isAddAddonVisible={isAddAddonVisible}
- />
+
+
{
+ setIsAddAddonVisible(false);
+ setAddon(null);
+ }}
+ isAddAddonVisible={isAddAddonVisible}
+ />
+
);
}
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/header/table-header/index.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/header/table-header/index.tsx
index a7b9f37b..e5f6ba70 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/header/table-header/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/header/table-header/index.tsx
@@ -13,13 +13,13 @@ import { useTranslations } from 'next-intl';
// Prime react
import { Checkbox } from 'primereact/checkbox';
import { OverlayPanel } from 'primereact/overlaypanel';
-import { useRef, useState } from 'react';
+import { ChangeEvent, useCallback, useRef, useState } from 'react';
export default function DispatchTableHeader({
- globalFilterValue,
- onGlobalFilterChange,
selectedActions,
setSelectedActions,
+ search,
+ setSearch,
}: IDispatchTableHeaderProps) {
// Hooks
const t = useTranslations();
@@ -30,7 +30,7 @@ export default function DispatchTableHeader({
// States
const [searchValue, setSearchValue] = useState('');
- // Handle checkbox toggle
+ // Checkbox toggle
const toggleAction = (action: string) => {
const updatedActions = selectedActions.includes(action)
? selectedActions.filter((a) => a !== action)
@@ -38,6 +38,7 @@ export default function DispatchTableHeader({
setSelectedActions(updatedActions);
};
+ // Actions
const menuItems = [
{
label: t('Pending'),
@@ -51,8 +52,26 @@ export default function DispatchTableHeader({
label: t('Accepted'),
value: 'ACCEPTED',
},
+ {
+ label: t('Picked'),
+ value: 'PICKED',
+ },
+ {
+ label: t('Delivered'),
+ value: 'DELIVERED',
+ },
];
+ // Debounce Search Handler
+ const debounceSearch = useCallback((delay: number, val: string) => {
+ let timer: ReturnType;
+ setSearch(val);
+ return () => {
+ clearTimeout(timer);
+ timer = setTimeout(() => setSearch(val), delay);
+ };
+ }, []);
+
return (
@@ -62,9 +81,11 @@ export default function DispatchTableHeader({
name="vendorFilter"
maxLength={35}
showLabel={false}
- value={globalFilterValue}
- onChange={onGlobalFilterChange}
- placeholder={t("Keyword Search")}
+ value={search}
+ onChange={(e: ChangeEvent) =>
+ debounceSearch(300, e.target.value)
+ }
+ placeholder={t('Keyword Search')}
/>
@@ -74,7 +95,7 @@ export default function DispatchTableHeader({
setSearchValue(e.target.value)}
- placeholder={t("Search")}
+ placeholder={t('Search')}
className="h-8 w-full"
type="text"
name="search"
@@ -103,7 +124,7 @@ export default function DispatchTableHeader({
htmlFor={`action-${item.value}`}
className="ml-1 text-sm"
>
- {t(item.label)}
+ {item.label}
@@ -113,7 +134,7 @@ export default function DispatchTableHeader({
className="mt-3 text-center text-sm cursor-pointer"
onClick={() => setSelectedActions([])}
>
- {t("Clear filters")}
+ {t('Clear filters')}
@@ -122,11 +143,11 @@ export default function DispatchTableHeader({
className="w-20 rounded border border-dotted border-[#E4E4E7] text-black"
icon={faAdd}
iconStyles={{ color: 'black' }}
- title={selectedActions.length > 0 ? t('Filter') : t('Action')}
+ title={selectedActions.length > 0 ? t('Filter') : t('Actions')}
onClick={(e) => overlayPanelRef.current?.toggle(e)}
/>
);
-}
\ No newline at end of file
+}
diff --git a/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/main/index.tsx b/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/main/index.tsx
index 409465a0..014cf066 100644
--- a/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/main/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/dispatch/view/main/index.tsx
@@ -6,65 +6,92 @@ import Table from '@/lib/ui/useable-components/table';
import DispatchTableHeader from '../header/table-header';
//Inrfaces
-import { ILazyQueryResult } from '@/lib/utils/interfaces';
import {
IActiveOrders,
IGetActiveOrders,
} from '@/lib/utils/interfaces/dispatch.interface';
-//Prime react
-import { FilterMatchMode } from 'primereact/api';
-
//Hooks
-import { useLazyQueryQL } from '@/lib/hooks/useLazyQueryQL';
import { useEffect, useState } from 'react';
// Constants
import { generateDummyDispatchOrders } from '@/lib/utils/dummy';
import { DISPATCH_TABLE_COLUMNS } from '@/lib/ui/useable-components/table/columns/dispatch-columns';
+import { useLazyQuery } from '@apollo/client';
export default function DispatchMain() {
// States
const [selectedData, setSelectedData] = useState([]);
const [globalFilterValue, setGlobalFilterValue] = useState('');
const [selectedActions, setSelectedActions] = useState([]);
- const [isLoading, setIsLoading] = useState(true);
+ const [isLoading, setIsLoading] = useState(true);
+ const [page, setPage] = useState(1);
+ const [rowsPerPage, setRowsPerPage] = useState(10);
+ const [search, setSearch] = useState('');
// Filters
- const filters = {
- global: { value: globalFilterValue, matchMode: FilterMatchMode.CONTAINS },
- orderStatus: {
- value: selectedActions.length > 0 ? selectedActions : null,
- matchMode: FilterMatchMode.IN,
- },
- };
+ // const filters = {
+ // global: { value: globalFilterValue, matchMode: FilterMatchMode.CONTAINS },
+ // orderStatus: {
+ // value: selectedActions.length > 0 ? selectedActions : null,
+ // matchMode: FilterMatchMode.IN,
+ // },
+ // };
// Queries
- const { data: active_orders_data, fetch: fetchActiveOrders } = useLazyQueryQL(
- GET_ACTIVE_ORDERS,
+ const [
+ fetchActiveOrders,
+ { data: active_orders_data, loading: active_orders_loading },
+ ] = useLazyQuery<
+ IGetActiveOrders | undefined,
{
- fetchPolicy: 'network-only',
- onCompleted: () => {
- setIsLoading(false);
- },
+ page: number;
+ rowsPerPage: number;
+ search: string;
+ actions: string[];
+ restaurantId?: string;
}
- ) as ILazyQueryResult;
+ >(GET_ACTIVE_ORDERS, {
+ variables: {
+ restaurantId: '',
+ page: page,
+ rowsPerPage: rowsPerPage,
+ search: search,
+ actions: selectedActions,
+ },
+ onCompleted: () => {
+ setIsLoading(false);
+ },
+ pollInterval: 3000,
+ });
+ // fetchPolicy: 'network-only',
+ // onCompleted: () => {
+ // setIsLoading(false);
+ // },
// UseEffects
useEffect(() => {
- fetchActiveOrders();
+ fetchActiveOrders({
+ variables: {
+ page,
+ rowsPerPage,
+ search,
+ actions: selectedActions,
+ restaurantId: '',
+ },
+ });
setIsLoading(true);
- }, []);
+ }, [rowsPerPage, page, selectedActions, search]);
return (
setSelectedData(e as IActiveOrders[])}
header={
@@ -73,10 +100,19 @@ export default function DispatchMain() {
onGlobalFilterChange={(e) => setGlobalFilterValue(e.target.value)}
selectedActions={selectedActions}
setSelectedActions={setSelectedActions}
+ search={search}
+ setSearch={setSearch}
/>
}
- filters={filters}
+ rowsPerPage={rowsPerPage}
+ totalRecords={active_orders_data?.getActiveOrders.totalCount}
+ onPageChange={(page, rowNumber) => {
+ setPage(page);
+ setRowsPerPage(rowNumber);
+ }}
+ currentPage={page}
+ // filters={filters}
/>
);
-}
\ No newline at end of file
+}
diff --git a/enatega-multivendor-admin/lib/ui/screens/admin/restaurant/food-management/category/index.tsx b/enatega-multivendor-admin/lib/ui/screens/admin/restaurant/food-management/category/index.tsx
index d720a840..f2133dd9 100644
--- a/enatega-multivendor-admin/lib/ui/screens/admin/restaurant/food-management/category/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/screens/admin/restaurant/food-management/category/index.tsx
@@ -57,6 +57,7 @@ export default function CategoryScreen() {
setSubCategories([]);
}}
isAddCategoryVisible={isAddCategoryVisible}
+
/>
);
diff --git a/enatega-multivendor-admin/lib/ui/useable-components/table/columns/dispatch-columns.tsx b/enatega-multivendor-admin/lib/ui/useable-components/table/columns/dispatch-columns.tsx
index a7f1cc1a..cd9060af 100644
--- a/enatega-multivendor-admin/lib/ui/useable-components/table/columns/dispatch-columns.tsx
+++ b/enatega-multivendor-admin/lib/ui/useable-components/table/columns/dispatch-columns.tsx
@@ -1,10 +1,11 @@
-'use client';
// Interfaces
-import { IActiveOrders } from '@/lib/utils/interfaces/dispatch.interface';
+import {
+ IActiveOrders,
+ IAssignRider,
+} from '@/lib/utils/interfaces/dispatch.interface';
import {
IDropdownSelectItem,
IQueryResult,
- IRiderDropDownSelectItem,
IRidersDataResponse,
} from '@/lib/utils/interfaces';
@@ -33,40 +34,6 @@ import classes from '@/lib/ui/screen-components/protected/super-admin/dispatch/v
import { useQueryGQL } from '@/lib/hooks/useQueryQL';
import { useTranslations } from 'next-intl';
-// Status options
-const actionStatusOptions = [
- {
- label: 'Pending',
- code: 'PENDING',
- body: () => ,
- },
- {
- label: 'Assigned',
- code: 'ASSIGNED',
- body: () => ,
- },
- {
- label: 'Accepted',
- code: 'ACCEPTED',
- body: () => ,
- },
- {
- label: 'Delivered',
- code: 'DELIVERED',
- body: () => ,
- },
- {
- label: 'Picked',
- code: 'PICKED',
- body: () => ,
- },
- {
- label: 'Rejected',
- code: 'CANCELLED',
- body: () => ,
- },
-];
-
// Status templates
const valueTemplate = (option: IDropdownSelectItem) => (
@@ -105,21 +72,50 @@ function severityChecker(status: string | undefined) {
}
}
-export const DISPATCH_TABLE_COLUMNS = (
- fetchActiveOrders: (variables?: undefined) => void
-) => {
+export const DISPATCH_TABLE_COLUMNS = () => {
// Hooks
const t = useTranslations();
-
- // Toast
const { showToast } = useContext(ToastContext);
+ // Status options
+ const actionStatusOptions = [
+ {
+ label: t('Pending'),
+ code: 'PENDING',
+ body: () =>
,
+ },
+ {
+ label: t('Assigned'),
+ code: 'ASSIGNED',
+ body: () =>
,
+ },
+ {
+ label: t('Accepted'),
+ code: 'ACCEPTED',
+ body: () =>
,
+ },
+ {
+ label: t('Delivered'),
+ code: 'DELIVERED',
+ body: () =>
,
+ },
+ {
+ label: t('Picked'),
+ code: 'PICKED',
+ body: () =>
,
+ },
+ {
+ label: t('Rejected'),
+ code: 'CANCELLED',
+ body: () =>
,
+ },
+ ];
+
// States
- const [riderOptions, setRiderOptions] = useState
(
- []
- );
+ const [riderOptions, setRiderOptions] = useState([]);
const [isRiderLoading, setIsRiderLoading] = useState({
_id: '',
+ orderId: '',
bool: false,
});
const [isStatusUpdating, setIsStatusUpdating] = useState({
@@ -128,22 +124,19 @@ export const DISPATCH_TABLE_COLUMNS = (
});
// Query
- const { data: ridersData, loading: ridersLoading } = useQueryGQL(
- GET_RIDERS,
- {}
- ) as IQueryResult;
+ const { data: ridersData } = useQueryGQL(GET_RIDERS, {}) as IQueryResult<
+ IRidersDataResponse | undefined,
+ undefined
+ >;
// Side-Effects
useEffect(() => {
if (ridersData) {
- const newRiderOptions = ridersData.riders
- .filter((_rider) => _rider.available)
- .map((rider) => ({
- label: rider.name,
- code: rider.name.toUpperCase(),
- assignedOrders: rider.assigned,
- _id: rider._id,
- }));
+ const newRiderOptions = ridersData.riders.map((rider) => ({
+ label: rider.name,
+ code: rider.name.toUpperCase(),
+ _id: rider._id,
+ }));
setRiderOptions(newRiderOptions); // Set the rider options
}
}, [ridersData]);
@@ -156,7 +149,12 @@ export const DISPATCH_TABLE_COLUMNS = (
},
fetchPolicy: 'network-only',
onSubscriptionData: () => {
- fetchActiveOrders();
+ // fetchActiveOrders({
+ // page: 1,
+ // rowsPerPage: 10,
+ // search: '',
+ // actions: [],
+ // });
},
});
};
@@ -166,7 +164,10 @@ export const DISPATCH_TABLE_COLUMNS = (
};
// Mutations
- const [assignRider] = useMutation(ASSIGN_RIDER, {
+ const [assignRider] = useMutation<
+ IAssignRider,
+ { id: string; riderId: string }
+ >(ASSIGN_RIDER, {
onError: (error) => {
showToast({
type: 'error',
@@ -176,6 +177,14 @@ export const DISPATCH_TABLE_COLUMNS = (
t('An error occured while assigning the job to rider'),
});
},
+
+ onCompleted: () => {
+ setIsRiderLoading({
+ _id: '',
+ orderId: '',
+ bool: false,
+ });
+ },
refetchQueries: [{ query: GET_ACTIVE_ORDERS }],
});
@@ -201,22 +210,14 @@ export const DISPATCH_TABLE_COLUMNS = (
//Handlers
const handleAssignRider = async (
- item: IRiderDropDownSelectItem,
+ item: IDropdownSelectItem,
rowData: IActiveOrders
) => {
- if (item?.assignedOrders.length > 5) {
- return showToast({
- type: 'error',
- title: t('Assign Rider'),
- message: t(
- 'This rider has already been assigned 5 orders, please choose a different one'
- ),
- });
- }
if (item._id) {
setIsRiderLoading({
_id: item._id,
bool: true,
+ orderId: rowData._id,
});
const { data } = await assignRider({
@@ -233,10 +234,6 @@ export const DISPATCH_TABLE_COLUMNS = (
});
}
}
- setIsRiderLoading({
- _id: '',
- bool: false,
- });
};
const handleStatusDropDownChange = async (
@@ -291,37 +288,71 @@ export const DISPATCH_TABLE_COLUMNS = (
propertyName: 'paymentMethod',
headerName: t('Payment'),
},
+ {
+ propertyName: 'user.name',
+ headerName: t('Customer'),
+ },
+ {
+ propertyName: 'user.phone',
+ headerName: t('Phone'),
+ },
{
propertyName: 'rider.name',
headerName: t('Rider'),
body: (rowData: IActiveOrders) => {
- return (
-
-
- handleAssignRider(e.value, rowData)
- }
- optionDisabled={(option) =>
- option.assignedOrders.length > 5 &&
- option._id !== rowData?.rider?._id
- }
- // filter={true}
- className="outline outline-1 min-w-[120px] outline-gray-300"
- />
-
- );
+ const selectedRider: IDropdownSelectItem = {
+ label: rowData?.rider?.name.toString() ?? '',
+ code: rowData?.rider?.name.toString().toUpperCase() ?? '',
+ _id: rowData?.rider?._id.toString() ?? '',
+ };
+ if (rowData._id && !rowData.isPickedUp) {
+ return (
+
+
+ handleAssignRider(e.value, rowData)
+ }
+ // filter={true}
+ className="outline outline-1 min-w-[120px] outline-gray-300"
+ />
+
+ );
+ } else {
+ return (
+
+ <>>}
+ disabled={true}
+ // onChange={(e: DropdownChangeEvent) =>
+ // handleAssignRider(e.value, rowData)
+ // }
+ // filter={true}
+ className="outline outline-1 min-w-[150px] outline-gray-300"
+ />
+
+ );
+ }
},
},
{
@@ -335,27 +366,65 @@ export const DISPATCH_TABLE_COLUMNS = (
),
},
+ // {
+ // propertyName: 'orderStatus',
+ // headerName: t('Status'),
+
+ // body: (rowData: IActiveOrders) => {
+ // const currentStatus = actionStatusOptions.find(
+ // (status: IDropdownSelectItem) => status.code === rowData?.orderStatus
+ // );
+
+ // return (
+ // <>
+ // handleStatusDropDownChange(e, rowData)}
+ // options={actionStatusOptions}
+ // itemTemplate={itemTemplate}
+ // valueTemplate={valueTemplate}
+ // loading={
+ // isStatusUpdating.bool && isStatusUpdating._id === rowData._id
+ // }
+ // className="outline outline-1 outline-gray-300"
+ // />
+ // >
+ // );
+ // },
+ // },
{
propertyName: 'orderStatus',
headerName: t('Status'),
-
body: (rowData: IActiveOrders) => {
- const currentStatus = actionStatusOptions.find(
+ // CHANGE 2: Filter status options based on whether it's a pickup order
+ const availableStatuses = rowData.isPickedUp
+ ? actionStatusOptions.filter((status) =>
+ ['PENDING', 'ACCEPTED', 'DELIVERED', 'CANCELLED'].includes(
+ status.code
+ )
+ )
+ : actionStatusOptions;
+
+ const currentStatus = availableStatuses.find(
(status: IDropdownSelectItem) => status.code === rowData?.orderStatus
);
+ // CHANGE 3: Disable status changes for delivered orders
+ const isDelivered = rowData.orderStatus === 'DELIVERED';
+
return (
<>
handleStatusDropDownChange(e, rowData)}
- options={actionStatusOptions}
+ options={availableStatuses} // CHANGE 4: Use filtered status options
itemTemplate={itemTemplate}
valueTemplate={valueTemplate}
loading={
isStatusUpdating.bool && isStatusUpdating._id === rowData._id
}
className="outline outline-1 outline-gray-300"
+ disabled={isDelivered} // CHANGE 5: Disable dropdown if delivered
/>
>
);
diff --git a/enatega-multivendor-admin/lib/ui/useable-components/table/index.tsx b/enatega-multivendor-admin/lib/ui/useable-components/table/index.tsx
index e5199890..77fdcdc3 100644
--- a/enatega-multivendor-admin/lib/ui/useable-components/table/index.tsx
+++ b/enatega-multivendor-admin/lib/ui/useable-components/table/index.tsx
@@ -9,9 +9,11 @@ import { Column } from 'primereact/column';
import {
DataTable,
DataTableSelectionMultipleChangeEvent,
+ DataTablePageEvent,
} from 'primereact/datatable';
import DataTableColumnSkeleton from '../custom-skeletons/datatable.column.skeleton';
import { useTranslations } from 'next-intl';
+
const Table = ({
header,
data,
@@ -25,6 +27,17 @@ const Table = ({
moduleName = 'Restaurant-Orders',
handleRowClick,
rowsPerPage = 10,
+ onPage,
+ className,
+ // For Store table
+ sortField,
+ sortOrder,
+ scrollable =true,
+ scrollHeight="420px",
+ // New pagination props
+ totalRecords,
+ onPageChange,
+ currentPage = 1,
}: IDataTableProps) => {
const handleSelectionChange = (
e: DataTableSelectionMultipleChangeEvent
@@ -35,6 +48,17 @@ const Table = ({
// Hooks
const t = useTranslations();
+ // Handlers
+ const handlePageChange = (event: DataTablePageEvent) => {
+ if (onPageChange) {
+ // Add 1 to first because PrimeReact uses 0-based indexing for pages
+ const page = Math.floor(event.first / event.rows) + 1;
+ onPageChange(page, event.rows);
+ }
+ };
+
+ const isServerPaginated = Boolean(onPageChange && totalRecords !== undefined);
+
const rowClassName = (data: T) => {
let className = '';
switch (moduleName) {
@@ -50,17 +74,32 @@ const Table = ({
return `${className} ${handleRowClick ? 'hover-clickable-row' : ''}`;
};
+ // Prepare pagination props based on server pagination status
+ const paginationProps = isServerPaginated
+ ? {
+ first: (currentPage - 1) * rowsPerPage,
+ lazy: true,
+ totalRecords,
+ onPage: handlePageChange,
+ }
+ : {};
+
return (
<>
({
}}
selectionMode={isSelectable ? 'checkbox' : null}
filters={filters}
- scrollable={true}
- scrollHeight="480px"
+ scrollable={scrollable}
+ scrollHeight={scrollHeight}
removableSort
rowClassName={rowClassName}
onRowClick={handleRowClick}
- emptyMessage={t("No available options")}
+ emptyMessage={t('No Data Available')}
+ {...paginationProps} // Spread pagination props conditionally
>
{isSelectable && (
=> {
- return new Promise((resolve) => {
- const videoSize = file.size / (1024 * 1024);
- const video = document.createElement('video');
- video.preload = 'metadata';
-
- video.onloadedmetadata = () => {
- const isInvalidVideo =
- (orientation === 'LANDSCAPE' &&
- video.videoWidth <= video.videoHeight) ||
- (orientation === 'SQUARE' &&
- video.videoWidth !== video.videoHeight) ||
- video.videoHeight > video.videoWidth;
- if (videoSize > maxVideoSize) {
- showToast({
- type: 'error',
- title: t('Upload Video'),
- message: `${t('Video size must be')} < ${maxVideoSize}`,
- });
- setImageValidationErr({
- bool: true,
- msg: `${t('Video size must be')} < ${maxVideoSize}`,
- });
- resolve(false);
- return false;
- } else if (video.videoWidth > maxFileWidth) {
- showToast({
- type: 'error',
- title: t('Upload Video'),
- message: `${t('Video width must be')} < ${maxFileWidth}`,
- });
- setImageValidationErr({
- bool: true,
- msg: `${t('Video width must be')} < ${maxFileWidth}`,
- });
- resolve(false);
- return false;
- } else if (video.videoHeight > maxFileHeight) {
- showToast({
- type: 'error',
- title: t('Upload Video'),
- message: `${t('Video height must be')} < ${maxFileHeight}`,
- });
- setImageValidationErr({
- bool: true,
- msg: `${t('Video height must be')} < ${maxFileHeight}`,
- });
- resolve(false);
- return false;
- } else if (isInvalidVideo) {
- showToast({
- type: 'error',
- title: t('Upload Video'),
- message: t(`Video dimensions must follow the guidelines`),
- });
- setImageValidationErr({
- bool: true,
- msg: t(`Video dimensions must follow the guidelines`),
- });
- resolve(false);
- return false;
- } else {
- setImageValidationErr({
- bool: false,
- msg: ``,
- });
- resolve(true);
- return true;
- }
- };
- // Set the video source
- video.src = URL.createObjectURL(file);
- });
- },
-
- [maxFileHeight, maxFileWidth, orientation, showToast, maxVideoSize]
- );
-
- // Validate Image
- const validateImage = useCallback(
- async (file: File) => {
- let img = new window.Image();
- let fileReader = new FileReader();
-
- const { isValid } = await new Promise<{
- imgSrc: string;
- isValid: boolean;
- }>((resolve) => {
- try {
- fileReader.onload = (e: ProgressEvent) => {
- const result = e.target?.result as string;
- img.src = result;
-
- img.onload = () => {
- // Validate orientation
- const invalidOrientation =
- (orientation === 'LANDSCAPE' && img.width <= img.height) ||
- (orientation === 'SQUARE' && img.width !== img.height) ||
- img.height > img.width;
-
- if (invalidOrientation) {
- showToast({
- type: 'error',
- title: t('Image Upload'),
- message: `${t('The image should be in')} ${orientation} ${t('orientation')}.`,
- });
- setImageValidationErr({
- bool: true,
- msg: `${t('The image should be in')} ${orientation} ${t('orientation')}.`,
- });
- setImageFile('');
- return resolve({ imgSrc: '', isValid: false });
- }
-
- // Validate width
- if (img.width > maxFileWidth) {
- showToast({
- type: 'error',
- title: t('Image Upload'),
- message: `${t('The file width exceeds the limit of')} ${maxFileWidth}.`,
- });
- setImageValidationErr({
- bool: true,
- msg: `File width should be < ${maxFileWidth}`,
- });
- setImageFile('');
- return resolve({ imgSrc: '', isValid: false });
- }
-
- // Validate height
- if (img.height > maxFileHeight) {
- showToast({
- type: 'error',
- title: t('Image Upload'),
- message: `${t('The file height exceeds the limit of')} ${maxFileHeight}.`,
- });
- setImageValidationErr({
- bool: true,
- msg: `${t('File height should be')} < ${maxFileHeight}`,
- });
- setImageFile('');
- return resolve({ imgSrc: '', isValid: false });
- }
-
- // If all checks pass, set the image and resolve as valid
- setImageValidationErr({ bool: false, msg: '' });
- setImageFile(result);
- resolve({ imgSrc: result, isValid: true });
- };
-
- img.onerror = () => {
- showToast({
- type: 'error',
- title: t('Image Upload'),
- message: t('An error occurred while loading the image'),
- });
- setImageValidationErr({
- bool: true,
- msg: t('Error during image load'),
- });
- setImageFile('');
- resolve({ imgSrc: '', isValid: false });
- };
- };
-
- fileReader.readAsDataURL(file);
- } catch (error) {
- console.error(error);
- showToast({
- type: 'error',
- title: t('Image Upload'),
- message: t('An unexpected error occurred, Please try again'),
- });
- setImageValidationErr({
- bool: true,
- msg: t('Unexpected error occurred'),
- });
- setImageFile('');
- resolve({ imgSrc: '', isValid: false });
- }
- });
-
- return isValid; // This should now reflect the correct validation state
- },
- [maxFileHeight, maxFileWidth, orientation, showToast]
- );
+ // Hooks
+ const t = useTranslations();
// Filter Files
const filterFiles = (event: FileUploadSelectEvent): File | undefined => {
const files = Array.from(event.files || []);
const extracted_files = files.filter((file) =>
- file.name.match(/\.(jpg|jpeg|png|gif|webp|mp4|webm)$/)
+ file.name.match(/\.(jpg|jpeg|png|gif|webp|avif|mp4|webm)$/)
);
- return extracted_files.length ? extracted_files[0] : undefined;
+ return extracted_files.length ? extracted_files[0] : files[0];
};
// Convert to Base64
const imageToBase64 = useCallback(
async (file: File): Promise => {
- var isValid = false;
+ var isValid = true;
setIsUploading(true);
- if (file?.type.startsWith('video/')) {
- isValid = await validateVideo(file);
- } else {
- isValid = await validateImage(file);
- }
+ // if (file?.type.startsWith('video/')) {
+ // isValid = await validateVideo(file);
+ // } else {
+ // isValid = await validateImage(file);
+ // }
if (!isValid) {
setIsUploading(false);
return;
@@ -290,12 +102,28 @@ function CustomUploadImageComponent({
configuration?.cloudinaryApiKey ?? ''
)
.then((url) => {
+ console.log(':rocket: ~ .then ~ url:', url);
isValid = false;
+ console.log(':rocket: ~ Valid url idk about the response');
onSetImageUrl(name, url);
+ if (!url) {
+ showToast({
+ type: 'error',
+ title: title,
+ message: `${fileTypes.includes('video/webm') || fileTypes.includes('video/mp4') ? t('File') : t('Image')} ${t('Upload Failed')}`,
+ duration: 2500,
+ });
+ setImageValidationErr({
+ bool: true,
+ msg: 'Cloudinary Url Invalid',
+ });
+ setImageFile('');
+ return;
+ }
showToast({
type: 'info',
title: title,
- message: `${fileTypes.includes('video/webm') || fileTypes.includes('video/mp4') ? t('File') : t('Image')} ${t("has been uploaded successfully")}.`,
+ message: `${fileTypes.includes('video/webm') || fileTypes.includes('video/mp4') ? t('File') : t('Image')} ${t('has been uploaded successfully')}.`,
duration: 2500,
});
})
@@ -304,9 +132,10 @@ function CustomUploadImageComponent({
showToast({
type: 'error',
title: title,
- message: `${fileTypes.includes('video/webm') || fileTypes.includes('video/mp4') ? t('File') : t('Image')} ${t("Upload Failed")}`,
+ message: `${fileTypes.includes('video/webm') || fileTypes.includes('video/mp4') ? t('File') : t('Image')} ${t('Upload Failed')}`,
duration: 2500,
});
+
console.log('errrror=====>', err);
})
.finally(() => {
@@ -324,7 +153,7 @@ function CustomUploadImageComponent({
configuration?.cloudinaryUploadUrl,
showToast,
title,
- validateImage,
+ // validateImage,
fileTypes,
]
);
@@ -357,13 +186,13 @@ function CustomUploadImageComponent({
};
return (
-
{t(title)}
+
{title}
@@ -391,12 +220,22 @@ function CustomUploadImageComponent({
{existingImageUrl ? (
-
+ existingImageUrl.includes('video/') ? (
+
+ ) : (
+
+ )
) : imageFile ? (
);
}}
- chooseLabel={t("Upload Image")}
+ chooseLabel={t('Upload Image')}
chooseOptions={
page === 'vendor-profile-edit'
? {
- className: `z-50 bg-white max-[500px]:ml-[-20px] ${!imageFile ? 'text-gray-700' : imageValidationErr.bool && !imageFile ? 'text-[#E4E4E7]' : 'text-[#E4E4E7]'} border border-[c] rounded-md items-center justify-center relative left-[20%] translate-y-[45px] w-[173px] h-[40px] text-[14px] gap-[5px] font-medium`,
+ className: `z-50 bg-white max-[500px]:ml-[-20px] ${!imageFile ? 'text-gray-700' : imageValidationErr.bool && !imageFile ? 'text-[#E4E4E7]' : 'text-[#E4E4E7]'} border border-[#E4E4E7] rounded-md items-center justify-center relative left-[20%] translate-y-[45px] w-[173px] h-[40px] text-[14px] gap-[5px] font-medium`,
label: t('Upload Image'),
icon: () => ,
}
@@ -475,6 +314,7 @@ function CustomUploadImageComponent({
width={100}
height={100}
autoPlay
+ muted
/>
) : (
{imageValidationErr.msg}
-
- {/* Error Messages Container */}
-
- {/* Rules */}
- {page === 'vendor-profile-edit' ? (
-
- {t('Recommended Size')}: {maxFileWidth} x{' '}
- {maxFileHeight} pixel{' '}
-
- {t('Upload File Type')}:{' '}
-
- {t('PNG or JPG')}
- {' '}
-
- {/* {fileTypes?.map((type, index) => {
- return (
-
- {type.split('')}
-
- );
- })} */}
-
-
- ) : (
- <>
-
- {`${t('Prefered dimensions')} ${maxFileWidth} x ${maxFileHeight}`}{' '}
- *
-
-
- {`${t('Prefered File size')} < ${maxFileSize === 2097152 ? '2MB' : '500KB'}`}
- *
-
-
- {t('Allowed file types')}:
- {fileTypes?.map((type, index) => {
- return (
-
- {type.split('')}
-
- );
- })}
-
- >
- )}
-
{error &&
{error}
}
);
}
diff --git a/enatega-multivendor-admin/lib/utils/constants/url.ts b/enatega-multivendor-admin/lib/utils/constants/url.ts
index eec6da12..50b6da04 100644
--- a/enatega-multivendor-admin/lib/utils/constants/url.ts
+++ b/enatega-multivendor-admin/lib/utils/constants/url.ts
@@ -1,7 +1,7 @@
export const BACKEND_URL = {
LOCAL: {
- SERVER_URL: 'http://192.168.0.131:8001/', //'https://enatega-multivendor.up.railway.app/',
- WS_SERVER_URL: 'ws://192.168.0.131:8001/', //wss://enatega-multivendor.up.railway.app/',
+ SERVER_URL: 'http://192.168.18.74:8001/', //'https://enatega-multivendor.up.railway.app/',
+ WS_SERVER_URL: 'ws://192.168.18.74:8001/', //wss://enatega-multivendor.up.railway.app/',
},
LIVE: {
SERVER_URL: 'https://enatega-multivendor.up.railway.app/',
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
index adabc1ad..ccfb69b6 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
@@ -1,8 +1,10 @@
+import { Dispatch, SetStateAction } from 'react';
import { TSideBarFormPosition } from '../types/sidebar';
import {
IGlobalComponentProps,
IGlobalTableHeaderProps,
} from './global.interface';
+import { IOptions } from './options.interface';
export interface IAddonHeaderProps extends IGlobalComponentProps {
setIsAddAddonVisible: (visible: boolean) => void;
@@ -14,6 +16,10 @@ export interface IAddonAddFormComponentProps extends IGlobalComponentProps {
isAddAddonVisible: boolean;
onHide: () => void;
addon: IAddon | null;
+ isAddOptionsVisible:boolean;
+ setIsAddOptionsVisible:Dispatch
>;
+ option:IOptions | null;
+ setOption:Dispatch>;
}
export interface IAddonMainComponentsProps extends IGlobalComponentProps {
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/category.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/category.interface.ts
index a6e37c7a..745a035b 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/category.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/category.interface.ts
@@ -17,6 +17,7 @@ export interface ICategoryAddFormComponentProps extends IGlobalComponentProps {
onHide: () => void;
category: ICategory | null;
subCategories?: ISubCategory[];
+ refetchCategories?: () => void;
}
export interface ICategoryMainComponentsProps extends IGlobalComponentProps {
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/dispatch.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/dispatch.interface.ts
index 3eeb6fcb..2c0e3df7 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/dispatch.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/dispatch.interface.ts
@@ -2,6 +2,7 @@ import { ChangeEvent, Dispatch, SetStateAction } from 'react';
export interface IActiveOrders {
_id: string;
+ isPickedUp: boolean;
zone: {
_id: string;
};
@@ -24,7 +25,6 @@ export interface IActiveOrders {
name: string;
username: string;
available: boolean;
- assigned: string[];
};
}
@@ -39,7 +39,7 @@ export interface GeolocationCoordinates {
}
export interface IGetActiveOrders {
- getActiveOrders: IActiveOrders[];
+ getActiveOrders: { totalCount: number; orders: IActiveOrders[] };
}
export interface IRidersByZone {
@@ -76,4 +76,7 @@ export interface IDispatchTableHeaderProps {
onGlobalFilterChange: (e: ChangeEvent) => void;
selectedActions: string[];
setSelectedActions: Dispatch>;
+ search: string;
+ setSearch: Dispatch>;
}
+
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/layout.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/layout.interface.ts
index 43dda275..12e42b4e 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/layout.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/layout.interface.ts
@@ -6,6 +6,7 @@ import React, {
import { IGlobalProps } from './global.interface';
import { ICategory, ISubCategory } from './category.interface';
+import { IOptions } from './options.interface';
// Layout
export interface IProvider extends IGlobalProps {}
@@ -60,6 +61,10 @@ export interface RestaurantLayoutContextProps {
setIsSubCategoryModalOpen: Dispatch>;
subCategoryParentId: string;
setSubCategoryParentId: Dispatch>;
+ isAddOptionsVisible: boolean;
+ setIsAddOptionsVisible: Dispatch>;
+ option: IOptions | null;
+ setOption: Dispatch>;
}
export interface RestaurantLayoutContextData {
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/table.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/table.interface.ts
index 249730fd..a89a507f 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/table.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/table.interface.ts
@@ -1,6 +1,6 @@
import { FilterMatchMode } from 'primereact/api';
import { IGlobalComponentProps } from './global.interface';
-import { DataTableRowClickEvent } from 'primereact/datatable';
+import { DataTableRowClickEvent, DataTableStateEvent, SortOrder } from 'primereact/datatable';
export interface IFilterType {
[key: string]: {
@@ -28,6 +28,14 @@ export interface IDataTableProps extends IGlobalComponentProps {
handleRowClick?: (event: DataTableRowClickEvent) => void;
rowsPerPage?: number;
moduleName?: string;
+ totalRecords?: number;
+ onPageChange?: (page: number, rows: number) => void;
+ currentPage?: number;
+ onPage?: (e: DataTableStateEvent) => void;
+ scrollable?: boolean;
+ scrollHeight?: string;
+ sortField?:string;
+ sortOrder?:SortOrder
}
export interface ITableExtends extends IGlobalComponentProps {
From 9270a31ef51674e09482d8b12811fb7ca5328d1b Mon Sep 17 00:00:00 2001
From: Syed Talha Ejaz
Date: Wed, 19 Feb 2025 11:12:21 +0500
Subject: [PATCH 2/3] fixed the changes for preview fails
---
enatega-multivendor-admin/lib/utils/constants/url.ts | 4 ++--
.../lib/utils/interfaces/add-on.interface.ts | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/enatega-multivendor-admin/lib/utils/constants/url.ts b/enatega-multivendor-admin/lib/utils/constants/url.ts
index 50b6da04..eec6da12 100644
--- a/enatega-multivendor-admin/lib/utils/constants/url.ts
+++ b/enatega-multivendor-admin/lib/utils/constants/url.ts
@@ -1,7 +1,7 @@
export const BACKEND_URL = {
LOCAL: {
- SERVER_URL: 'http://192.168.18.74:8001/', //'https://enatega-multivendor.up.railway.app/',
- WS_SERVER_URL: 'ws://192.168.18.74:8001/', //wss://enatega-multivendor.up.railway.app/',
+ SERVER_URL: 'http://192.168.0.131:8001/', //'https://enatega-multivendor.up.railway.app/',
+ WS_SERVER_URL: 'ws://192.168.0.131:8001/', //wss://enatega-multivendor.up.railway.app/',
},
LIVE: {
SERVER_URL: 'https://enatega-multivendor.up.railway.app/',
diff --git a/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts b/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
index ccfb69b6..da4339e3 100644
--- a/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
+++ b/enatega-multivendor-admin/lib/utils/interfaces/add-on.interface.ts
@@ -16,10 +16,10 @@ export interface IAddonAddFormComponentProps extends IGlobalComponentProps {
isAddAddonVisible: boolean;
onHide: () => void;
addon: IAddon | null;
- isAddOptionsVisible:boolean;
- setIsAddOptionsVisible:Dispatch>;
- option:IOptions | null;
- setOption:Dispatch>;
+ isAddOptionsVisible?:boolean;
+ setIsAddOptionsVisible?:Dispatch>;
+ option?:IOptions | null;
+ setOption?:Dispatch>;
}
export interface IAddonMainComponentsProps extends IGlobalComponentProps {
From b795a04ea28a575bcd054bbc3603e3465881b6e7 Mon Sep 17 00:00:00 2001
From: Syed Talha Ejaz
Date: Wed, 19 Feb 2025 11:16:14 +0500
Subject: [PATCH 3/3] fixed the changes for preview fails
---
enatega-multivendor-admin/lib/utils/dummy/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/enatega-multivendor-admin/lib/utils/dummy/index.tsx b/enatega-multivendor-admin/lib/utils/dummy/index.tsx
index 47c4373c..32fa91e8 100644
--- a/enatega-multivendor-admin/lib/utils/dummy/index.tsx
+++ b/enatega-multivendor-admin/lib/utils/dummy/index.tsx
@@ -422,7 +422,6 @@ export const generateDummyDispatchOrders = (count: number = 10) => {
name: `rider_${i + 1}`,
username: `rider_${i + 1}`,
available: true,
- assigned: [''],
},
createdAt: new Date().toDateString(),
deliveryAddress: {
@@ -443,6 +442,7 @@ export const generateDummyDispatchOrders = (count: number = 10) => {
zone: {
_id: `active_order_${i + 1}`,
},
+ isPickedUp: false
});
}
return dispatchActiveOrders;