rankrunners-cms 0.0.36 → 0.0.38

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rankrunners-cms",
3
3
  "type": "module",
4
- "version": "0.0.36",
4
+ "version": "0.0.38",
5
5
  "peerDependencies": {
6
6
  "@puckeditor/core": "^0.21.1",
7
7
  "@tanstack/react-router": "^1.166.7",
@@ -10,6 +10,7 @@ import {
10
10
  type SendFormFillResult,
11
11
  SendFormFillResultType,
12
12
  } from "../types/form-fills";
13
+ import { fromValibot } from "src/libs/valibot-serialize";
13
14
 
14
15
  export type SendFormFillArgs<
15
16
  A,
@@ -52,7 +53,7 @@ export const sendFormFill = async <
52
53
  type: args.type,
53
54
  data: formToSend.output as Record<string, string>,
54
55
  schema: {
55
- schema: JSON.stringify(args.schema),
56
+ schema: JSON.stringify(fromValibot(args.schema)),
56
57
  fields: args.fieldNames,
57
58
  },
58
59
  captchaToken: args.captchaToken,
@@ -85,6 +86,10 @@ export const sendFormFill = async <
85
86
  return { response: SendFormFillResultType.CaptchaError };
86
87
  }
87
88
  }
89
+ if (error instanceof TypeError) {
90
+ // fetch throws TypeError on network failure
91
+ return { response: SendFormFillResultType.NetworkError };
92
+ }
88
93
  return { response: SendFormFillResultType.UnknownError };
89
94
  }
90
95
  };
@@ -55,6 +55,7 @@ export enum SendFormFillResultType {
55
55
  Success = "success",
56
56
  ValidationError = "validation_error",
57
57
  CaptchaError = "captcha_error",
58
+ NetworkError = "network_error",
58
59
  InvalidResponse = "invalid_response",
59
60
  UnknownError = "unknown_error",
60
61
  }
@@ -69,6 +70,8 @@ export const formFillResultToMessage = (
69
70
  return "There was a validation error with your submission. Please check your input and try again.";
70
71
  case SendFormFillResultType.CaptchaError:
71
72
  return "Captcha verification failed. Please complete the captcha and try again.";
73
+ case SendFormFillResultType.NetworkError:
74
+ return "A network error occurred while submitting the form. Please check your internet connection and try again.";
72
75
  case SendFormFillResultType.InvalidResponse:
73
76
  return "An internal error occurred while submitting the form. Please call us instead!";
74
77
  case SendFormFillResultType.UnknownError: