@ludo.ninja/components 2.3.22 → 2.3.24

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.
@@ -0,0 +1,10 @@
1
+ import { alertTypeProps } from "../../system/Alert/type";
2
+ import { ApolloError } from "@apollo/client";
3
+ export declare enum ServerErrorType {
4
+ BAD_REQUEST = "BAD_REQUEST",
5
+ UNAUTHORIZED = "UNAUTHORIZED",
6
+ FORBIDDEN = "FORBIDDEN",
7
+ NOT_FOUND = "NOT_FOUND",
8
+ INTERNAL_ERROR = "INTERNAL_ERROR"
9
+ }
10
+ export declare const getErrorAlertProps: (error: ApolloError) => alertTypeProps | null;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getErrorAlertProps = exports.ServerErrorType = void 0;
4
+ const type_1 = require("../../system/Alert/type");
5
+ const env_1 = require("../env");
6
+ var ServerErrorType;
7
+ (function (ServerErrorType) {
8
+ ServerErrorType["BAD_REQUEST"] = "BAD_REQUEST";
9
+ ServerErrorType["UNAUTHORIZED"] = "UNAUTHORIZED";
10
+ ServerErrorType["FORBIDDEN"] = "FORBIDDEN";
11
+ ServerErrorType["NOT_FOUND"] = "NOT_FOUND";
12
+ ServerErrorType["INTERNAL_ERROR"] = "INTERNAL_ERROR";
13
+ })(ServerErrorType || (exports.ServerErrorType = ServerErrorType = {}));
14
+ const getErrorAlertProps = (error) => {
15
+ const errorExtensions = error.cause?.extensions;
16
+ switch (errorExtensions?.classification) {
17
+ case ServerErrorType.BAD_REQUEST:
18
+ case ServerErrorType.UNAUTHORIZED:
19
+ case ServerErrorType.FORBIDDEN:
20
+ case ServerErrorType.NOT_FOUND:
21
+ return {
22
+ type: type_1.alertVariants.warning,
23
+ caption: error.cause?.message || error.message,
24
+ };
25
+ case ServerErrorType.INTERNAL_ERROR:
26
+ default:
27
+ return !(0, env_1.isProdFromEnvForServer)() ? {
28
+ type: type_1.alertVariants.error,
29
+ caption: error.cause?.message || error.message,
30
+ } : null;
31
+ }
32
+ };
33
+ exports.getErrorAlertProps = getErrorAlertProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",