Skip to content

Commit 2a29c7e

Browse files
Merge pull request #852 from enatega/ahmad
Fixed issues
2 parents 6b87efe + f3d603e commit 2a29c7e

File tree

13 files changed

+74
-47
lines changed

13 files changed

+74
-47
lines changed

enatega-multivendor-admin/lib/hoc/RESTAURANT_GUARD.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const RESTAURANT_GUARD = <T extends object>(
2626

2727
// For STAFF => Check if VENDOR permission is given to STAFF
2828
if (user && user.userType === 'STAFF') {
29-
const allowed = user?.permissions?.includes('Restaurants');
29+
const allowed = user?.permissions?.includes('Restaurants') || user?.permissions?.includes('Stores');
3030

3131
if (!allowed) {
3232
router.replace('/forbidden');

enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/dashboard/sub-header/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default function DashboardSubHeader({
2222
t('Week'),
2323
t('Month'),
2424
t('Year'),
25-
t('Custom'),
25+
'Custom',
2626
]}
27-
selectedTab={dateFilter?.dateKeyword ?? t('All')}
27+
selectedTab={dateFilter?.dateKeyword ?? 'All'}
2828
setSelectedTab={(tab: string) =>
2929
handleDateFilter({ ...dateFilter, dateKeyword: tab })
3030
}

enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/commission-rate/view/main/index.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,24 @@ export default function CommissionRateMain() {
6464
// Handlers
6565
const handleSave = async (restaurantId: string) => {
6666
const restaurant = restaurants.find((r) => r._id === restaurantId);
67+
if (!restaurant?.commissionRate) {
68+
return showToast({
69+
type: 'error',
70+
title: t('Commission Updated'),
71+
message: `${t('Commission')} ${t('Update')} ${t('failed')}`,
72+
});
73+
}
6774
if (restaurant) {
6875
setLoadingRestaurant(restaurantId);
69-
if(restaurant?.commissionRate>100){
76+
if (restaurant?.commissionRate > 100) {
7077
setLoadingRestaurant(null);
7178
return showToast({
72-
type:"error",
73-
title:t('Commission Updated'),
74-
message:t('As commission rate is a %age value so it cannot exceed a max value of 100')
75-
})
79+
type: 'error',
80+
title: t('Commission Updated'),
81+
message: t(
82+
'As commission rate is a %age value so it cannot exceed a max value of 100'
83+
),
84+
});
7685
}
7786
try {
7887
await updateCommissionMutation({

enatega-multivendor-admin/lib/ui/screen-components/protected/super-admin/order/header/table-header/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ const OrderSuperAdminTableHeader: React.FC<IOrderSuperAdminHeaderProps> = ({
7878
</div>
7979

8080
<DateFilterCustomTab
81-
options={['All', 'Today', 'Week', 'Month', 'Year', 'Custom']}
81+
options={[
82+
t('All'),
83+
t('Today'),
84+
t('Week'),
85+
t('Month'),
86+
t('Year'),
87+
'Custom',
88+
]}
8289
selectedTab={dateFilter.dateKeyword}
8390
setSelectedTab={(tab: string) =>
8491
handleDateFilter({ ...dateFilter, dateKeyword: tab })

enatega-multivendor-admin/lib/ui/screen-components/protected/vendor/dashboard/sub-header/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export default function DashboardSubHeader({
3838
</div>
3939
</div>
4040
<DateFilterCustomTab
41-
options={['All', 'Today', 'Week', 'Month', 'Year', 'Custom']}
41+
options={[
42+
t('All'),
43+
t('Today'),
44+
t('Week'),
45+
t('Month'),
46+
t('Year'),
47+
'Custom',
48+
]}
4249
selectedTab={dateFilter?.dateKeyword ?? ''}
4350
setSelectedTab={(tab: string) =>
4451
handleDateFilter({ ...dateFilter, dateKeyword: tab })
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
'use client';
22

3-
// Contexts
4-
import { LayoutContext } from '@/lib/context/global/layout.context';
5-
6-
// Components
3+
// Component
74
import GrowthOverView from '@/lib/ui/screen-components/protected/restaurant/dashboard/growth-overview';
85
import OrderStats from '@/lib/ui/screen-components/protected/restaurant/dashboard/order-stats';
96
import RestaurantStatesTable from '@/lib/ui/screen-components/protected/restaurant/dashboard/restaurant-stats-table';
7+
import DashboardSubHeader from '@/lib/ui/screen-components/protected/restaurant/dashboard/sub-header';
108
import DashboardDateFilter from '@/lib/ui/useable-components/date-filter';
119

12-
// Interfaces
1310
import { IDateFilter } from '@/lib/utils/interfaces';
14-
15-
// Hooks
16-
import { useContext, useState } from 'react';
11+
import { useState } from 'react';
1712

1813
export default function AdminRestaurantDashboard() {
19-
// Contexts
20-
const { isSuperAdminSidebarVisible } = useContext(LayoutContext);
21-
22-
// States
2314
const [dateFilter, setDateFilter] = useState<IDateFilter>({
15+
dateKeyword: 'All',
2416
startDate: `${new Date().getFullYear()}-01-01`, // Current year, January 1st
25-
endDate: `${new Date().getFullYear()}-${String(new Date().getMonth()).padStart(2, '0')}-${String(new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate()).padStart(2, '0')}`, // Last day of previous month
17+
endDate: `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, '0')}-${String(new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).getDate()).padStart(2, '0')}`, // Last day of the current month
2618
});
2719

20+
const handleDateFilter = (dateFilter: IDateFilter) => {
21+
setDateFilter({
22+
...dateFilter,
23+
dateKeyword: dateFilter.dateKeyword ?? '',
24+
});
25+
};
26+
2827
return (
29-
<>
30-
<div
31-
className={`flex flex-col ${isSuperAdminSidebarVisible ? 'w-[99%]' : 'w-[100%]'} overflow-x-hidden h-full p-3 `}
32-
>
33-
<DashboardDateFilter
34-
dateFilter={dateFilter}
35-
setDateFilter={setDateFilter}
36-
/>
37-
<OrderStats dateFilter={dateFilter} />
38-
<GrowthOverView />
39-
<RestaurantStatesTable dateFilter={dateFilter} />
40-
</div>
41-
</>
28+
<div className="screen-container">
29+
<DashboardSubHeader
30+
dateFilter={dateFilter}
31+
handleDateFilter={handleDateFilter}
32+
/>
33+
<DashboardDateFilter
34+
dateFilter={dateFilter}
35+
setDateFilter={setDateFilter}
36+
/>
37+
38+
<OrderStats dateFilter={dateFilter} />
39+
<GrowthOverView />
40+
<RestaurantStatesTable dateFilter={dateFilter} />
41+
</div>
4242
);
4343
}

enatega-multivendor-admin/lib/ui/useable-components/custom-tab/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const CustomTab = ({
2525
}`}
2626
onClick={() => setSelectedTab(option)}
2727
>
28-
{t(option)}
28+
{option}
2929
</div>
3030
))}
3131
</div>
32-
{selectedTab === 'Custom' && (
32+
{selectedTab === t('Custom') || selectedTab === t('custom') && (
3333
<OrdersDashboardDateFilter
3434
dateFilter={
3535
dateFilter ?? {

enatega-multivendor-admin/lib/ui/useable-components/dashboard-sub-header/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import CustomInputSwitch from '@/lib/ui/useable-components/custom-input-switch';
22
import CustomTab from '@/lib/ui/useable-components/custom-tab';
33
import { IDashboardSubHeaderComponentsProps } from '@/lib/utils/interfaces';
4+
import { useTranslations } from 'use-intl';
45

56
export default function DashboardSubHeader({
67
isStoreView,
78
handleViewChange,
89
dateFilter,
910
handleDateFilter,
1011
}: IDashboardSubHeaderComponentsProps) {
12+
const t = useTranslations();
13+
14+
if (!isStoreView || !handleViewChange) return;
1115
return (
1216
<div className="flex flex-row items-center justify-between rounded-lg bg-white px-4 py-3 shadow-sm">
1317
<div className="flex items-center space-x-4">
1418
<h2 className="text-xl font-semibold text-gray-800">
15-
Business Overview
19+
{t('Business Overview')}
1620
</h2>
1721
<div className="flex items-center space-x-2">
1822
<span
1923
className={`font-inter text-sm font-medium leading-5 ${!isStoreView ? 'text-black' : 'text-[#71717A]'}`}
2024
>
21-
Graph View
25+
{t('Graph View')}
2226
</span>
2327
<CustomInputSwitch
2428
isActive={isStoreView}
@@ -27,7 +31,7 @@ export default function DashboardSubHeader({
2731
<span
2832
className={`font-inter text-sm font-medium leading-5 ${isStoreView ? 'text-black' : 'text-[#71717A]'}`}
2933
>
30-
Store View
34+
{t('Store View')}
3135
</span>
3236
</div>
3337
</div>

enatega-multivendor-admin/lib/ui/useable-components/date-filter-custom-tab/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DateFilterCustomTab = ({
2121
}`}
2222
onClick={() => setSelectedTab(option)}
2323
>
24-
{t(option)}
24+
{t(option)}
2525
</div>
2626
))}
2727
</div>

enatega-multivendor-admin/lib/utils/constants/permissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const PERMISSIONS = [
22
{ label: 'Admin', code: 'Admin' },
33
{ label: 'Vendors', code: 'Vendors' },
4-
{ label: 'Stores', code: 'Restaurants' },
4+
{ label: 'Stores', code: 'Stores' },
55
{ label: 'Riders', code: 'Riders' },
66
{ label: 'Users', code: 'Users' },
77
{ label: 'Staff', code: 'Staff' },

0 commit comments

Comments
 (0)