import { Button } from 'react-daisyui'; import { useTranslation } from 'next-i18next'; import type { SAMLFederationApp } from '../types'; import { useFormik } from 'formik'; import { defaultHeaders } from '../utils'; import { Card } from '../shared'; type Branding = Pick; export const EditBranding = ({ app, urls, onUpdate, onError, }: { app: SAMLFederationApp; urls: { patch: string }; onUpdate?: (data: SAMLFederationApp) => void; onError?: (error: Error) => void; }) => { const { t } = useTranslation('common'); const formik = useFormik({ enableReinitialize: true, initialValues: { logoUrl: app.logoUrl, faviconUrl: app.faviconUrl, primaryColor: app.primaryColor || '#25c2a0', }, onSubmit: async (values) => { const rawResponse = await fetch(urls.patch, { method: 'PATCH', body: JSON.stringify({ ...values, id: app.id }), headers: defaultHeaders, }); const response = await rawResponse.json(); if (rawResponse.ok) { onUpdate?.(response.data); } else { onError?.(response.error); } }, }); return (
{t('bui-fs-branding-title')} {t('bui-fs-branding-desc')}
); };