Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/dashboard/src/components/contexts/create-context-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/src/components/primitives/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export const Editor = React.forwardRef<ReactCodeMirrorRef, EditorProps>(
},
ref
) => {
const safeValue = typeof value === 'string' ? value : String(value ?? '');
const onChangeRef = useDataRef(onChange);
const extensions = useMemo(
() => [...(extensionsProp ?? []), baseTheme({ multiline })],
Expand Down Expand Up @@ -373,7 +374,7 @@ export const Editor = React.forwardRef<ReactCodeMirrorRef, EditorProps>(
height="auto"
placeholder={placeholder}
basicSetup={basicSetup}
value={value}
value={safeValue}
onChange={onChangeCallback}
theme={theme}
{...restCodeMirrorProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/src/components/subscribers/subscriber-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions apps/dashboard/src/components/topics/create-topic-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
10 changes: 7 additions & 3 deletions apps/dashboard/src/pages/create-subscriber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading