feat(imei): Add IMEI related internationalization support and menu items

This commit is contained in:
web@ppanel
2025-02-12 16:34:23 +07:00
parent b4946f7a06
commit 13c33378aa
204 changed files with 252 additions and 399 deletions
@@ -131,7 +131,7 @@ export default function Page() {
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/apple'
placeholder='https://your-domain.com'
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
@@ -57,7 +57,7 @@ export default function Page() {
return (
<Tabs defaultValue='basic'>
<TabsList>
<TabsList className='h-full flex-wrap'>
<TabsTrigger value='basic'>{t('emailBasicConfig')}</TabsTrigger>
<TabsTrigger value='template'>{t('emailTemplate')}</TabsTrigger>
<TabsTrigger value='logs'>{t('emailLogs')}</TabsTrigger>
@@ -86,24 +86,6 @@ export default function Page() {
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>{t('redirectUri')}</Label>
<p className='text-muted-foreground text-xs'>{t('redirectUriDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/facebook'
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
...data?.config,
redirect_url: value,
})
}
/>
</TableCell>
</TableRow>
</TableBody>
</Table>
);
@@ -85,24 +85,6 @@ export default function Page() {
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>{t('redirectUri')}</Label>
<p className='text-muted-foreground text-xs'>{t('redirectUriDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/github'
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
...data?.config,
redirect_url: value,
})
}
/>
</TableCell>
</TableRow>
</TableBody>
</Table>
);
@@ -86,24 +86,6 @@ export default function Page() {
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>{t('redirectUri')}</Label>
<p className='text-muted-foreground text-xs'>{t('redirectUriDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/google'
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
...data?.config,
redirect_url: value,
})
}
/>
</TableCell>
</TableRow>
</TableBody>
</Table>
);
@@ -0,0 +1,55 @@
'use client';
import { getAuthMethodConfig, updateAuthMethodConfig } from '@/services/admin/authMethod';
import { useQuery } from '@tanstack/react-query';
import { Label } from '@workspace/ui/components/label';
import { Switch } from '@workspace/ui/components/switch';
import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table';
import { useTranslations } from 'next-intl';
import { toast } from 'sonner';
export default function Page() {
const t = useTranslations('imei');
const { data, refetch } = useQuery({
queryKey: ['getAuthMethodConfig', 'imei'],
queryFn: async () => {
const { data } = await getAuthMethodConfig({
method: 'imei',
});
return data.data;
},
});
async function updateConfig(key: keyof API.UpdataAuthMethodConfigRequest, value: unknown) {
try {
await updateAuthMethodConfig({
...data,
[key]: value,
} as API.UpdataAuthMethodConfigRequest);
toast.success(t('saveSuccess'));
refetch();
} catch (error) {
toast.error(t('saveFailed'));
}
}
return (
<Table>
<TableBody>
<TableRow>
<TableCell>
<Label>{t('enable')}</Label>
<p className='text-muted-foreground text-xs'>{t('enableDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<Switch
checked={data?.enabled}
onCheckedChange={(checked) => updateConfig('enabled', checked)}
/>
</TableCell>
</TableRow>
</TableBody>
</Table>
);
}
@@ -86,24 +86,6 @@ export default function Page() {
/>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>{t('redirectUri')}</Label>
<p className='text-muted-foreground text-xs'>{t('redirectUriDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/telegram'
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
...data?.config,
redirect_url: value,
})
}
/>
</TableCell>
</TableRow>
</TableBody>
</Table>
);