diff --git a/apps/dashboard/src/components/contexts/create-context-form.tsx b/apps/dashboard/src/components/contexts/create-context-form.tsx index 19d5d26c8ec..c0a996973d6 100644 --- a/apps/dashboard/src/components/contexts/create-context-form.tsx +++ b/apps/dashboard/src/components/contexts/create-context-form.tsx @@ -92,11 +92,15 @@ export const CreateContextForm = (props: CreateContextFormProps) => { const parsedData = formData.data ? JSON.parse(formData.data) : {}; - await createContext({ - type: formData.type.trim(), - id: formData.id.trim(), - ...(parsedData && Object.keys(parsedData).length > 0 ? { data: parsedData } : {}), - }); + try { + await createContext({ + type: formData.type.trim(), + id: formData.id.trim(), + ...(parsedData && Object.keys(parsedData).length > 0 ? { data: parsedData } : {}), + }); + } catch { + // errors are handled by the mutation's onError callback + } }; return ( diff --git a/apps/dashboard/src/components/primitives/editor.tsx b/apps/dashboard/src/components/primitives/editor.tsx index edec0ec3ccb..62da8646a6a 100644 --- a/apps/dashboard/src/components/primitives/editor.tsx +++ b/apps/dashboard/src/components/primitives/editor.tsx @@ -315,6 +315,7 @@ export const Editor = React.forwardRef( }, ref ) => { + const safeValue = typeof value === 'string' ? value : String(value ?? ''); const onChangeRef = useDataRef(onChange); const extensions = useMemo( () => [...(extensionsProp ?? []), baseTheme({ multiline })], @@ -373,7 +374,7 @@ export const Editor = React.forwardRef( height="auto" placeholder={placeholder} basicSetup={basicSetup} - value={value} + value={safeValue} onChange={onChangeCallback} theme={theme} {...restCodeMirrorProps} diff --git a/apps/dashboard/src/components/subscribers/subscriber-overview-form.tsx b/apps/dashboard/src/components/subscribers/subscriber-overview-form.tsx index 5f78c783c9a..4d5f38c33ba 100644 --- a/apps/dashboard/src/components/subscribers/subscriber-overview-form.tsx +++ b/apps/dashboard/src/components/subscribers/subscriber-overview-form.tsx @@ -455,8 +455,12 @@ export function SubscriberOverviewForm(props: SubscriberOverviewFormProps) { open={isDeleteModalOpen} onOpenChange={setIsDeleteModalOpen} onConfirm={async () => { - await deleteSubscriber({ subscriberId: subscriber.subscriberId }); - setIsDeleteModalOpen(false); + try { + await deleteSubscriber({ subscriberId: subscriber.subscriberId }); + setIsDeleteModalOpen(false); + } catch { + // errors are handled by the mutation's onError callback + } }} title="Delete subscriber" description={ diff --git a/apps/dashboard/src/components/subscribers/subscriber-row.tsx b/apps/dashboard/src/components/subscribers/subscriber-row.tsx index fe84a69be77..99db167b06d 100644 --- a/apps/dashboard/src/components/subscribers/subscriber-row.tsx +++ b/apps/dashboard/src/components/subscribers/subscriber-row.tsx @@ -113,7 +113,12 @@ export const SubscriberRow = ({ subscriber, subscribersCount, firstTwoSubscriber }; const handleDeletion = async () => { - await deleteSubscriber({ subscriberId: subscriber.subscriberId }); + try { + await deleteSubscriber({ subscriberId: subscriber.subscriberId }); + } catch { + // errors are handled by the mutation's onError callback + return; + } setIsDeleteModalOpen(false); const hasSingleSubscriber = subscribersCount === 1; diff --git a/apps/dashboard/src/components/topics/create-topic-form.tsx b/apps/dashboard/src/components/topics/create-topic-form.tsx index a34586309c6..ea73692e543 100644 --- a/apps/dashboard/src/components/topics/create-topic-form.tsx +++ b/apps/dashboard/src/components/topics/create-topic-form.tsx @@ -109,12 +109,16 @@ export const CreateTopicForm = (props: CreateTopicFormProps) => { onSubmitStart(); } - await createTopic({ - topic: { - name: formData.name.trim(), - key: formData.key.trim(), - }, - }); + try { + await createTopic({ + topic: { + name: formData.name.trim(), + key: formData.key.trim(), + }, + }); + } catch { + // errors are handled by the mutation's onError callback + } }; return ( diff --git a/apps/dashboard/src/pages/create-subscriber.tsx b/apps/dashboard/src/pages/create-subscriber.tsx index 3154edc0c05..02ff894e2e9 100644 --- a/apps/dashboard/src/pages/create-subscriber.tsx +++ b/apps/dashboard/src/pages/create-subscriber.tsx @@ -85,9 +85,13 @@ export function CreateSubscriberPage() { }, {}); form.reset(formData); - await createSubscriber({ - subscriber: { ...dirtyPayload, subscriberId: formData.subscriberId }, - }); + try { + await createSubscriber({ + subscriber: { ...dirtyPayload, subscriberId: formData.subscriberId }, + }); + } catch { + // errors are handled by the mutation's onError callback + } }; return (