@bluemarble/bm-components 1.4.2 → 1.6.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/index.d.mts +121 -49
- package/dist/index.d.ts +121 -49
- package/dist/index.js +428 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +458 -208
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -255,7 +255,7 @@ var require_react_is_development = __commonJS({
|
|
|
255
255
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
256
256
|
var Element = REACT_ELEMENT_TYPE;
|
|
257
257
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
258
|
-
var
|
|
258
|
+
var Fragment3 = REACT_FRAGMENT_TYPE;
|
|
259
259
|
var Lazy = REACT_LAZY_TYPE;
|
|
260
260
|
var Memo = REACT_MEMO_TYPE;
|
|
261
261
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -314,7 +314,7 @@ var require_react_is_development = __commonJS({
|
|
|
314
314
|
exports.ContextProvider = ContextProvider;
|
|
315
315
|
exports.Element = Element;
|
|
316
316
|
exports.ForwardRef = ForwardRef;
|
|
317
|
-
exports.Fragment =
|
|
317
|
+
exports.Fragment = Fragment3;
|
|
318
318
|
exports.Lazy = Lazy;
|
|
319
319
|
exports.Memo = Memo;
|
|
320
320
|
exports.Portal = Portal;
|
|
@@ -2404,7 +2404,7 @@ function createBox(options = {}) {
|
|
|
2404
2404
|
const BoxRoot = styled("div", {
|
|
2405
2405
|
shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
|
|
2406
2406
|
})(styleFunctionSx_default);
|
|
2407
|
-
const
|
|
2407
|
+
const Box7 = /* @__PURE__ */ React3.forwardRef(function Box8(inProps, ref) {
|
|
2408
2408
|
const theme = useTheme_default(defaultTheme);
|
|
2409
2409
|
const _extendSxProp = extendSxProp(inProps), {
|
|
2410
2410
|
className,
|
|
@@ -2417,7 +2417,7 @@ function createBox(options = {}) {
|
|
|
2417
2417
|
theme: themeId ? theme[themeId] || theme : theme
|
|
2418
2418
|
}, other));
|
|
2419
2419
|
});
|
|
2420
|
-
return
|
|
2420
|
+
return Box7;
|
|
2421
2421
|
}
|
|
2422
2422
|
|
|
2423
2423
|
// node_modules/@mui/utils/generateUtilityClass/generateUtilityClass.js
|
|
@@ -3702,6 +3702,7 @@ var TabPanel = (props) => {
|
|
|
3702
3702
|
// src/components/BaseGrid/index.tsx
|
|
3703
3703
|
import React20 from "react";
|
|
3704
3704
|
import {
|
|
3705
|
+
Box as Box4,
|
|
3705
3706
|
LinearProgress as LinearProgress2,
|
|
3706
3707
|
Paper as Paper2,
|
|
3707
3708
|
Table as Table2,
|
|
@@ -3817,7 +3818,6 @@ function BaseGrid({
|
|
|
3817
3818
|
tableBodyProps,
|
|
3818
3819
|
tableHeadProps,
|
|
3819
3820
|
tableProps,
|
|
3820
|
-
sortedDirection,
|
|
3821
3821
|
sortedBy,
|
|
3822
3822
|
onSortBy,
|
|
3823
3823
|
dense = true,
|
|
@@ -3825,6 +3825,8 @@ function BaseGrid({
|
|
|
3825
3825
|
bordered,
|
|
3826
3826
|
currentPage,
|
|
3827
3827
|
totalNumberOfPages,
|
|
3828
|
+
tableSortLabelProps,
|
|
3829
|
+
boxContainerProps,
|
|
3828
3830
|
onPageChange,
|
|
3829
3831
|
rowsPerPage,
|
|
3830
3832
|
setRowsPerPage,
|
|
@@ -3832,6 +3834,7 @@ function BaseGrid({
|
|
|
3832
3834
|
hideFooter,
|
|
3833
3835
|
prependColumn,
|
|
3834
3836
|
appendColumn,
|
|
3837
|
+
loadingColSpan,
|
|
3835
3838
|
isLoading
|
|
3836
3839
|
}) {
|
|
3837
3840
|
return /* @__PURE__ */ React20.createElement(
|
|
@@ -3840,34 +3843,52 @@ function BaseGrid({
|
|
|
3840
3843
|
sx: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, styles.rowGap(dense)), styles.bordered(bordered)), styles.striped(striped)), styles.lastRowBorder(hideFooter)), paperProps == null ? void 0 : paperProps.sx)
|
|
3841
3844
|
}),
|
|
3842
3845
|
/* @__PURE__ */ React20.createElement(
|
|
3843
|
-
|
|
3844
|
-
__spreadProps(__spreadValues({
|
|
3845
|
-
|
|
3846
|
-
stickyHeader: true
|
|
3847
|
-
}, tableProps), {
|
|
3848
|
-
sx: __spreadValues({}, tableProps == null ? void 0 : tableProps.sx)
|
|
3846
|
+
Box4,
|
|
3847
|
+
__spreadProps(__spreadValues({}, boxContainerProps), {
|
|
3848
|
+
sx: __spreadValues({ overflowX: "auto" }, boxContainerProps == null ? void 0 : boxContainerProps.sx)
|
|
3849
3849
|
}),
|
|
3850
|
-
/* @__PURE__ */ React20.createElement(
|
|
3851
|
-
|
|
3852
|
-
{
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
},
|
|
3859
|
-
|
|
3860
|
-
|
|
3850
|
+
/* @__PURE__ */ React20.createElement(
|
|
3851
|
+
Table2,
|
|
3852
|
+
__spreadProps(__spreadValues({
|
|
3853
|
+
size: "small",
|
|
3854
|
+
stickyHeader: true
|
|
3855
|
+
}, tableProps), {
|
|
3856
|
+
sx: __spreadValues({}, tableProps == null ? void 0 : tableProps.sx)
|
|
3857
|
+
}),
|
|
3858
|
+
/* @__PURE__ */ React20.createElement(TableHead2, __spreadValues({}, tableHeadProps), /* @__PURE__ */ React20.createElement(TableRow3, null, prependColumn, columns.map((column) => {
|
|
3859
|
+
var _a;
|
|
3860
|
+
return /* @__PURE__ */ React20.createElement(
|
|
3861
|
+
TableCell4,
|
|
3862
|
+
{
|
|
3863
|
+
key: column.name,
|
|
3864
|
+
padding: dense ? "none" : "normal",
|
|
3865
|
+
sx: __spreadValues({
|
|
3866
|
+
pl: 2
|
|
3867
|
+
}, column == null ? void 0 : column.sx)
|
|
3868
|
+
},
|
|
3869
|
+
column.children ? column.children : /* @__PURE__ */ React20.createElement(
|
|
3870
|
+
TableSortLabel2,
|
|
3871
|
+
__spreadProps(__spreadValues({
|
|
3872
|
+
active: sortedBy.some((p) => p.prop === column.name),
|
|
3873
|
+
direction: ((_a = sortedBy.find((p) => p.prop === column.name)) == null ? void 0 : _a.direction) || "desc",
|
|
3874
|
+
onClick: () => onSortBy(column.name),
|
|
3875
|
+
disabled: column.canSort === false
|
|
3876
|
+
}, tableSortLabelProps), {
|
|
3877
|
+
sx: __spreadValues({}, tableSortLabelProps == null ? void 0 : tableSortLabelProps.sx)
|
|
3878
|
+
}),
|
|
3879
|
+
column.label
|
|
3880
|
+
)
|
|
3881
|
+
);
|
|
3882
|
+
}), appendColumn), isLoading && /* @__PURE__ */ React20.createElement(TableRow3, null, /* @__PURE__ */ React20.createElement(
|
|
3883
|
+
TableCell4,
|
|
3861
3884
|
{
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
onClick: () => onSortBy(column.name),
|
|
3865
|
-
disabled: column.canSort === false
|
|
3885
|
+
colSpan: loadingColSpan || columns.length,
|
|
3886
|
+
sx: { p: 0, border: "none" }
|
|
3866
3887
|
},
|
|
3867
|
-
|
|
3868
|
-
)
|
|
3869
|
-
|
|
3870
|
-
|
|
3888
|
+
/* @__PURE__ */ React20.createElement(LinearProgress2, null)
|
|
3889
|
+
))),
|
|
3890
|
+
/* @__PURE__ */ React20.createElement(TableBody2, __spreadValues({}, tableBodyProps), children)
|
|
3891
|
+
)
|
|
3871
3892
|
),
|
|
3872
3893
|
!hideFooter && /* @__PURE__ */ React20.createElement(
|
|
3873
3894
|
GridPagination,
|
|
@@ -3884,16 +3905,28 @@ function BaseGrid({
|
|
|
3884
3905
|
);
|
|
3885
3906
|
}
|
|
3886
3907
|
|
|
3887
|
-
// src/components/
|
|
3908
|
+
// src/components/BaseGrid/BaseGridAutoRows.tsx
|
|
3888
3909
|
import React21 from "react";
|
|
3910
|
+
import { Fragment as Fragment2 } from "react";
|
|
3911
|
+
import { TableCell as TableCell5, TableRow as TableRow4 } from "@mui/material";
|
|
3912
|
+
function BaseGridAutoRows({
|
|
3913
|
+
data,
|
|
3914
|
+
columns,
|
|
3915
|
+
rowKey
|
|
3916
|
+
}) {
|
|
3917
|
+
return /* @__PURE__ */ React21.createElement(Fragment2, null, data.map((row) => /* @__PURE__ */ React21.createElement(TableRow4, { key: row[rowKey] }, columns.map((column) => /* @__PURE__ */ React21.createElement(TableCell5, { key: column.name }, row[column.name])))));
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
// src/components/Modal/index.tsx
|
|
3921
|
+
import React22 from "react";
|
|
3889
3922
|
import {
|
|
3890
|
-
Box as
|
|
3923
|
+
Box as Box5,
|
|
3891
3924
|
Modal as MuiModal
|
|
3892
3925
|
} from "@mui/material";
|
|
3893
3926
|
var Modal = (_a) => {
|
|
3894
3927
|
var _b = _a, { open, onClose } = _b, rest = __objRest(_b, ["open", "onClose"]);
|
|
3895
|
-
return /* @__PURE__ */
|
|
3896
|
-
|
|
3928
|
+
return /* @__PURE__ */ React22.createElement(MuiModal, __spreadValues({ open, onClose }, rest), /* @__PURE__ */ React22.createElement(
|
|
3929
|
+
Box5,
|
|
3897
3930
|
{
|
|
3898
3931
|
sx: {
|
|
3899
3932
|
outline: "none",
|
|
@@ -3905,7 +3938,7 @@ var Modal = (_a) => {
|
|
|
3905
3938
|
borderRadius: 1
|
|
3906
3939
|
}
|
|
3907
3940
|
},
|
|
3908
|
-
/* @__PURE__ */
|
|
3941
|
+
/* @__PURE__ */ React22.createElement(React22.Fragment, null, rest.children)
|
|
3909
3942
|
));
|
|
3910
3943
|
};
|
|
3911
3944
|
|
|
@@ -3918,9 +3951,9 @@ function GetInputLabel(columns) {
|
|
|
3918
3951
|
}
|
|
3919
3952
|
|
|
3920
3953
|
// src/components/Dialog/index.tsx
|
|
3921
|
-
import
|
|
3954
|
+
import React23 from "react";
|
|
3922
3955
|
import {
|
|
3923
|
-
Box as
|
|
3956
|
+
Box as Box6,
|
|
3924
3957
|
Dialog as DefaultDialog,
|
|
3925
3958
|
DialogContentText,
|
|
3926
3959
|
DialogActions,
|
|
@@ -3942,8 +3975,8 @@ var Dialog = (_a) => {
|
|
|
3942
3975
|
"body",
|
|
3943
3976
|
"options"
|
|
3944
3977
|
]);
|
|
3945
|
-
return /* @__PURE__ */
|
|
3946
|
-
return /* @__PURE__ */
|
|
3978
|
+
return /* @__PURE__ */ React23.createElement(DefaultDialog, __spreadValues({ open }, rest), /* @__PURE__ */ React23.createElement(Box6, { sx: { p: 2 } }, /* @__PURE__ */ React23.createElement(DialogTitle, { sx: { fontWeight: "bold" } }, title), /* @__PURE__ */ React23.createElement(DialogContentText, { sx: { px: "10px", textAlign: "center", mb: 2 } }, body), /* @__PURE__ */ React23.createElement(DialogActions, null, options.map((option, index) => {
|
|
3979
|
+
return /* @__PURE__ */ React23.createElement(
|
|
3947
3980
|
Button3,
|
|
3948
3981
|
{
|
|
3949
3982
|
key: index,
|
|
@@ -3956,7 +3989,7 @@ var Dialog = (_a) => {
|
|
|
3956
3989
|
disableElevation: true,
|
|
3957
3990
|
disabled: loading
|
|
3958
3991
|
},
|
|
3959
|
-
loading && option.focus ? /* @__PURE__ */
|
|
3992
|
+
loading && option.focus ? /* @__PURE__ */ React23.createElement(CircularProgress3, { size: 25, color: "inherit" }) : /* @__PURE__ */ React23.createElement(React23.Fragment, null, option.label)
|
|
3960
3993
|
);
|
|
3961
3994
|
}))));
|
|
3962
3995
|
};
|
|
@@ -4063,21 +4096,21 @@ var ApiHelper = class _ApiHelper {
|
|
|
4063
4096
|
};
|
|
4064
4097
|
|
|
4065
4098
|
// src/hooks/useFormHelper.ts
|
|
4066
|
-
import { useContext as useContext3, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
4099
|
+
import { useCallback as useCallback3, useContext as useContext3, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
4067
4100
|
|
|
4068
4101
|
// src/hooks/useAlert.ts
|
|
4069
4102
|
import { useContext as useContext2 } from "react";
|
|
4070
4103
|
|
|
4071
4104
|
// src/contexts/AlertContext.tsx
|
|
4072
|
-
import
|
|
4105
|
+
import React25, { useCallback } from "react";
|
|
4073
4106
|
import { createContext, useState as useState3 } from "react";
|
|
4074
4107
|
|
|
4075
4108
|
// src/components/Toast/index.tsx
|
|
4076
|
-
import
|
|
4109
|
+
import React24 from "react";
|
|
4077
4110
|
import { Alert, IconButton as IconButton4, Snackbar } from "@mui/material";
|
|
4078
4111
|
import { MdClose as MdClose2 } from "react-icons/md";
|
|
4079
4112
|
var Toast = ({ open, onClose, severity, message }) => {
|
|
4080
|
-
return /* @__PURE__ */
|
|
4113
|
+
return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(
|
|
4081
4114
|
Snackbar,
|
|
4082
4115
|
{
|
|
4083
4116
|
open,
|
|
@@ -4086,12 +4119,12 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4086
4119
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
4087
4120
|
sx: { zIndex: 99999999 }
|
|
4088
4121
|
},
|
|
4089
|
-
/* @__PURE__ */
|
|
4122
|
+
/* @__PURE__ */ React24.createElement(
|
|
4090
4123
|
Alert,
|
|
4091
4124
|
{
|
|
4092
4125
|
severity,
|
|
4093
4126
|
elevation: 2,
|
|
4094
|
-
action: /* @__PURE__ */
|
|
4127
|
+
action: /* @__PURE__ */ React24.createElement(
|
|
4095
4128
|
IconButton4,
|
|
4096
4129
|
{
|
|
4097
4130
|
"aria-label": "close",
|
|
@@ -4099,7 +4132,7 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4099
4132
|
size: "small",
|
|
4100
4133
|
onClick: onClose
|
|
4101
4134
|
},
|
|
4102
|
-
/* @__PURE__ */
|
|
4135
|
+
/* @__PURE__ */ React24.createElement(MdClose2, { fontSize: "inherit" })
|
|
4103
4136
|
)
|
|
4104
4137
|
},
|
|
4105
4138
|
message
|
|
@@ -4113,15 +4146,18 @@ var AlertProvider = ({ children }) => {
|
|
|
4113
4146
|
const [severity, setSeverity] = useState3("info");
|
|
4114
4147
|
const [message, setMessage] = useState3("");
|
|
4115
4148
|
const [isVisible, setIsVisible] = useState3(false);
|
|
4116
|
-
const createAlert = (
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4149
|
+
const createAlert = useCallback(
|
|
4150
|
+
(newMessage, severity2) => {
|
|
4151
|
+
setMessage(newMessage);
|
|
4152
|
+
setSeverity(severity2);
|
|
4153
|
+
setIsVisible(true);
|
|
4154
|
+
},
|
|
4155
|
+
[]
|
|
4156
|
+
);
|
|
4157
|
+
const onCloseToast = useCallback(() => {
|
|
4122
4158
|
setIsVisible(false);
|
|
4123
|
-
}
|
|
4124
|
-
return /* @__PURE__ */
|
|
4159
|
+
}, []);
|
|
4160
|
+
return /* @__PURE__ */ React25.createElement(AlertContext.Provider, { value: { createAlert } }, children, /* @__PURE__ */ React25.createElement(
|
|
4125
4161
|
Toast,
|
|
4126
4162
|
{
|
|
4127
4163
|
open: isVisible,
|
|
@@ -4138,25 +4174,25 @@ var useAlert = () => {
|
|
|
4138
4174
|
};
|
|
4139
4175
|
|
|
4140
4176
|
// src/hooks/useLoading.ts
|
|
4141
|
-
import { useState as useState4 } from "react";
|
|
4177
|
+
import { useCallback as useCallback2, useState as useState4 } from "react";
|
|
4142
4178
|
function useLoading() {
|
|
4143
4179
|
const [state, setState] = useState4([]);
|
|
4144
|
-
const isLoading = (prop) => state.includes(prop);
|
|
4145
|
-
const setLoading = (prop, remove) => {
|
|
4180
|
+
const isLoading = useCallback2((prop) => state.includes(prop), [state]);
|
|
4181
|
+
const setLoading = useCallback2((prop, remove) => {
|
|
4146
4182
|
if (remove)
|
|
4147
4183
|
setState((prevState) => prevState.filter((state2) => state2 !== prop));
|
|
4148
4184
|
else
|
|
4149
4185
|
setState((prevState) => [...prevState, prop]);
|
|
4150
|
-
};
|
|
4186
|
+
}, []);
|
|
4151
4187
|
return { isLoading, setLoading };
|
|
4152
4188
|
}
|
|
4153
4189
|
|
|
4154
4190
|
// src/contexts/FormHelperProvider.tsx
|
|
4155
|
-
import
|
|
4191
|
+
import React26 from "react";
|
|
4156
4192
|
import { createContext as createContext2 } from "react";
|
|
4157
4193
|
var FormHelperContext = createContext2({});
|
|
4158
4194
|
var FormHelperProvider = ({ formatErrorMessage, api, children }) => {
|
|
4159
|
-
return /* @__PURE__ */
|
|
4195
|
+
return /* @__PURE__ */ React26.createElement(FormHelperContext.Provider, { value: { formatErrorMessage, api } }, children);
|
|
4160
4196
|
};
|
|
4161
4197
|
|
|
4162
4198
|
// src/hooks/useFormHelper.ts
|
|
@@ -4167,59 +4203,68 @@ function useFormHelper() {
|
|
|
4167
4203
|
const { createAlert } = alertProps;
|
|
4168
4204
|
const { setLoading } = loadingProps;
|
|
4169
4205
|
const sourceRef = useRef3(new AbortController());
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4206
|
+
const onSubmitWrapper = useCallback3(
|
|
4207
|
+
(fn, { name }) => {
|
|
4208
|
+
return (fields, methods) => __async(this, null, function* () {
|
|
4209
|
+
const LOADING_NAME = name;
|
|
4210
|
+
setLoading(LOADING_NAME);
|
|
4211
|
+
try {
|
|
4212
|
+
yield fn(fields, methods);
|
|
4213
|
+
} catch (error) {
|
|
4214
|
+
errorHandler(error, methods.setErrors);
|
|
4215
|
+
} finally {
|
|
4216
|
+
setLoading(LOADING_NAME, true);
|
|
4217
|
+
}
|
|
4218
|
+
});
|
|
4219
|
+
},
|
|
4220
|
+
[setLoading]
|
|
4221
|
+
);
|
|
4222
|
+
const onRequestWrapper = useCallback3(
|
|
4223
|
+
(fn, { name }) => {
|
|
4224
|
+
return (...params) => __async(this, null, function* () {
|
|
4225
|
+
const LOADING_NAME = name;
|
|
4226
|
+
setLoading(LOADING_NAME);
|
|
4227
|
+
api.interceptors.request.use(
|
|
4228
|
+
(config) => {
|
|
4229
|
+
if (!config.signal && sourceRef.current && config.method === "get") {
|
|
4230
|
+
config.signal = sourceRef.current.signal;
|
|
4231
|
+
}
|
|
4232
|
+
return config;
|
|
4233
|
+
},
|
|
4234
|
+
(error) => {
|
|
4235
|
+
return Promise.reject(error);
|
|
4191
4236
|
}
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
return
|
|
4237
|
+
);
|
|
4238
|
+
try {
|
|
4239
|
+
const response = yield fn(...params);
|
|
4240
|
+
return response;
|
|
4241
|
+
} catch (error) {
|
|
4242
|
+
errorHandler(error);
|
|
4243
|
+
} finally {
|
|
4244
|
+
setLoading(LOADING_NAME, true);
|
|
4245
|
+
}
|
|
4246
|
+
});
|
|
4247
|
+
},
|
|
4248
|
+
[setLoading, api]
|
|
4249
|
+
);
|
|
4250
|
+
const errorHandler = useCallback3(
|
|
4251
|
+
(error, callback) => {
|
|
4252
|
+
if ((error == null ? void 0 : error.message) === "cancel.navigation")
|
|
4253
|
+
return;
|
|
4254
|
+
if (callback) {
|
|
4255
|
+
if (error.response.data.code === "invalid.body") {
|
|
4256
|
+
const errors = error.response.data.details.issues;
|
|
4257
|
+
const currentErrors = errors.reduce((acc, item) => {
|
|
4258
|
+
acc[item.path.join(".")] = item.message;
|
|
4259
|
+
return acc;
|
|
4260
|
+
}, {});
|
|
4261
|
+
callback(currentErrors);
|
|
4196
4262
|
}
|
|
4197
|
-
);
|
|
4198
|
-
try {
|
|
4199
|
-
const response = yield fn(...params);
|
|
4200
|
-
return response;
|
|
4201
|
-
} catch (error) {
|
|
4202
|
-
errorHandler(error);
|
|
4203
|
-
} finally {
|
|
4204
|
-
setLoading(LOADING_NAME, true);
|
|
4205
|
-
}
|
|
4206
|
-
});
|
|
4207
|
-
}
|
|
4208
|
-
function errorHandler(error, callback) {
|
|
4209
|
-
if ((error == null ? void 0 : error.message) === "cancel.navigation")
|
|
4210
|
-
return;
|
|
4211
|
-
if (callback) {
|
|
4212
|
-
if (error.response.data.code === "invalid.body") {
|
|
4213
|
-
const errors = error.response.data.details.issues;
|
|
4214
|
-
const currentErrors = errors.reduce((acc, item) => {
|
|
4215
|
-
acc[item.path.join(".")] = item.message;
|
|
4216
|
-
return acc;
|
|
4217
|
-
}, {});
|
|
4218
|
-
callback(currentErrors);
|
|
4219
4263
|
}
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4264
|
+
createAlert(formatErrorMessage(error), "error");
|
|
4265
|
+
},
|
|
4266
|
+
[formatErrorMessage, createAlert]
|
|
4267
|
+
);
|
|
4223
4268
|
useEffect4(() => {
|
|
4224
4269
|
return () => {
|
|
4225
4270
|
sourceRef.current.abort();
|
|
@@ -4547,11 +4592,11 @@ var AuthHelper = class {
|
|
|
4547
4592
|
};
|
|
4548
4593
|
|
|
4549
4594
|
// src/hooks/useGrid.ts
|
|
4550
|
-
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
4595
|
+
import { useCallback as useCallback5, useMemo as useMemo3, useState as useState6 } from "react";
|
|
4551
4596
|
|
|
4552
4597
|
// src/hooks/useFilter.ts
|
|
4553
4598
|
import moment2 from "moment";
|
|
4554
|
-
import { useState as useState5 } from "react";
|
|
4599
|
+
import { useCallback as useCallback4, useState as useState5 } from "react";
|
|
4555
4600
|
|
|
4556
4601
|
// src/components/utils/getObjectValue.ts
|
|
4557
4602
|
function getObjectValue(obj) {
|
|
@@ -4567,7 +4612,7 @@ function getObjectValue(obj) {
|
|
|
4567
4612
|
// src/hooks/useFilter.ts
|
|
4568
4613
|
function useFilter() {
|
|
4569
4614
|
const [selectedFilters, setSelectedFilters] = useState5([]);
|
|
4570
|
-
const filterBy = (newFilter) => {
|
|
4615
|
+
const filterBy = useCallback4((newFilter) => {
|
|
4571
4616
|
const propToCompare = (newFilter == null ? void 0 : newFilter.id) ? "id" : "prop";
|
|
4572
4617
|
function removeRepeatedFilters(filter) {
|
|
4573
4618
|
return filter[propToCompare] !== newFilter[propToCompare];
|
|
@@ -4576,13 +4621,16 @@ function useFilter() {
|
|
|
4576
4621
|
...filters.filter(removeRepeatedFilters),
|
|
4577
4622
|
newFilter
|
|
4578
4623
|
]);
|
|
4579
|
-
};
|
|
4580
|
-
const removeFilter = (
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4624
|
+
}, []);
|
|
4625
|
+
const removeFilter = useCallback4(
|
|
4626
|
+
(prop, isId) => {
|
|
4627
|
+
const propToCompare = isId ? "id" : "prop";
|
|
4628
|
+
setSelectedFilters(
|
|
4629
|
+
selectedFilters.filter((filter) => filter[propToCompare] !== prop)
|
|
4630
|
+
);
|
|
4631
|
+
},
|
|
4632
|
+
[selectedFilters]
|
|
4633
|
+
);
|
|
4586
4634
|
function clearAllFilters() {
|
|
4587
4635
|
setSelectedFilters([]);
|
|
4588
4636
|
}
|
|
@@ -4637,70 +4685,96 @@ function createFilter(filters) {
|
|
|
4637
4685
|
}
|
|
4638
4686
|
|
|
4639
4687
|
// src/hooks/useGrid.ts
|
|
4688
|
+
import sortBy from "sort-by";
|
|
4640
4689
|
function useGrid({
|
|
4641
4690
|
columns,
|
|
4642
4691
|
filters = [],
|
|
4643
4692
|
search,
|
|
4644
|
-
rowsPerPageOptions = [30, 60, 100]
|
|
4693
|
+
rowsPerPageOptions = [30, 60, 100],
|
|
4694
|
+
defaultData: externalDefaultData,
|
|
4695
|
+
defaultCurrentPage,
|
|
4696
|
+
defaultSortedBy
|
|
4645
4697
|
}) {
|
|
4646
|
-
const [defaultData, setDefaultData] = useState6([]);
|
|
4647
|
-
const [sortedBy, setSortedBy] = useState6(
|
|
4648
|
-
|
|
4649
|
-
|
|
4698
|
+
const [defaultData, setDefaultData] = useState6(externalDefaultData || []);
|
|
4699
|
+
const [sortedBy, setSortedBy] = useState6(
|
|
4700
|
+
defaultSortedBy || []
|
|
4701
|
+
);
|
|
4702
|
+
const [currentPage, setCurrentPage] = useState6(defaultCurrentPage || 0);
|
|
4650
4703
|
const [rowsPerPage, setRowsPerPage] = useState6(rowsPerPageOptions[0]);
|
|
4651
|
-
const toggleSortedDirection = (
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4704
|
+
const toggleSortedDirection = useCallback5(
|
|
4705
|
+
(direction) => {
|
|
4706
|
+
if (direction === "asc")
|
|
4707
|
+
return "desc";
|
|
4708
|
+
return "asc";
|
|
4709
|
+
},
|
|
4710
|
+
[]
|
|
4711
|
+
);
|
|
4712
|
+
const setSort = useCallback5((prop, direction) => {
|
|
4713
|
+
setSortedBy((prev) => [...prev, { prop, direction }]);
|
|
4714
|
+
}, []);
|
|
4715
|
+
const onSortBy = useCallback5(
|
|
4716
|
+
(prop) => {
|
|
4717
|
+
if (!prop)
|
|
4718
|
+
return;
|
|
4719
|
+
const currentSorted = sortedBy.find((p) => p.prop === prop);
|
|
4720
|
+
if (currentSorted) {
|
|
4721
|
+
if (currentSorted.direction === "asc") {
|
|
4722
|
+
setSortedBy((prev) => prev.filter((p) => p.prop !== prop));
|
|
4723
|
+
} else {
|
|
4724
|
+
setSortedBy((prev) => {
|
|
4725
|
+
const newArr = prev.map((p) => {
|
|
4726
|
+
if (p.prop !== prop)
|
|
4727
|
+
return p;
|
|
4728
|
+
return {
|
|
4729
|
+
prop: p.prop,
|
|
4730
|
+
direction: toggleSortedDirection(p.direction)
|
|
4731
|
+
};
|
|
4732
|
+
});
|
|
4733
|
+
return [...newArr].slice(0);
|
|
4734
|
+
});
|
|
4735
|
+
}
|
|
4736
|
+
} else {
|
|
4737
|
+
setSortedBy((prev) => [...prev, { prop, direction: "desc" }]);
|
|
4738
|
+
}
|
|
4739
|
+
},
|
|
4740
|
+
[toggleSortedDirection, sortedBy]
|
|
4741
|
+
);
|
|
4742
|
+
const set = useCallback5((data) => {
|
|
4676
4743
|
setDefaultData(data);
|
|
4677
|
-
};
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
const
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4744
|
+
}, []);
|
|
4745
|
+
const sortData = useCallback5(
|
|
4746
|
+
(data) => {
|
|
4747
|
+
if (sortedBy.length > 0) {
|
|
4748
|
+
const symbolDir = {
|
|
4749
|
+
asc: "",
|
|
4750
|
+
desc: "-"
|
|
4751
|
+
};
|
|
4752
|
+
const formattedKeys = sortedBy.map(
|
|
4753
|
+
({ prop, direction }) => `${symbolDir[direction]}${prop}`
|
|
4754
|
+
);
|
|
4755
|
+
return data.sort(sortBy(...formattedKeys));
|
|
4756
|
+
} else
|
|
4757
|
+
return data;
|
|
4758
|
+
},
|
|
4759
|
+
[sortedBy]
|
|
4760
|
+
);
|
|
4761
|
+
const onPageChange = useCallback5((pageNumber) => {
|
|
4691
4762
|
if (pageNumber < 0)
|
|
4692
4763
|
return;
|
|
4693
4764
|
if (pageNumber > totalNumberOfPages)
|
|
4694
4765
|
return;
|
|
4695
4766
|
setCurrentPage(pageNumber);
|
|
4696
|
-
};
|
|
4697
|
-
const onChangeRowsPerPage = (
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4767
|
+
}, []);
|
|
4768
|
+
const onChangeRowsPerPage = useCallback5(
|
|
4769
|
+
(rows) => {
|
|
4770
|
+
let totalNumberOfPages2 = Math.round(filteredData.length / rows) - 1;
|
|
4771
|
+
totalNumberOfPages2 = totalNumberOfPages2 <= 0 ? 0 : 1;
|
|
4772
|
+
if (currentPage > totalNumberOfPages2)
|
|
4773
|
+
setCurrentPage(totalNumberOfPages2);
|
|
4774
|
+
setRowsPerPage(rows);
|
|
4775
|
+
},
|
|
4776
|
+
[currentPage]
|
|
4777
|
+
);
|
|
4704
4778
|
const filteredData = useMemo3(() => {
|
|
4705
4779
|
let newData = defaultData.slice(0);
|
|
4706
4780
|
if (search && search.value !== "") {
|
|
@@ -4715,7 +4789,7 @@ function useGrid({
|
|
|
4715
4789
|
const startPage = currentPage * rowsPerPage;
|
|
4716
4790
|
const endPage = startPage + rowsPerPage;
|
|
4717
4791
|
return sortedData.slice(startPage, endPage);
|
|
4718
|
-
}, [
|
|
4792
|
+
}, [filteredData, currentPage, rowsPerPage, sortData]);
|
|
4719
4793
|
const totalNumberOfPages = Math.ceil(filteredData.length / rowsPerPage) - 1;
|
|
4720
4794
|
return {
|
|
4721
4795
|
data: displayData,
|
|
@@ -4723,7 +4797,6 @@ function useGrid({
|
|
|
4723
4797
|
onSortBy,
|
|
4724
4798
|
sortedBy,
|
|
4725
4799
|
defaultData,
|
|
4726
|
-
sortedDirection,
|
|
4727
4800
|
columns,
|
|
4728
4801
|
currentPage,
|
|
4729
4802
|
totalNumberOfPages: totalNumberOfPages < 0 ? 0 : totalNumberOfPages,
|
|
@@ -4769,10 +4842,184 @@ function createSearch(options) {
|
|
|
4769
4842
|
};
|
|
4770
4843
|
}
|
|
4771
4844
|
|
|
4845
|
+
// src/hooks/useAsyncGrid.ts
|
|
4846
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useState as useState7 } from "react";
|
|
4847
|
+
function useAsyncGrid({
|
|
4848
|
+
columns,
|
|
4849
|
+
filters = [],
|
|
4850
|
+
search,
|
|
4851
|
+
rowsPerPageOptions = [30, 60, 100],
|
|
4852
|
+
onRequest,
|
|
4853
|
+
axiosInstance,
|
|
4854
|
+
url,
|
|
4855
|
+
defaultData: externalDefaultData,
|
|
4856
|
+
defaultCurrentPage,
|
|
4857
|
+
defaultSortedBy
|
|
4858
|
+
}) {
|
|
4859
|
+
const [defaultData, setDefaultData] = useState7(externalDefaultData || []);
|
|
4860
|
+
const [sortedBy, setSortedBy] = useState7(
|
|
4861
|
+
defaultSortedBy || []
|
|
4862
|
+
);
|
|
4863
|
+
const [totalNumberOfItems, setTotalNumberOfItems] = useState7(0);
|
|
4864
|
+
const [isLoading, setIsLoading] = useState7(false);
|
|
4865
|
+
const [currentPage, setCurrentPage] = useState7(defaultCurrentPage || 0);
|
|
4866
|
+
const [rowsPerPage, setRowsPerPage] = useState7(rowsPerPageOptions[0]);
|
|
4867
|
+
const totalNumberOfPages = Math.ceil(totalNumberOfItems / rowsPerPage) - 1;
|
|
4868
|
+
const toggleSortedDirection = useCallback6(
|
|
4869
|
+
(direction) => {
|
|
4870
|
+
if (direction === "asc")
|
|
4871
|
+
return "desc";
|
|
4872
|
+
return "asc";
|
|
4873
|
+
},
|
|
4874
|
+
[]
|
|
4875
|
+
);
|
|
4876
|
+
const setSort = useCallback6((prop, direction) => {
|
|
4877
|
+
setSortedBy((prev) => [...prev, { prop, direction }]);
|
|
4878
|
+
}, []);
|
|
4879
|
+
const onSortBy = useCallback6(
|
|
4880
|
+
(prop) => __async(this, null, function* () {
|
|
4881
|
+
if (!prop)
|
|
4882
|
+
return;
|
|
4883
|
+
let finalArr = [];
|
|
4884
|
+
const currentSorted = sortedBy.find((p) => p.prop === prop);
|
|
4885
|
+
if (currentSorted) {
|
|
4886
|
+
if (currentSorted.direction === "asc") {
|
|
4887
|
+
finalArr = sortedBy.filter((p) => p.prop !== prop);
|
|
4888
|
+
} else {
|
|
4889
|
+
finalArr = sortedBy.map((p) => {
|
|
4890
|
+
if (p.prop !== prop)
|
|
4891
|
+
return p;
|
|
4892
|
+
return {
|
|
4893
|
+
prop: p.prop,
|
|
4894
|
+
direction: toggleSortedDirection(p.direction)
|
|
4895
|
+
};
|
|
4896
|
+
});
|
|
4897
|
+
}
|
|
4898
|
+
} else {
|
|
4899
|
+
finalArr = [...sortedBy, { prop, direction: "desc" }];
|
|
4900
|
+
}
|
|
4901
|
+
yield updateGridContent({
|
|
4902
|
+
page: currentPage,
|
|
4903
|
+
sortedBy: finalArr,
|
|
4904
|
+
rowsPerPage
|
|
4905
|
+
});
|
|
4906
|
+
}),
|
|
4907
|
+
[sortedBy, toggleSortedDirection, rowsPerPage, currentPage]
|
|
4908
|
+
);
|
|
4909
|
+
const set = useCallback6((data) => {
|
|
4910
|
+
setDefaultData(data);
|
|
4911
|
+
}, []);
|
|
4912
|
+
const baseRequest = useCallback6(
|
|
4913
|
+
(_0) => __async(this, [_0], function* ({
|
|
4914
|
+
page,
|
|
4915
|
+
search: search2,
|
|
4916
|
+
filters: filters2,
|
|
4917
|
+
sortedBy: sortedBy2,
|
|
4918
|
+
rowsPerPage: rowsPerPage2
|
|
4919
|
+
}) {
|
|
4920
|
+
if (!axiosInstance)
|
|
4921
|
+
throw new Error("Axios instance not provided");
|
|
4922
|
+
try {
|
|
4923
|
+
const params = new URLSearchParams({
|
|
4924
|
+
page: String(page),
|
|
4925
|
+
rowsPerPage: String(rowsPerPage2),
|
|
4926
|
+
searchText: (search2 == null ? void 0 : search2.value) || "",
|
|
4927
|
+
sort: sortedBy2.map(({ prop, direction }) => `${prop}:${direction}`).join(","),
|
|
4928
|
+
filters: filters2.map(
|
|
4929
|
+
(filter) => `${filter.prop}:${filter.compareType}:${filter.value}`
|
|
4930
|
+
).join(",")
|
|
4931
|
+
});
|
|
4932
|
+
const pathWithParams = `${url}?${params.toString()}`;
|
|
4933
|
+
const { data } = yield axiosInstance.get(pathWithParams);
|
|
4934
|
+
setTotalNumberOfItems(data.totalNumberOfItems);
|
|
4935
|
+
return data.rows;
|
|
4936
|
+
} catch (_) {
|
|
4937
|
+
return [];
|
|
4938
|
+
}
|
|
4939
|
+
}),
|
|
4940
|
+
[axiosInstance, url]
|
|
4941
|
+
);
|
|
4942
|
+
const updateGridContent = useCallback6(
|
|
4943
|
+
(_0) => __async(this, [_0], function* ({
|
|
4944
|
+
page,
|
|
4945
|
+
sortedBy: sortedBy2,
|
|
4946
|
+
rowsPerPage: rowsPerPage2
|
|
4947
|
+
}) {
|
|
4948
|
+
setIsLoading(true);
|
|
4949
|
+
try {
|
|
4950
|
+
const props = {
|
|
4951
|
+
page,
|
|
4952
|
+
rowsPerPage: rowsPerPage2,
|
|
4953
|
+
sortedBy: sortedBy2,
|
|
4954
|
+
search,
|
|
4955
|
+
filters
|
|
4956
|
+
};
|
|
4957
|
+
const result = !onRequest ? yield baseRequest(props) : yield onRequest(props);
|
|
4958
|
+
setSortedBy(sortedBy2);
|
|
4959
|
+
setRowsPerPage(rowsPerPage2);
|
|
4960
|
+
set(result);
|
|
4961
|
+
setCurrentPage(page);
|
|
4962
|
+
} finally {
|
|
4963
|
+
setIsLoading(false);
|
|
4964
|
+
}
|
|
4965
|
+
}),
|
|
4966
|
+
[set, search, filters, onRequest, baseRequest]
|
|
4967
|
+
);
|
|
4968
|
+
const onPageChange = useCallback6(
|
|
4969
|
+
(pageNumber) => {
|
|
4970
|
+
if (pageNumber < 0)
|
|
4971
|
+
return;
|
|
4972
|
+
if (pageNumber > totalNumberOfPages)
|
|
4973
|
+
return;
|
|
4974
|
+
updateGridContent({ page: pageNumber, sortedBy, rowsPerPage });
|
|
4975
|
+
},
|
|
4976
|
+
[updateGridContent, totalNumberOfPages, sortedBy, rowsPerPage]
|
|
4977
|
+
);
|
|
4978
|
+
const onChangeRowsPerPage = useCallback6(
|
|
4979
|
+
(rows) => {
|
|
4980
|
+
let totalNumberOfPages2 = Math.round(totalNumberOfItems / rows) - 1;
|
|
4981
|
+
totalNumberOfPages2 = totalNumberOfPages2 <= 0 ? 0 : 1;
|
|
4982
|
+
if (currentPage > totalNumberOfPages2)
|
|
4983
|
+
updateGridContent({
|
|
4984
|
+
page: totalNumberOfPages2,
|
|
4985
|
+
sortedBy,
|
|
4986
|
+
rowsPerPage: rows
|
|
4987
|
+
});
|
|
4988
|
+
updateGridContent({
|
|
4989
|
+
page: currentPage,
|
|
4990
|
+
sortedBy,
|
|
4991
|
+
rowsPerPage: rows
|
|
4992
|
+
});
|
|
4993
|
+
},
|
|
4994
|
+
[updateGridContent, totalNumberOfItems, sortedBy, currentPage]
|
|
4995
|
+
);
|
|
4996
|
+
const displayData = defaultData;
|
|
4997
|
+
useEffect5(() => {
|
|
4998
|
+
updateGridContent({ page: 0, sortedBy: [], rowsPerPage });
|
|
4999
|
+
}, [updateGridContent, rowsPerPage]);
|
|
5000
|
+
return {
|
|
5001
|
+
data: displayData,
|
|
5002
|
+
set,
|
|
5003
|
+
onSortBy,
|
|
5004
|
+
sortedBy,
|
|
5005
|
+
defaultData,
|
|
5006
|
+
columns,
|
|
5007
|
+
currentPage,
|
|
5008
|
+
totalNumberOfPages: totalNumberOfPages < 0 ? 0 : totalNumberOfPages,
|
|
5009
|
+
onPageChange,
|
|
5010
|
+
setRowsPerPage: onChangeRowsPerPage,
|
|
5011
|
+
rowsPerPageOptions,
|
|
5012
|
+
rowsPerPage,
|
|
5013
|
+
setSort,
|
|
5014
|
+
isLoading,
|
|
5015
|
+
setIsLoading
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
5018
|
+
|
|
4772
5019
|
// src/hooks/useEvent.ts
|
|
4773
|
-
import { useEffect as
|
|
5020
|
+
import { useEffect as useEffect6 } from "react";
|
|
4774
5021
|
function useEvent(event, handler, passive = false) {
|
|
4775
|
-
|
|
5022
|
+
useEffect6(() => {
|
|
4776
5023
|
window.addEventListener(event, handler, passive);
|
|
4777
5024
|
return function cleanup() {
|
|
4778
5025
|
window.removeEventListener(event, handler);
|
|
@@ -4781,11 +5028,11 @@ function useEvent(event, handler, passive = false) {
|
|
|
4781
5028
|
}
|
|
4782
5029
|
|
|
4783
5030
|
// src/contexts/AuthContext.tsx
|
|
4784
|
-
import React27 from "react";
|
|
5031
|
+
import React27, { useCallback as useCallback7 } from "react";
|
|
4785
5032
|
import {
|
|
4786
5033
|
createContext as createContext3,
|
|
4787
|
-
useEffect as
|
|
4788
|
-
useState as
|
|
5034
|
+
useEffect as useEffect7,
|
|
5035
|
+
useState as useState8
|
|
4789
5036
|
} from "react";
|
|
4790
5037
|
import { parseCookies as parseCookies2 } from "nookies";
|
|
4791
5038
|
function createAuthContext() {
|
|
@@ -4797,35 +5044,36 @@ function CreateAuthProvider({
|
|
|
4797
5044
|
sessionTokenName,
|
|
4798
5045
|
Provider
|
|
4799
5046
|
}) {
|
|
4800
|
-
const [user, setUser] =
|
|
4801
|
-
const [status, setStatus] =
|
|
5047
|
+
const [user, setUser] = useState8();
|
|
5048
|
+
const [status, setStatus] = useState8("unauthenticated");
|
|
4802
5049
|
const { createAlert } = useAlert();
|
|
4803
|
-
const signIn = (
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
5050
|
+
const signIn = useCallback7(
|
|
5051
|
+
(_0) => __async(this, [_0], function* ({ email, password }) {
|
|
5052
|
+
setStatus("loading");
|
|
5053
|
+
try {
|
|
5054
|
+
const response = yield api.post("/auth/login", {
|
|
5055
|
+
email,
|
|
5056
|
+
password
|
|
5057
|
+
});
|
|
5058
|
+
const { token } = response.data;
|
|
5059
|
+
api.defaults.headers.common.Authorization = `Bearer ${token}`;
|
|
5060
|
+
const { data } = yield api.get("/auth/me");
|
|
5061
|
+
setUser(data);
|
|
5062
|
+
setStatus("autenticated");
|
|
5063
|
+
return true;
|
|
5064
|
+
} catch (error) {
|
|
5065
|
+
createAlert(error.response.data.error, "error");
|
|
5066
|
+
setStatus("unauthenticated");
|
|
5067
|
+
throw error;
|
|
5068
|
+
}
|
|
5069
|
+
}),
|
|
5070
|
+
[createAlert, api]
|
|
5071
|
+
);
|
|
5072
|
+
const ClientSignOut = useCallback7(() => __async(this, null, function* () {
|
|
5073
|
+
yield api.get("/auth/logout");
|
|
5074
|
+
setUser(void 0);
|
|
5075
|
+
}), [api]);
|
|
5076
|
+
useEffect7(() => {
|
|
4829
5077
|
const token = parseCookies2()[sessionTokenName];
|
|
4830
5078
|
if (token) {
|
|
4831
5079
|
setStatus("loading");
|
|
@@ -4857,6 +5105,7 @@ export {
|
|
|
4857
5105
|
AuthHelper,
|
|
4858
5106
|
Autocomplete2 as Autocomplete,
|
|
4859
5107
|
BaseGrid,
|
|
5108
|
+
BaseGridAutoRows,
|
|
4860
5109
|
Checkbox,
|
|
4861
5110
|
CreateAuthProvider,
|
|
4862
5111
|
Dialog,
|
|
@@ -4881,6 +5130,7 @@ export {
|
|
|
4881
5130
|
filterData,
|
|
4882
5131
|
getTabProps,
|
|
4883
5132
|
useAlert,
|
|
5133
|
+
useAsyncGrid,
|
|
4884
5134
|
useEvent,
|
|
4885
5135
|
useFilter,
|
|
4886
5136
|
useFormHelper,
|