feat(admin): adapt new config system (#11360)

feat(server): add test mail api

feat(admin): adapt new config system
This commit is contained in:
forehalo
2025-04-01 15:00:10 +00:00
parent 8427293d36
commit dad858014f
29 changed files with 718 additions and 400 deletions
@@ -0,0 +1,32 @@
import { Button } from '@affine/admin/components/ui/button';
import { useMutation } from '@affine/admin/use-mutation';
import { notify } from '@affine/component';
import type { UserFriendlyError } from '@affine/error';
import { sendTestEmailMutation } from '@affine/graphql';
import { useCallback } from 'react';
import type { AppConfig } from '../config';
export function SendTestEmail({ appConfig }: { appConfig: AppConfig }) {
const { trigger } = useMutation({
mutation: sendTestEmailMutation,
});
const onClick = useCallback(() => {
trigger(appConfig.mailer.SMTP)
.then(() => {
notify.success({
title: 'Test email sent',
message: 'The test email has been successfully sent.',
});
})
.catch((err: UserFriendlyError) => {
notify.error({
title: 'Failed to send test email',
message: err.message,
});
});
}, [appConfig, trigger]);
return <Button onClick={onClick}>Send Test Email</Button>;
}