From b686cd1e7da8c2b4da195577355b5687640de622 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Fri, 19 Jun 2026 20:48:44 +0330 Subject: [PATCH] feat: implement template editing functionality and revert approved templates to draft status --- assets/admin/pages/SmsPage.tsx | 61 ++++++++++++++++++++++++++-- src/Sms/Controller/SmsController.php | 10 +++-- src/Sms/Entity/SmsTemplate.php | 2 + 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/assets/admin/pages/SmsPage.tsx b/assets/admin/pages/SmsPage.tsx index aa474971..9fcd5576 100644 --- a/assets/admin/pages/SmsPage.tsx +++ b/assets/admin/pages/SmsPage.tsx @@ -58,6 +58,9 @@ export default function SmsPage() { const [tagFilter, setTagFilter] = useState(''); const [editMsg, setEditMsg] = useState(null); const [editBody, setEditBody] = useState(''); + const [editTemplate, setEditTemplate] = useState(null); + const [editTplName, setEditTplName] = useState(''); + const [editTplBody, setEditTplBody] = useState(''); const limit = 15; const sampleTemplatesQuery = useQuery({ @@ -119,6 +122,17 @@ export default function SmsPage() { onError: (err: Error) => toast.error(err.message), }); + const updateTemplateMut = useMutation({ + mutationFn: ({ uuid, name, body }: { uuid: string; name: string; body: string }) => + api.patch>(`/api/v1/sms/template/${uuid}`, { name, body }), + onSuccess: () => { + toast.success('قالب ویرایش شد'); + setEditTemplate(null); + qc.invalidateQueries({ queryKey: ['sms-samples'] }); + }, + onError: (err: Error) => toast.error(err.message), + }); + const approveMutation = useMutation({ mutationFn: (t: SmsTemplate) => api.post>(`/api/v1/admin/sms/template/${t.uuid}/approve`, {}), @@ -292,9 +306,17 @@ export default function SmsPage() { loading={sampleTemplatesQuery.isLoading} emptyMessage="هیچ قالبی یافت نشد" actions={(t) => ( - + <> + + + )} /> + setEditTemplate(null)} + footer={ + <> + + + + } + > +
+ + setEditTplName(e.target.value)} /> +
+
+ +