'use client'; import { getOAuthByPlatform, 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 { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; import { useTranslations } from 'next-intl'; import { toast } from 'sonner'; export default function Page() { const t = useTranslations('github'); const { data, refetch } = useQuery({ queryKey: ['getOAuthByPlatform', 'github'], queryFn: async () => { const { data } = await getOAuthByPlatform({ platform: 'github', }); return data.data; }, }); async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) { try { await updateOAuthConfig({ ...data, [key]: value, } as API.UpdateOAuthConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { toast.error(t('saveFailed')); } } return (

{t('enableDescription')}

updateConfig('enabled', checked)} />

{t('clientIdDescription')}

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

{t('clientSecretDescription')}

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

{t('redirectUriDescription')}

updateConfig('redirect', value)} />
); }