@carlonicora/nextjs-jsonapi 6.23.0 → 6.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BlockNoteEditor-UO4ZRCUM.mjs → BlockNoteEditor-ENDOVTAW.mjs} +2 -2
- package/dist/{BlockNoteEditor-PPRML5CO.js → BlockNoteEditor-MONT74RQ.js} +9 -9
- package/dist/{BlockNoteEditor-PPRML5CO.js.map → BlockNoteEditor-MONT74RQ.js.map} +1 -1
- package/dist/billing/index.js +378 -378
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-R5722NLL.js → chunk-BDWV4KYR.js} +312 -309
- package/dist/chunk-BDWV4KYR.js.map +1 -0
- package/dist/{chunk-HP6DT6K3.mjs → chunk-OZADFYE7.mjs} +5 -2
- package/dist/chunk-OZADFYE7.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/forms/EditorSheet.d.ts +6 -1
- package/dist/components/forms/EditorSheet.d.ts.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/index.mjs +1 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/email-automations/index.js +78 -78
- package/dist/email-automations/index.mjs +1 -1
- package/dist/features/analytics/index.js +107 -107
- package/dist/features/analytics/index.mjs +1 -1
- package/dist/features/blog/index.js +93 -93
- package/dist/features/blog/index.mjs +1 -1
- package/dist/features/help/index.js +31 -31
- package/dist/features/help/index.mjs +1 -1
- package/dist/features/tokenusage/index.js +102 -102
- package/dist/features/tokenusage/index.mjs +1 -1
- package/package.json +1 -1
- package/src/components/forms/EditorSheet.tsx +8 -0
- package/src/components/forms/__tests__/EditorSheet.spec.tsx +30 -0
- package/dist/chunk-HP6DT6K3.mjs.map +0 -1
- package/dist/chunk-R5722NLL.js.map +0 -1
- /package/dist/{BlockNoteEditor-UO4ZRCUM.mjs.map → BlockNoteEditor-ENDOVTAW.mjs.map} +0 -0
|
@@ -93,6 +93,11 @@ export type EditorSheetProps<T extends FieldValues> = {
|
|
|
93
93
|
* sheet stays open with the form unchanged. Use it for a last confirmation
|
|
94
94
|
* (e.g. "this information will be deleted") that must not close the sheet. */
|
|
95
95
|
onBeforeSubmit?: (values: T) => Promise<boolean> | boolean;
|
|
96
|
+
/** Optional. Called when `onSubmit` throws. Return `true` when the caller
|
|
97
|
+
* showed its own message for that error: the generic "could not save" toast
|
|
98
|
+
* is then skipped. Either way the sheet stays open with the user's input.
|
|
99
|
+
* Omitted, every error shows the generic toast (the default). */
|
|
100
|
+
onSubmitError?: (error: unknown) => boolean;
|
|
96
101
|
onReset: () => T;
|
|
97
102
|
isFormDirty?: () => boolean;
|
|
98
103
|
|
|
@@ -150,6 +155,7 @@ export function EditorSheet<T extends FieldValues>({
|
|
|
150
155
|
form,
|
|
151
156
|
onSubmit,
|
|
152
157
|
onBeforeSubmit,
|
|
158
|
+
onSubmitError,
|
|
153
159
|
onReset,
|
|
154
160
|
isFormDirty: isFormDirtyProp,
|
|
155
161
|
entityType,
|
|
@@ -250,6 +256,7 @@ export function EditorSheet<T extends FieldValues>({
|
|
|
250
256
|
}
|
|
251
257
|
}
|
|
252
258
|
} catch (error) {
|
|
259
|
+
if (onSubmitError?.(error)) return;
|
|
253
260
|
errorToast({
|
|
254
261
|
title: isEdit ? t("generic.errors.update") : t("generic.errors.create"),
|
|
255
262
|
error,
|
|
@@ -259,6 +266,7 @@ export function EditorSheet<T extends FieldValues>({
|
|
|
259
266
|
[
|
|
260
267
|
onSubmit,
|
|
261
268
|
onBeforeSubmit,
|
|
269
|
+
onSubmitError,
|
|
262
270
|
setOpen,
|
|
263
271
|
onSuccess,
|
|
264
272
|
onSaved,
|
|
@@ -248,6 +248,36 @@ describe("EditorSheet", () => {
|
|
|
248
248
|
error,
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
it("skips the generic error toast when onSubmitError handles the error", async () => {
|
|
253
|
+
const { errorToast: mockErrorToast } = await import("../../errors/errorToast");
|
|
254
|
+
vi.mocked(mockErrorToast).mockClear();
|
|
255
|
+
const error = new Error("402:TRIAL_START_FAILED");
|
|
256
|
+
const onSubmit = vi.fn().mockRejectedValue(error);
|
|
257
|
+
const onSubmitError = vi.fn().mockReturnValue(true);
|
|
258
|
+
render(<TestEditor dialogOpen={true} onSubmit={onSubmit} onSubmitError={onSubmitError} />);
|
|
259
|
+
|
|
260
|
+
await userEvent.type(screen.getByTestId("name-input"), "Test Name");
|
|
261
|
+
await userEvent.click(screen.getByTestId("modal-button-create"));
|
|
262
|
+
|
|
263
|
+
expect(onSubmitError).toHaveBeenCalledWith(error);
|
|
264
|
+
expect(mockErrorToast).not.toHaveBeenCalled();
|
|
265
|
+
expect(screen.getByTestId("name-input")).toHaveValue("Test Name");
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("still shows the generic error toast when onSubmitError does not handle the error", async () => {
|
|
269
|
+
const { errorToast: mockErrorToast } = await import("../../errors/errorToast");
|
|
270
|
+
vi.mocked(mockErrorToast).mockClear();
|
|
271
|
+
const error = new Error("Network error");
|
|
272
|
+
const onSubmit = vi.fn().mockRejectedValue(error);
|
|
273
|
+
const onSubmitError = vi.fn().mockReturnValue(false);
|
|
274
|
+
render(<TestEditor dialogOpen={true} onSubmit={onSubmit} onSubmitError={onSubmitError} />);
|
|
275
|
+
|
|
276
|
+
await userEvent.type(screen.getByTestId("name-input"), "Test Name");
|
|
277
|
+
await userEvent.click(screen.getByTestId("modal-button-create"));
|
|
278
|
+
|
|
279
|
+
expect(mockErrorToast).toHaveBeenCalledWith({ title: "generic.errors.create", error });
|
|
280
|
+
});
|
|
251
281
|
});
|
|
252
282
|
|
|
253
283
|
describe("onBeforeSubmit", () => {
|