Skip to content

Commit 7fce4d1

Browse files
committed
fix: disable admin nav items
1 parent 91c2778 commit 7fce4d1

File tree

8 files changed

+130
-43
lines changed

8 files changed

+130
-43
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { useLingui } from '@lingui/react';
2+
import {
3+
ListItem,
4+
ListItemButton,
5+
ListItemIcon,
6+
ListItemText,
7+
} from '@mui/material';
8+
import _ from 'lodash';
9+
10+
import { cn } from 'web-components/src/utils/styles/cn';
11+
12+
import { AdminNavigationItem } from './AdminNavigation.types';
13+
import { isSelected } from './AdminNavigation.utils';
14+
15+
type AdminNavigationListItemProps = {
16+
onNavItemClick: (sectionName: string) => void;
17+
currentPath: string;
18+
item: AdminNavigationItem;
19+
};
20+
export const AdminNavigationListItem = ({
21+
onNavItemClick,
22+
currentPath,
23+
item,
24+
}: AdminNavigationListItemProps) => {
25+
const { _ } = useLingui();
26+
27+
return (
28+
<ListItem disablePadding className="pb-1">
29+
<ListItemButton
30+
disableRipple
31+
className={cn(
32+
'flex p-2',
33+
item.disabled
34+
? 'text-bc-neutral-400 cursor-default'
35+
: 'cursor-pointer',
36+
)}
37+
onClick={() => {
38+
if (!item.disabled) onNavItemClick(item.path);
39+
}}
40+
selected={isSelected(item.path, currentPath)}
41+
sx={theme => ({
42+
'&.Mui-selected, &.Mui-selected:hover': {
43+
backgroundColor: theme.palette.info.light,
44+
borderRadius: '5px',
45+
},
46+
'&:hover': {
47+
backgroundColor: theme.palette.info.light,
48+
borderRadius: '5px',
49+
},
50+
})}
51+
>
52+
<ListItemIcon className="min-w-[40px]">{item.icon}</ListItemIcon>
53+
<ListItemText className="w-full">{_(item.name)}</ListItemText>
54+
</ListItemButton>
55+
</ListItem>
56+
);
57+
};

web-marketplace/src/components/organisms/AdminNavigation/AdminNavigation.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Fragment } from 'react';
12
import { useLingui } from '@lingui/react';
23
import {
34
List,
@@ -8,6 +9,10 @@ import {
89
ListSubheader,
910
} from '@mui/material';
1011

12+
import InfoTooltip from 'web-components/src/components/tooltip/InfoTooltip';
13+
import { cn } from 'web-components/src/utils/styles/cn';
14+
15+
import { AdminNavigationListItem } from './AdminNavigation.ListItem';
1116
import { AdminNavigationSection } from './AdminNavigation.types';
1217
import { isSelected } from './AdminNavigation.utils';
1318

@@ -45,7 +50,7 @@ export const AdminNavigation = ({
4550
subheader={
4651
<ListSubheader
4752
id={`${_(section.heading).toLowerCase()}-list-subheader`}
48-
className="bg-transparent text-gray-700 uppercase font-extrabold tracking-wider font-muli"
53+
className="bg-transparent text-bc-neutral-400 uppercase font-extrabold tracking-wider font-muli"
4954
component="div"
5055
disableSticky
5156
>
@@ -55,29 +60,25 @@ export const AdminNavigation = ({
5560
className="mb-15"
5661
>
5762
{section.items.map(item => (
58-
<ListItem key={_(item.name)} disablePadding className="pb-1">
59-
<ListItemButton
60-
disableRipple
61-
className="flex p-2 cursor-pointer"
62-
onClick={() => onNavItemClick(item.path)}
63-
selected={isSelected(item.path, currentPath)}
64-
sx={theme => ({
65-
'&.Mui-selected, &.Mui-selected:hover': {
66-
backgroundColor: theme.palette.info.light,
67-
borderRadius: '5px',
68-
},
69-
'&:hover': {
70-
backgroundColor: theme.palette.info.light,
71-
borderRadius: '5px',
72-
},
73-
})}
74-
>
75-
<ListItemIcon className="min-w-[40px]">
76-
{item.icon}
77-
</ListItemIcon>
78-
<ListItemText className="w-full">{_(item.name)}</ListItemText>
79-
</ListItemButton>
80-
</ListItem>
63+
<Fragment key={item.name}>
64+
{item.disabled ? (
65+
<InfoTooltip title={item.disabledTooltipText} arrow>
66+
<div>
67+
<AdminNavigationListItem
68+
onNavItemClick={onNavItemClick}
69+
currentPath={currentPath}
70+
item={item}
71+
/>
72+
</div>
73+
</InfoTooltip>
74+
) : (
75+
<AdminNavigationListItem
76+
onNavItemClick={onNavItemClick}
77+
currentPath={currentPath}
78+
item={item}
79+
/>
80+
)}
81+
</Fragment>
8182
))}
8283
</List>
8384
))}

web-marketplace/src/components/organisms/AdminNavigation/AdminNavigation.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ export type AdminNavigationSection = {
33
items: AdminNavigationItem[];
44
};
55

6-
type AdminNavigationItem = {
6+
export type AdminNavigationItem = {
77
name: string;
88
icon: JSX.Element;
99
path: string;
10+
disabledTooltipText?: string | undefined;
11+
disabled?: boolean | undefined;
1012
};

web-marketplace/src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,44 @@ import { ShoppingBagIcon } from 'web-components/src/components/icons/ShoppingBag
88
// import { PrefinanceIcon } from 'web-components/src/components/icons/PrefinanceIcon';
99
import { UserMenuIcon } from 'web-components/src/components/icons/UserMenuIcon';
1010

11-
import { AdminNavigationSection } from './AdminNavigation.types';
11+
import { NOT_SUPPORTED_TOOLTIP_TEXT } from 'pages/Dashboard/MyProjects/MyProjects.constants';
12+
13+
import {
14+
AdminNavigationItem,
15+
AdminNavigationSection,
16+
} from './AdminNavigation.types';
1217

1318
export const getAdminNavigationSections = ({
1419
showOrders,
20+
loginDisabled,
1521
}: {
1622
showOrders?: boolean;
23+
loginDisabled?: boolean;
1724
}): AdminNavigationSection[] => {
1825
const sections = [
1926
{
2027
heading: i18n._(msg`Profile`),
2128
items: [
2229
{
2330
name: i18n._(msg`Edit profile`),
24-
icon: <UserMenuIcon linearGradient />,
31+
icon: <UserMenuIcon linearGradient disabled={loginDisabled} />,
2532
path: 'profile',
33+
disabled: loginDisabled,
34+
disabledTooltipText: i18n._(NOT_SUPPORTED_TOOLTIP_TEXT),
2635
},
2736
{
2837
name: i18n._(msg`Settings`),
29-
icon: <CogIcon linearGradient />,
38+
icon: <CogIcon linearGradient disabled={loginDisabled} />,
3039
path: 'settings',
40+
disabled: loginDisabled,
41+
disabledTooltipText: i18n._(NOT_SUPPORTED_TOOLTIP_TEXT),
3142
},
3243
// {
3344
// name: i18n._(msg`Email updates`),
3445
// icon: <EnvelopeIcon linearGradient />,
3546
// path: 'email-updates',
3647
// },
37-
],
48+
] as AdminNavigationItem[],
3849
},
3950
];
4051

web-marketplace/src/lib/i18n/locales/en.po

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,10 @@ msgstr ""
12951295
msgid "Credit card not available for this project"
12961296
msgstr ""
12971297

1298+
#: src/pages/Orders/Orders.CreditCardHidden.tsx:8
1299+
msgid "Credit card orders are hidden"
1300+
msgstr ""
1301+
12981302
#: src/components/organisms/CreditBatches/CreditBatches.config.ts:19
12991303
#: src/lib/constants/shared.constants.tsx:197
13001304
msgid "credit class"
@@ -1788,7 +1792,7 @@ msgstr ""
17881792
msgid "edit profile"
17891793
msgstr ""
17901794

1791-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:23
1795+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:30
17921796
#: src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx:115
17931797
#: src/pages/Dashboard/Dashboard.constants.tsx:54
17941798
msgid "Edit profile"
@@ -2597,7 +2601,7 @@ msgstr ""
25972601
msgid "Must have recipients"
25982602
msgstr ""
25992603

2600-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:46
2604+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:57
26012605
#: src/pages/Dashboard/Dashboard.constants.tsx:79
26022606
msgid "My orders"
26032607
msgstr ""
@@ -2798,7 +2802,7 @@ msgstr ""
27982802
msgid "orders"
27992803
msgstr ""
28002804

2801-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:43
2805+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:54
28022806
msgid "Orders"
28032807
msgstr ""
28042808

@@ -3110,7 +3114,7 @@ msgstr ""
31103114
msgid "profile"
31113115
msgstr ""
31123116

3113-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:20
3117+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:27
31143118
#: src/pages/ProfileEdit/ProfileEdit.constants.tsx:8
31153119
msgid "Profile"
31163120
msgstr ""
@@ -3794,7 +3798,7 @@ msgstr ""
37943798
msgid "settings"
37953799
msgstr ""
37963800

3797-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:28
3801+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:37
37983802
#: src/pages/Dashboard/Dashboard.constants.tsx:62
37993803
#: src/pages/Settings/Settings.tsx:52
38003804
msgid "Settings"
@@ -4243,6 +4247,10 @@ msgstr ""
42434247
msgid "This factor is used to calculate the credits issued for this project."
42444248
msgstr ""
42454249

4250+
#: src/pages/Orders/Orders.CreditCardHidden.tsx:11
4251+
msgid "This feature is not yet supported by Wallet Connect and Keplr mobile. Please log in using Keplr browser extension on desktop or via email or Google login."
4252+
msgstr ""
4253+
42464254
#: src/lib/constants/shared.constants.tsx:63
42474255
msgid "This field is required"
42484256
msgstr ""

web-marketplace/src/lib/i18n/locales/es.po

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,10 @@ msgstr "Tarjeta de crédito"
12981298
msgid "Credit card not available for this project"
12991299
msgstr "Tarjeta de crédito no disponible para este proyecto"
13001300

1301+
#: src/pages/Orders/Orders.CreditCardHidden.tsx:8
1302+
msgid "Credit card orders are hidden"
1303+
msgstr "Los pedidos con tarjeta de crédito están ocultos"
1304+
13011305
#: src/components/organisms/CreditBatches/CreditBatches.config.ts:19
13021306
#: src/lib/constants/shared.constants.tsx:197
13031307
msgid "credit class"
@@ -1791,7 +1795,7 @@ msgstr "Editar filtros"
17911795
msgid "edit profile"
17921796
msgstr "editar perfil"
17931797

1794-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:23
1798+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:30
17951799
#: src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx:115
17961800
#: src/pages/Dashboard/Dashboard.constants.tsx:54
17971801
msgid "Edit profile"
@@ -2600,7 +2604,7 @@ msgstr "Debe ser positivo"
26002604
msgid "Must have recipients"
26012605
msgstr "Debe tener destinatarios"
26022606

2603-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:46
2607+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:57
26042608
#: src/pages/Dashboard/Dashboard.constants.tsx:79
26052609
msgid "My orders"
26062610
msgstr "Mis pedidos"
@@ -2801,7 +2805,7 @@ msgstr "Resumen del pedido"
28012805
msgid "orders"
28022806
msgstr "órdenes"
28032807

2804-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:43
2808+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:54
28052809
msgid "Orders"
28062810
msgstr "Pedidos"
28072811

@@ -3113,7 +3117,7 @@ msgstr "Proceda con precaución: ¡esto no se puede deshacer!"
31133117
msgid "profile"
31143118
msgstr "perfil"
31153119

3116-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:20
3120+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:27
31173121
#: src/pages/ProfileEdit/ProfileEdit.constants.tsx:8
31183122
msgid "Profile"
31193123
msgstr "Perfil"
@@ -3797,7 +3801,7 @@ msgstr "Configurar una billetera Keplr →"
37973801
msgid "settings"
37983802
msgstr "ajustes"
37993803

3800-
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:28
3804+
#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:37
38013805
#: src/pages/Dashboard/Dashboard.constants.tsx:62
38023806
#: src/pages/Settings/Settings.tsx:52
38033807
msgid "Settings"
@@ -4246,6 +4250,10 @@ msgstr "Estos datos están en cadena o anclados en la cadena a través de un has
42464250
msgid "This factor is used to calculate the credits issued for this project."
42474251
msgstr "Este factor se utiliza para calcular los créditos emitidos para este proyecto."
42484252

4253+
#: src/pages/Orders/Orders.CreditCardHidden.tsx:11
4254+
msgid "This feature is not yet supported by Wallet Connect and Keplr mobile. Please log in using Keplr browser extension on desktop or via email or Google login."
4255+
msgstr "Esta función aún no es compatible con Wallet Connect y Keplr Mobile. Inicie sesión con la extensión de navegador de Keplr en su computadora de escritorio o a través de correo electrónico o inicio de sesión de Google."
4256+
42494257
#: src/lib/constants/shared.constants.tsx:63
42504258
msgid "This field is required"
42514259
msgstr "Este campo es obligatorio"

web-marketplace/src/pages/Orders/Orders.CreditCardHidden.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Trans } from '@lingui/macro';
33
import { Body, Title } from 'web-components/src/components/typography';
44

55
export const CreditCardHidden = () => (
6-
<div className="mb-20 lg:mb-30 bg-orange-gradient p-20 pl-[12px] rounded-lg border-solid border border-l-8 border-bc-orange-300">
6+
<div className="mb-20 bg-orange-gradient p-20 pl-[12px] rounded-lg border-solid border border-l-8 border-bc-orange-300">
77
<Title variant="h6" className="text-base">
88
<Trans>Credit card orders are hidden</Trans>
99
</Title>
10-
<Body size="md">
10+
<Body size="sm" mobileSize="sm">
1111
<Trans>
1212
This feature is not yet supported by Wallet Connect and Keplr mobile.
1313
Please log in using Keplr browser extension on desktop or via email or

web-marketplace/src/pages/ProfileEdit/ProfileEdit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { ViewProfileButton } from './ProfileEdit.ViewProfile';
3030

3131
export const ProfileEdit = () => {
3232
const { _ } = useLingui();
33-
const { accountChanging } = useWallet();
33+
const { accountChanging, loginDisabled } = useWallet();
3434
const { loading } = useAuth();
3535
const showOrders = useShowOrders();
3636

@@ -70,7 +70,7 @@ export const ProfileEdit = () => {
7070
<div className="flex flex-col justify-start items-center lg:items-start lg:flex-row lg:justify-evenly max-w-[1150px] mx-auto p-10 lg:py-50 lg:px-15 lg:min-h-screen">
7171
<AdminNavigation
7272
className="hidden lg:block min-w-[235px]"
73-
sections={getAdminNavigationSections({ showOrders })}
73+
sections={getAdminNavigationSections({ showOrders, loginDisabled })}
7474
onNavItemClick={onNavClick}
7575
currentPath={pathname}
7676
savedPaymentInfo={

0 commit comments

Comments
 (0)