@campxdev/campx-web-utils 0.1.8 → 0.1.10

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/craco.config.js CHANGED
@@ -1,7 +1,4 @@
1
- const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
2
-
3
1
  const path = require("path");
4
- const deps = require("./package.json").dependencies;
5
2
  const { getLoader, loaderByName } = require("@craco/craco");
6
3
  const packages = [];
7
4
  packages.push(path.dirname(require.resolve("@campxdev/react-blueprint")));
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@campxdev/campx-web-utils",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "main": "./exports.ts",
5
5
  "private": false,
6
6
  "dependencies": {
7
- "@campxdev/react-blueprint": "^1.0.14",
7
+ "@campxdev/react-blueprint": "^1.0.16",
8
8
  "@mui/x-date-pickers": "^7.11.0",
9
9
  "@testing-library/jest-dom": "^5.14.1",
10
10
  "@testing-library/react": "^13.0.0",
@@ -1,7 +1,9 @@
1
- import { InternalServerError } from "@campxdev/react-blueprint/src/components/Assets/ErrorPages/InternalServerError";
2
- import { NoInterneConnection } from "@campxdev/react-blueprint/src/components/Assets/ErrorPages/NoInternetConnection";
3
- import { UnAuthorized } from "@campxdev/react-blueprint/src/components/Assets/ErrorPages/UnAuthorized";
4
- import { Button } from "@campxdev/react-blueprint/src/components/Input/Button/Button";
1
+ import {
2
+ Button,
3
+ InternalServerError,
4
+ NoInterneConnection,
5
+ UnAuthorized,
6
+ } from "@campxdev/react-blueprint";
5
7
  import { Alert, Box, styled } from "@mui/material";
6
8
  import Cookies from "js-cookie";
7
9
  import { ReactNode } from "react";
@@ -58,12 +58,12 @@ axios.interceptors.response.use(
58
58
  if (
59
59
  response.config.method &&
60
60
  ["put", "post", "delete", "patch"].includes(response.config.method) &&
61
- [200, 202].includes(response.status)
61
+ [200, 201, 202].includes(response.status)
62
62
  ) {
63
63
  SnackbarStore.update((s) => {
64
64
  s.open = true;
65
65
  s.message = response.data.message;
66
- s.variant = "success";
66
+ s.severity = "success";
67
67
  });
68
68
  }
69
69
 
@@ -74,7 +74,7 @@ axios.interceptors.response.use(
74
74
  SnackbarStore.update((s) => {
75
75
  s.open = true;
76
76
  s.message = err.response.data.message || "Bad Request";
77
- s.variant = "alert";
77
+ s.severity = "error";
78
78
  });
79
79
  }
80
80
 
@@ -1,11 +1,9 @@
1
- import { Snackbar } from "@campxdev/react-blueprint";
1
+ import { Severity, Snackbar } from "@campxdev/react-blueprint";
2
2
  import { Store } from "pullstate";
3
3
  import { createContext, ReactNode } from "react";
4
4
 
5
- type Variant = "success" | "info" | "warning" | "alert";
6
-
7
5
  interface SnackbarContextProps {
8
- showSnackbar: (message: string, variant?: Variant) => void;
6
+ showSnackbar: (message: string, severity?: Severity) => void;
9
7
  }
10
8
 
11
9
  const SnackbarContext = createContext<SnackbarContextProps | undefined>(
@@ -18,16 +16,16 @@ interface SnackbarProviderProps {
18
16
  export const SnackbarStore = new Store({
19
17
  open: false,
20
18
  message: "",
21
- variant: "success" as Variant,
19
+ severity: "success" as Severity,
22
20
  });
23
21
 
24
22
  export const SnackbarProvider = ({ children }: SnackbarProviderProps) => {
25
23
  const snackbar = SnackbarStore.useState((s) => s);
26
- const showSnackbar = (message: string, variant: Variant = "info") => {
24
+ const showSnackbar = (message: string, severity: Severity = "info") => {
27
25
  SnackbarStore.update((s) => {
28
26
  s.open = true;
29
27
  s.message = message;
30
- s.variant = variant;
28
+ s.severity = severity;
31
29
  });
32
30
  };
33
31
  return (
@@ -36,7 +34,7 @@ export const SnackbarProvider = ({ children }: SnackbarProviderProps) => {
36
34
  <Snackbar
37
35
  open={snackbar.open}
38
36
  message={snackbar.message}
39
- variant={snackbar.variant}
37
+ severity={snackbar.severity}
40
38
  autoHideDuration={1500}
41
39
  onClose={() => {
42
40
  SnackbarStore.update((s) => {