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>
);
@@ -28,11 +28,10 @@ export default function UserSubscription({ userId }: { userId: number }) {
trigger={t('add')}
title={t('createSubscription')}
loading={loading}
userId={userId}
onSubmit={async (values) => {
setLoading(true);
await createUserSubscribe({
user_id: userId,
user_id: Number(userId),
...values,
});
toast.success(t('createSuccess'));
@@ -121,12 +120,11 @@ export default function UserSubscription({ userId }: { userId: number }) {
trigger={t('edit')}
title={t('editSubscription')}
loading={loading}
userId={userId}
initialData={row}
onSubmit={async (values) => {
setLoading(true);
await updateUserSubscribe({
user_id: userId,
user_id: Number(userId),
user_subscribe_id: row.id,
...values,
});
@@ -35,7 +35,6 @@ interface Props {
trigger: ReactNode;
title: string;
loading?: boolean;
userId: number;
initialData?: API.UserSubscribe;
onSubmit: (values: any) => Promise<boolean>;
}
@@ -48,21 +47,13 @@ const formSchema = z.object({
expired_at: z.number().nullish().optional(),
});
export function SubscriptionForm({
trigger,
title,
loading,
userId,
initialData,
onSubmit,
}: Props) {
export function SubscriptionForm({ trigger, title, loading, initialData, onSubmit }: Props) {
const t = useTranslations('user');
const [open, setOpen] = useState(false);
const form = useForm({
resolver: zodResolver(formSchema),
defaultValues: {
user_id: userId,
subscribe_id: initialData?.subscribe_id || 0,
traffic: initialData?.traffic || 0,
upload: initialData?.upload || 0,
+1 -5
View File
@@ -80,11 +80,7 @@ export default function Page() {
const method = row.original.auth_methods?.[0];
return (
<div>
<Badge
variant={method?.verified ? 'default' : 'destructive'}
className='mr-1 uppercase'
title={method?.verified ? t('verified') : ''}
>
<Badge className='mr-1 uppercase' title={method?.verified ? t('verified') : ''}>
{method?.auth_type}
</Badge>
{method?.auth_identifier}