diff --git a/apps/admin/app/dashboard/auth-control/apple/page.tsx b/apps/admin/app/dashboard/auth-control/apple/page.tsx new file mode 100644 index 0000000..97cb5ff --- /dev/null +++ b/apps/admin/app/dashboard/auth-control/apple/page.tsx @@ -0,0 +1,130 @@ +'use client'; + +import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system'; +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 { Textarea } from '@workspace/ui/components/textarea'; +import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; +import { useTranslations } from 'next-intl'; +import { toast } from 'sonner'; + +export default function Page() { + const t = useTranslations('apple'); + + const { data, refetch } = useQuery({ + queryKey: ['getOAuthConfig', 'apple'], + queryFn: async () => { + const { data } = await getOAuthConfig(); + return data.data?.list.find((item) => item.platform === 'apple') as API.OAuthConfig; + }, + }); + + async function updateConfig(key: keyof API.OAuthConfig, value: unknown) { + if (data?.[key] === value) return; + try { + if (data?.id) { + await oAuthCreateConfig({ + ...data, + platform: 'apple', + [key]: value, + } as API.OAuthConfig); + } else { + await updateOAuthConfig({ + ...data, + [key]: value, + } as API.OAuthConfig); + } + toast.success(t('saveSuccess')); + refetch(); + } catch (error) { + toast.error(t('saveFailed')); + } + } + + return ( + + + + + +

{t('enableDescription')}

+
+ + updateConfig('enabled', checked)} + /> + +
+ + + +

{t('teamIdDescription')}

+
+ + updateConfig('team_id', value)} + /> + +
+ + + +

{t('clientIdDescription')}

+
+ + updateConfig('client_id', value)} + /> + +
+ + + +

{t('keyIdDescription')}

+
+ + updateConfig('key_id', value)} + /> + +
+ + + +

{t('clientSecretDescription')}

+
+ +