import { Button, Dialog, FormContainer, FormItem, Input, Notification, toast, } from '@/components/ui' import { postMyNotificationByNotificationRuleId } from '@/services/notification.service' import { useLocalization } from '@/utils/hooks/useLocalization' import { Field, Form, Formik, FormikHelpers } from 'formik' import { useState } from 'react' import * as Yup from 'yup' export interface NotificationDto { id: string message: string } const scheme = Yup.object().shape({ id: Yup.string().required(), message: Yup.string().required(), }) function CreateNotification({ open, onDialogClose, id, }: { open: boolean onDialogClose: () => void id: string }) { const { translate } = useLocalization() const [loading, setLoading] = useState(true) const handleSubmit = async ( values: NotificationDto, { setSubmitting }: FormikHelpers, ) => { if (!id) { return } setLoading(true) setSubmitting(true) try { await postMyNotificationByNotificationRuleId({ id, message: values.message }) toast.push( {translate('::Kaydet')} , { placement: 'top-end', }, ) onDialogClose() } catch (error) { toast.push( {'Hata'} , { placement: 'top-end', }, ) } finally { setLoading(false) setSubmitting(false) } } return (
{id}
{({ touched, errors, values, isSubmitting }) => { return (
) }}
) } export default CreateNotification