'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 { 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: ['getAuthMethodConfig', 'apple'], queryFn: async () => { const { data } = await getAuthMethodConfig({ method: 'apple', }); return data.data; }, }); async function updateConfig(key: keyof API.UpdateAuthMethodConfigRequest, value: unknown) { try { await updateAuthMethodConfig({ ...data, [key]: value, } as API.UpdateAuthMethodConfigRequest); toast.success(t('saveSuccess')); refetch(); } catch (error) { toast.error(t('saveFailed')); } } return (

{t('enableDescription')}

updateConfig('enabled', checked)} />

{t('teamIdDescription')}

{ updateConfig('config', { ...data?.config, team_id: value, }); }} />

{t('keyIdDescription')}

{ updateConfig('config', { ...data?.config, key_id: value, }); }} />

{t('clientIdDescription')}

{ updateConfig('config', { ...data?.config, client_id: value, }); }} />

{t('clientSecretDescription')}