test
This commit is contained in:
1 parent
cac502573f
commit
806d7ae456
1 file changed
+8
-4
@@ -30,6 +30,7 @@ const NotificationsCreatePage = () => {
|
|||||||
|
|
||||||
const { post, loading: isSubmitting } = usePost<NotificationFormData, Notification>();
|
const { post, loading: isSubmitting } = usePost<NotificationFormData, Notification>();
|
||||||
const { patch, loading: isPatching } = usePatch<NotificationFormData, Notification>();
|
const { patch, loading: isPatching } = usePatch<NotificationFormData, Notification>();
|
||||||
|
const { post: testPost, loading: isTesting } = usePost<NotificationFormData, void>();
|
||||||
|
|
||||||
const { schema, defaults } = useNotificationForm({ data: existingNotification });
|
const { schema, defaults } = useNotificationForm({ data: existingNotification });
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ const NotificationsCreatePage = () => {
|
|||||||
defaultValues: defaults,
|
defaultValues: defaults,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { control, watch, reset, handleSubmit, clearErrors } = form;
|
const { control, watch, reset, handleSubmit, clearErrors, trigger, getValues } = form;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reset(defaults);
|
reset(defaults);
|
||||||
@@ -84,8 +85,11 @@ const NotificationsCreatePage = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTest = () => {
|
const handleTest = async () => {
|
||||||
console.log("Test notification");
|
const isValid = await trigger();
|
||||||
|
if (!isValid) return;
|
||||||
|
const data = getValues();
|
||||||
|
await testPost("/notifications/test", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -236,7 +240,7 @@ const NotificationsCreatePage = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={handleTest}
|
onClick={handleTest}
|
||||||
loading={false}
|
loading={isTesting}
|
||||||
>
|
>
|
||||||
{t("common.buttons.test")}
|
{t("common.buttons.test")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in new issue
Block a user