Update 'next' package version and refactor user account handling

This commit updates the 'next' package from version 14.2.0 to 14.2.1 across various modules. It also refactors the code for user account handling to make it controlled by an enableTeamAccounts flag in the featureFlagsConfig, essentially allowing the enabling or disabling of the 'team accounts' feature according to the specified flag.
This commit is contained in:
giancarlo
2024-04-15 17:46:11 +08:00
parent 81e662e63d
commit 8627cdaf1f
13 changed files with 78 additions and 74 deletions

View File

@@ -36,7 +36,7 @@
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"next-themes": "0.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -33,7 +33,6 @@ interface AccountSelectorProps {
}>;
features: {
enableTeamAccounts: boolean;
enableTeamCreation: boolean;
};
@@ -50,7 +49,6 @@ export function AccountSelector({
selectedAccount,
onAccountChange,
features = {
enableTeamAccounts: true,
enableTeamCreation: true,
},
collapsed = false,
@@ -80,10 +78,6 @@ export function AccountSelector({
);
};
if (!features.enableTeamAccounts) {
return null;
}
const selected = accounts.find((account) => account.value === value);
const pictureUrl = personalData.data?.picture_url;
@@ -176,66 +170,64 @@ export function AccountSelector({
<CommandSeparator />
<If condition={features.enableTeamAccounts}>
<If condition={accounts.length > 0}>
<CommandGroup
heading={
<Trans
i18nKey={'teams:yourTeams'}
values={{ teamsCount: accounts.length }}
/>
}
>
{(accounts ?? []).map((account) => (
<CommandItem
data-test={'account-selector-team'}
data-name={account.label}
data-slug={account.value}
className={cn(
'group flex justify-between transition-colors',
{
['bg-muted']: value === account.value,
},
)}
key={account.value}
value={account.value ?? ''}
onSelect={(currentValue) => {
setValue(currentValue === value ? '' : currentValue);
setOpen(false);
<If condition={accounts.length > 0}>
<CommandGroup
heading={
<Trans
i18nKey={'teams:yourTeams'}
values={{ teamsCount: accounts.length }}
/>
}
>
{(accounts ?? []).map((account) => (
<CommandItem
data-test={'account-selector-team'}
data-name={account.label}
data-slug={account.value}
className={cn(
'group flex justify-between transition-colors',
{
['bg-muted']: value === account.value,
},
)}
key={account.value}
value={account.value ?? ''}
onSelect={(currentValue) => {
setValue(currentValue === value ? '' : currentValue);
setOpen(false);
if (onAccountChange) {
onAccountChange(currentValue);
}
}}
>
<div className={'flex items-center'}>
<Avatar
className={cn(
'mr-2 h-6 w-6 border border-transparent',
{
['border-border']: value === account.value,
['group-hover:border-border ']:
value !== account.value,
},
)}
>
<AvatarImage src={account.image ?? undefined} />
if (onAccountChange) {
onAccountChange(currentValue);
}
}}
>
<div className={'flex items-center'}>
<Avatar
className={cn(
'mr-2 h-6 w-6 border border-transparent',
{
['border-border']: value === account.value,
['group-hover:border-border ']:
value !== account.value,
},
)}
>
<AvatarImage src={account.image ?? undefined} />
<AvatarFallback>
{account.label ? account.label[0] : ''}
</AvatarFallback>
</Avatar>
<AvatarFallback>
{account.label ? account.label[0] : ''}
</AvatarFallback>
</Avatar>
<span className={'mr-2 max-w-[165px] truncate'}>
{account.label}
</span>
</div>
<span className={'mr-2 max-w-[165px] truncate'}>
{account.label}
</span>
</div>
<Icon item={account.value ?? ''} />
</CommandItem>
))}
</CommandGroup>
</If>
<Icon item={account.value ?? ''} />
</CommandItem>
))}
</CommandGroup>
</If>
</CommandList>
</Command>

View File

@@ -40,7 +40,7 @@
"@tanstack/react-table": "^8.16.0",
"@types/react": "^18.2.77",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"react-hook-form": "^7.51.3",
"zod": "^3.22.4"

View File

@@ -32,7 +32,7 @@
"@tanstack/react-query": "5.29.0",
"@types/react": "^18.2.77",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react-hook-form": "^7.51.3",
"react-i18next": "^14.1.0",
"sonner": "^1.4.41",

View File

@@ -37,7 +37,7 @@
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",