next-recomponents 2.0.35 → 2.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/dist/index.js +177 -149
- package/dist/index.mjs +178 -150
- package/package.json +1 -1
- package/src/container/index.tsx +19 -15
- package/src/use-resources/index.ts +206 -136
package/dist/index.mjs
CHANGED
|
@@ -3561,7 +3561,7 @@ function Button({
|
|
|
3561
3561
|
}
|
|
3562
3562
|
|
|
3563
3563
|
// src/container/index.tsx
|
|
3564
|
-
import {
|
|
3564
|
+
import { useState as useState2 } from "react";
|
|
3565
3565
|
|
|
3566
3566
|
// src/container/icons.tsx
|
|
3567
3567
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -3643,19 +3643,8 @@ function Container({
|
|
|
3643
3643
|
expandedFooter = false,
|
|
3644
3644
|
expandedMenu = false
|
|
3645
3645
|
}) {
|
|
3646
|
-
const [isSidebarOpen, setIsSidebarOpen] = useState2(
|
|
3646
|
+
const [isSidebarOpen, setIsSidebarOpen] = useState2(false);
|
|
3647
3647
|
const [isFooterOpen, setIsFooterOpen] = useState2(expandedFooter);
|
|
3648
|
-
const handleClick = (state) => {
|
|
3649
|
-
window.localStorage.setItem("isSidebarOpen", JSON.stringify(state));
|
|
3650
|
-
};
|
|
3651
|
-
useEffect(() => {
|
|
3652
|
-
if (typeof window !== "undefined") {
|
|
3653
|
-
const storedSidebarState = window.localStorage.getItem("isSidebarOpen");
|
|
3654
|
-
if (storedSidebarState && window.innerWidth >= 768) {
|
|
3655
|
-
setIsSidebarOpen(JSON.parse(storedSidebarState));
|
|
3656
|
-
}
|
|
3657
|
-
}
|
|
3658
|
-
}, []);
|
|
3659
3648
|
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col h-screen", children: [
|
|
3660
3649
|
/* @__PURE__ */ jsxs2("header", { className: "", children: [
|
|
3661
3650
|
/* @__PURE__ */ jsxs2("div", { className: "bg-blue-600 text-white p-4 flex justify-between items-center shadow-md", children: [
|
|
@@ -3664,7 +3653,6 @@ function Container({
|
|
|
3664
3653
|
{
|
|
3665
3654
|
onClick: () => {
|
|
3666
3655
|
setIsSidebarOpen(!isSidebarOpen);
|
|
3667
|
-
handleClick(!isSidebarOpen);
|
|
3668
3656
|
},
|
|
3669
3657
|
className: "bg-blue-600 text-white px-2 py-1 rounded-r",
|
|
3670
3658
|
children: /* @__PURE__ */ jsx3(MenuIcon, {})
|
|
@@ -3703,6 +3691,10 @@ function Container({
|
|
|
3703
3691
|
className: `bg-blue-500 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out
|
|
3704
3692
|
${isSidebarOpen ? "w-full md:w-[250px]" : "w-0 md:w-[60px]"}
|
|
3705
3693
|
`,
|
|
3694
|
+
onMouseEnter: (e) => {
|
|
3695
|
+
setIsSidebarOpen(true);
|
|
3696
|
+
},
|
|
3697
|
+
onMouseLeave: (e) => setIsSidebarOpen(false),
|
|
3706
3698
|
children: /* @__PURE__ */ jsx3("div", { className: "p-4 ", children: /* @__PURE__ */ jsxs2("ul", { className: "space-y-3", children: [
|
|
3707
3699
|
/* @__PURE__ */ jsxs2(
|
|
3708
3700
|
"li",
|
|
@@ -3710,7 +3702,6 @@ function Container({
|
|
|
3710
3702
|
className: "p-2 md:hidden flex items-center justify-between font-bold",
|
|
3711
3703
|
onClick: (e) => {
|
|
3712
3704
|
setIsSidebarOpen(false);
|
|
3713
|
-
handleClick(false);
|
|
3714
3705
|
},
|
|
3715
3706
|
children: [
|
|
3716
3707
|
/* @__PURE__ */ jsx3(MenuIcon, {}),
|
|
@@ -3746,7 +3737,6 @@ function Container({
|
|
|
3746
3737
|
className: "fixed inset-0 bg-black bg-opacity-40 z-40",
|
|
3747
3738
|
onClick: () => {
|
|
3748
3739
|
setIsSidebarOpen(false);
|
|
3749
|
-
handleClick(false);
|
|
3750
3740
|
}
|
|
3751
3741
|
}
|
|
3752
3742
|
),
|
|
@@ -36399,140 +36389,152 @@ function useResources({
|
|
|
36399
36389
|
return error;
|
|
36400
36390
|
}
|
|
36401
36391
|
};
|
|
36392
|
+
const mergeDataArray = (existingData, newItem, matchId) => {
|
|
36393
|
+
if (!existingData) return [newItem];
|
|
36394
|
+
const index = existingData.findIndex((d) => (d == null ? void 0 : d.id) == matchId);
|
|
36395
|
+
if (index >= 0) {
|
|
36396
|
+
return existingData.map(
|
|
36397
|
+
(d, i) => i === index ? newItem : d
|
|
36398
|
+
);
|
|
36399
|
+
}
|
|
36400
|
+
return [newItem, ...existingData];
|
|
36401
|
+
};
|
|
36402
36402
|
const bodyCreateFunc = async (data) => {
|
|
36403
|
-
var _a2, _b2, _c2, _d2, _e2
|
|
36403
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
36404
36404
|
const options = {
|
|
36405
36405
|
method: "POST",
|
|
36406
36406
|
url: `${baseURI}/${key}`,
|
|
36407
36407
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36408
36408
|
headers: { Authorization: token }
|
|
36409
36409
|
};
|
|
36410
|
-
const newInfo = {
|
|
36411
|
-
|
|
36412
|
-
|
|
36410
|
+
const newInfo = {
|
|
36411
|
+
...info,
|
|
36412
|
+
[key]: {
|
|
36413
|
+
...info[key],
|
|
36414
|
+
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36415
|
+
state: "loading",
|
|
36416
|
+
errorMessage: ""
|
|
36417
|
+
}
|
|
36418
|
+
};
|
|
36413
36419
|
setInfo(newInfo);
|
|
36414
36420
|
try {
|
|
36415
36421
|
const consulta = await axios.request(options);
|
|
36416
36422
|
const d = consulta.data;
|
|
36417
|
-
|
|
36418
|
-
newInfo[key].errorMessage = "";
|
|
36423
|
+
let updatedData;
|
|
36419
36424
|
if (Array.isArray(data)) {
|
|
36420
|
-
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
);
|
|
36424
|
-
if (index >= 0) {
|
|
36425
|
-
newInfo[key].data[index] = d;
|
|
36426
|
-
} else {
|
|
36427
|
-
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36428
|
-
newInfo[key].data.unshift(d);
|
|
36429
|
-
} else {
|
|
36430
|
-
newInfo[key].data = [d];
|
|
36431
|
-
}
|
|
36432
|
-
}
|
|
36425
|
+
updatedData = [...(_d2 = (_c2 = newInfo[key]) == null ? void 0 : _c2.data) != null ? _d2 : []];
|
|
36426
|
+
for (const datum of data) {
|
|
36427
|
+
updatedData = mergeDataArray(updatedData, d, datum == null ? void 0 : datum.id);
|
|
36433
36428
|
}
|
|
36434
|
-
|
|
36429
|
+
updatedData = updatedData.flat();
|
|
36435
36430
|
} else {
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36431
|
+
updatedData = mergeDataArray(
|
|
36432
|
+
(_e2 = newInfo[key]) == null ? void 0 : _e2.data,
|
|
36433
|
+
d,
|
|
36434
|
+
data == null ? void 0 : data.id
|
|
36439
36435
|
);
|
|
36440
|
-
if (index >= 0) {
|
|
36441
|
-
newInfo[key].data[index] = d;
|
|
36442
|
-
} else {
|
|
36443
|
-
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36444
|
-
newInfo[key].data.unshift(d);
|
|
36445
|
-
} else {
|
|
36446
|
-
newInfo[key].data = [d];
|
|
36447
|
-
}
|
|
36448
|
-
}
|
|
36449
36436
|
}
|
|
36450
|
-
setInfo({
|
|
36437
|
+
setInfo({
|
|
36438
|
+
...newInfo,
|
|
36439
|
+
[key]: {
|
|
36440
|
+
...newInfo[key],
|
|
36441
|
+
state: "success",
|
|
36442
|
+
errorMessage: "",
|
|
36443
|
+
selectedItem: Array.isArray(data) ? newInfo[key].selectedItem : d,
|
|
36444
|
+
data: updatedData
|
|
36445
|
+
}
|
|
36446
|
+
});
|
|
36451
36447
|
return d;
|
|
36452
36448
|
} catch (error) {
|
|
36453
36449
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36454
|
-
newInfo[key].state = "error";
|
|
36455
|
-
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36456
36450
|
if (error.status == 403) {
|
|
36457
|
-
onError == null ? void 0 : onError({ error,
|
|
36451
|
+
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36458
36452
|
}
|
|
36459
|
-
setInfo({
|
|
36453
|
+
setInfo({
|
|
36454
|
+
...newInfo,
|
|
36455
|
+
[key]: {
|
|
36456
|
+
...newInfo[key],
|
|
36457
|
+
state: "error",
|
|
36458
|
+
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36459
|
+
}
|
|
36460
|
+
});
|
|
36460
36461
|
return error;
|
|
36461
36462
|
}
|
|
36462
36463
|
};
|
|
36463
36464
|
const formCreateFunc = async (data) => {
|
|
36464
|
-
var _a2, _b2, _c2, _d2, _e2
|
|
36465
|
-
const
|
|
36466
|
-
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
|
|
36470
|
-
const formData = new FormData();
|
|
36471
|
-
if (Array.isArray(data)) {
|
|
36472
|
-
data.forEach((item, i) => {
|
|
36473
|
-
for (const [k, v] of Object.entries(item)) {
|
|
36474
|
-
formData.append(`${k}[${i}]`, v);
|
|
36475
|
-
}
|
|
36476
|
-
});
|
|
36477
|
-
} else {
|
|
36478
|
-
for (const [k, v] of Object.entries(data)) {
|
|
36479
|
-
formData.append(k, v);
|
|
36465
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
36466
|
+
const formData = new FormData();
|
|
36467
|
+
if (Array.isArray(data)) {
|
|
36468
|
+
data.forEach((item, i) => {
|
|
36469
|
+
for (const [k, v] of Object.entries(item)) {
|
|
36470
|
+
formData.append(`${k}[${i}]`, v);
|
|
36480
36471
|
}
|
|
36472
|
+
});
|
|
36473
|
+
} else {
|
|
36474
|
+
for (const [k, v] of Object.entries(data)) {
|
|
36475
|
+
formData.append(k, v);
|
|
36481
36476
|
}
|
|
36482
|
-
|
|
36483
|
-
|
|
36484
|
-
|
|
36485
|
-
|
|
36486
|
-
|
|
36487
|
-
|
|
36488
|
-
|
|
36489
|
-
|
|
36490
|
-
}
|
|
36477
|
+
}
|
|
36478
|
+
const options = {
|
|
36479
|
+
method: "POST",
|
|
36480
|
+
url: `${baseURI}/${key}`,
|
|
36481
|
+
data: formData,
|
|
36482
|
+
headers: {
|
|
36483
|
+
Authorization: token,
|
|
36484
|
+
"Content-Type": "multipart/form-data"
|
|
36485
|
+
}
|
|
36486
|
+
};
|
|
36487
|
+
const newInfo = {
|
|
36488
|
+
...info,
|
|
36489
|
+
[key]: {
|
|
36490
|
+
...info[key],
|
|
36491
|
+
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36492
|
+
state: "loading",
|
|
36493
|
+
errorMessage: ""
|
|
36494
|
+
}
|
|
36495
|
+
};
|
|
36496
|
+
setInfo(newInfo);
|
|
36497
|
+
try {
|
|
36491
36498
|
const consulta = await axios.request(options);
|
|
36492
36499
|
const d = consulta.data;
|
|
36493
|
-
|
|
36494
|
-
newInfo[key].errorMessage = "";
|
|
36500
|
+
let updatedData;
|
|
36495
36501
|
if (Array.isArray(data)) {
|
|
36496
|
-
|
|
36497
|
-
|
|
36498
|
-
|
|
36499
|
-
);
|
|
36500
|
-
if (index >= 0) {
|
|
36501
|
-
newInfo[key].data[index] = d;
|
|
36502
|
-
} else {
|
|
36503
|
-
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36504
|
-
newInfo[key].data.unshift(d);
|
|
36505
|
-
} else {
|
|
36506
|
-
newInfo[key].data = [d];
|
|
36507
|
-
}
|
|
36508
|
-
}
|
|
36502
|
+
updatedData = [...(_d2 = (_c2 = newInfo[key]) == null ? void 0 : _c2.data) != null ? _d2 : []];
|
|
36503
|
+
for (const datum of data) {
|
|
36504
|
+
updatedData = mergeDataArray(updatedData, d, datum == null ? void 0 : datum.id);
|
|
36509
36505
|
}
|
|
36510
|
-
|
|
36506
|
+
updatedData = updatedData.flat();
|
|
36511
36507
|
} else {
|
|
36512
|
-
|
|
36513
|
-
|
|
36514
|
-
|
|
36508
|
+
updatedData = mergeDataArray(
|
|
36509
|
+
(_e2 = newInfo[key]) == null ? void 0 : _e2.data,
|
|
36510
|
+
d,
|
|
36511
|
+
data == null ? void 0 : data.id
|
|
36515
36512
|
);
|
|
36516
|
-
if (index >= 0) {
|
|
36517
|
-
newInfo[key].data[index] = d;
|
|
36518
|
-
} else {
|
|
36519
|
-
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36520
|
-
newInfo[key].data.unshift(d);
|
|
36521
|
-
} else {
|
|
36522
|
-
newInfo[key].data = [d];
|
|
36523
|
-
}
|
|
36524
|
-
}
|
|
36525
36513
|
}
|
|
36526
|
-
setInfo({
|
|
36514
|
+
setInfo({
|
|
36515
|
+
...newInfo,
|
|
36516
|
+
[key]: {
|
|
36517
|
+
...newInfo[key],
|
|
36518
|
+
state: "success",
|
|
36519
|
+
errorMessage: "",
|
|
36520
|
+
selectedItem: Array.isArray(data) ? newInfo[key].selectedItem : d,
|
|
36521
|
+
data: updatedData
|
|
36522
|
+
}
|
|
36523
|
+
});
|
|
36527
36524
|
return d;
|
|
36528
36525
|
} catch (error) {
|
|
36529
36526
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36530
|
-
newInfo[key].state = "error";
|
|
36531
|
-
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36532
36527
|
if (error.status == 403) {
|
|
36533
|
-
onError == null ? void 0 : onError({ error,
|
|
36528
|
+
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36534
36529
|
}
|
|
36535
|
-
setInfo({
|
|
36530
|
+
setInfo({
|
|
36531
|
+
...newInfo,
|
|
36532
|
+
[key]: {
|
|
36533
|
+
...newInfo[key],
|
|
36534
|
+
state: "error",
|
|
36535
|
+
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36536
|
+
}
|
|
36537
|
+
});
|
|
36536
36538
|
return error;
|
|
36537
36539
|
}
|
|
36538
36540
|
};
|
|
@@ -36551,81 +36553,107 @@ function useResources({
|
|
|
36551
36553
|
return await bodyCreateFunc(data);
|
|
36552
36554
|
},
|
|
36553
36555
|
update: async (id, data) => {
|
|
36554
|
-
var _a2, _b2, _c2;
|
|
36556
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
36555
36557
|
const options = {
|
|
36556
36558
|
method: "PATCH",
|
|
36557
36559
|
url: `${baseURI}/${key}/${id}`,
|
|
36558
36560
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36559
36561
|
headers: { Authorization: token }
|
|
36560
36562
|
};
|
|
36561
|
-
const newInfo = {
|
|
36562
|
-
|
|
36563
|
-
|
|
36563
|
+
const newInfo = {
|
|
36564
|
+
...info,
|
|
36565
|
+
[key]: {
|
|
36566
|
+
...info[key],
|
|
36567
|
+
// ✅ copia superficial del key
|
|
36568
|
+
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36569
|
+
// ✅ copia del array
|
|
36570
|
+
state: "loading",
|
|
36571
|
+
errorMessage: ""
|
|
36572
|
+
}
|
|
36573
|
+
};
|
|
36564
36574
|
setInfo(newInfo);
|
|
36565
36575
|
try {
|
|
36566
36576
|
const consulta = await axios.request(options);
|
|
36567
36577
|
const d = consulta.data;
|
|
36568
|
-
newInfo[key].
|
|
36569
|
-
|
|
36570
|
-
newInfo[key].selectedItem = { ...newInfo[key].selectedItem, ...d };
|
|
36571
|
-
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36572
|
-
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36578
|
+
const index = (_d2 = (_c2 = newInfo[key]) == null ? void 0 : _c2.data) == null ? void 0 : _d2.findIndex(
|
|
36579
|
+
(item) => (item == null ? void 0 : item.id) == id
|
|
36573
36580
|
);
|
|
36574
|
-
|
|
36575
|
-
|
|
36576
|
-
|
|
36577
|
-
|
|
36578
|
-
|
|
36579
|
-
|
|
36580
|
-
newInfo[key]
|
|
36581
|
+
const updatedData = index >= 0 ? newInfo[key].data.map(
|
|
36582
|
+
(item, i) => i === index ? { ...item, ...d } : item
|
|
36583
|
+
) : ((_e2 = newInfo[key]) == null ? void 0 : _e2.data) ? [d, ...newInfo[key].data] : [d];
|
|
36584
|
+
const updatedInfo = {
|
|
36585
|
+
...newInfo,
|
|
36586
|
+
[key]: {
|
|
36587
|
+
...newInfo[key],
|
|
36588
|
+
state: "success",
|
|
36589
|
+
errorMessage: "",
|
|
36590
|
+
selectedItem: { ...newInfo[key].selectedItem, ...d },
|
|
36591
|
+
data: updatedData
|
|
36581
36592
|
}
|
|
36582
|
-
}
|
|
36583
|
-
setInfo(
|
|
36593
|
+
};
|
|
36594
|
+
setInfo(updatedInfo);
|
|
36584
36595
|
return d;
|
|
36585
36596
|
} catch (error) {
|
|
36586
36597
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36587
|
-
|
|
36588
|
-
|
|
36598
|
+
setInfo({
|
|
36599
|
+
...newInfo,
|
|
36600
|
+
[key]: {
|
|
36601
|
+
...newInfo[key],
|
|
36602
|
+
state: "error",
|
|
36603
|
+
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36604
|
+
}
|
|
36605
|
+
});
|
|
36589
36606
|
if (error.status == 403) {
|
|
36590
36607
|
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36591
36608
|
}
|
|
36592
|
-
setInfo({ ...newInfo });
|
|
36593
36609
|
return error;
|
|
36594
36610
|
}
|
|
36595
36611
|
},
|
|
36596
36612
|
remove: async (id) => {
|
|
36597
|
-
var _a2, _b2;
|
|
36613
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
36598
36614
|
const options = {
|
|
36599
36615
|
method: "DELETE",
|
|
36600
36616
|
url: `${baseURI}/${key}/${id}`,
|
|
36601
36617
|
headers: { Authorization: token }
|
|
36602
36618
|
};
|
|
36603
|
-
const newInfo = {
|
|
36604
|
-
|
|
36605
|
-
|
|
36619
|
+
const newInfo = {
|
|
36620
|
+
...info,
|
|
36621
|
+
[key]: {
|
|
36622
|
+
...info[key],
|
|
36623
|
+
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36624
|
+
state: "loading",
|
|
36625
|
+
errorMessage: ""
|
|
36626
|
+
}
|
|
36627
|
+
};
|
|
36606
36628
|
setInfo(newInfo);
|
|
36607
36629
|
try {
|
|
36608
36630
|
const consulta = await axios.request(options);
|
|
36609
36631
|
const d = consulta.data;
|
|
36610
|
-
|
|
36611
|
-
|
|
36612
|
-
|
|
36613
|
-
|
|
36614
|
-
|
|
36615
|
-
|
|
36616
|
-
|
|
36617
|
-
|
|
36618
|
-
|
|
36619
|
-
|
|
36632
|
+
setInfo({
|
|
36633
|
+
...newInfo,
|
|
36634
|
+
[key]: {
|
|
36635
|
+
...newInfo[key],
|
|
36636
|
+
state: "success",
|
|
36637
|
+
errorMessage: "",
|
|
36638
|
+
selectedItem: d,
|
|
36639
|
+
data: (_e2 = (_d2 = (_c2 = newInfo[key]) == null ? void 0 : _c2.data) == null ? void 0 : _d2.filter((item) => (item == null ? void 0 : item.id) != id)) != null ? _e2 : []
|
|
36640
|
+
// ✅ filter en lugar de splice
|
|
36641
|
+
}
|
|
36642
|
+
});
|
|
36620
36643
|
return d.data;
|
|
36621
36644
|
} catch (error) {
|
|
36622
36645
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36623
|
-
newInfo[key].state = "error";
|
|
36624
|
-
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36625
36646
|
if (error.status == 403) {
|
|
36626
|
-
onError == null ? void 0 : onError({ error,
|
|
36647
|
+
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36627
36648
|
}
|
|
36628
|
-
setInfo({
|
|
36649
|
+
setInfo({
|
|
36650
|
+
...newInfo,
|
|
36651
|
+
[key]: {
|
|
36652
|
+
...newInfo[key],
|
|
36653
|
+
state: "error",
|
|
36654
|
+
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36655
|
+
}
|
|
36656
|
+
});
|
|
36629
36657
|
return error;
|
|
36630
36658
|
}
|
|
36631
36659
|
},
|
package/package.json
CHANGED
package/src/container/index.tsx
CHANGED
|
@@ -26,19 +26,19 @@ export default function Container({
|
|
|
26
26
|
expandedMenu?: boolean;
|
|
27
27
|
expandedFooter?: boolean;
|
|
28
28
|
}) {
|
|
29
|
-
const [isSidebarOpen, setIsSidebarOpen] = useState(
|
|
29
|
+
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
|
30
30
|
const [isFooterOpen, setIsFooterOpen] = useState(expandedFooter);
|
|
31
|
-
const handleClick = (state: boolean) => {
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, []);
|
|
31
|
+
// const handleClick = (state: boolean) => {
|
|
32
|
+
// window.localStorage.setItem("isSidebarOpen", JSON.stringify(state));
|
|
33
|
+
// };
|
|
34
|
+
// useEffect(() => {
|
|
35
|
+
// if (typeof window !== "undefined") {
|
|
36
|
+
// const storedSidebarState = window.localStorage.getItem("isSidebarOpen");
|
|
37
|
+
// if (storedSidebarState && window.innerWidth >= 768) {
|
|
38
|
+
// setIsSidebarOpen(JSON.parse(storedSidebarState));
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
// }, []);
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex flex-col h-screen">
|
|
44
44
|
{/* Header */}
|
|
@@ -47,7 +47,7 @@ export default function Container({
|
|
|
47
47
|
<button
|
|
48
48
|
onClick={() => {
|
|
49
49
|
setIsSidebarOpen(!isSidebarOpen);
|
|
50
|
-
handleClick(!isSidebarOpen);
|
|
50
|
+
// handleClick(!isSidebarOpen);
|
|
51
51
|
}}
|
|
52
52
|
className="bg-blue-600 text-white px-2 py-1 rounded-r"
|
|
53
53
|
>
|
|
@@ -90,6 +90,10 @@ export default function Container({
|
|
|
90
90
|
className={`bg-blue-500 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out
|
|
91
91
|
${isSidebarOpen ? "w-full md:w-[250px]" : "w-0 md:w-[60px]"}
|
|
92
92
|
`}
|
|
93
|
+
onMouseEnter={(e) => {
|
|
94
|
+
setIsSidebarOpen(true);
|
|
95
|
+
}}
|
|
96
|
+
onMouseLeave={(e) => setIsSidebarOpen(false)}
|
|
93
97
|
>
|
|
94
98
|
<div className="p-4 ">
|
|
95
99
|
{
|
|
@@ -101,7 +105,7 @@ export default function Container({
|
|
|
101
105
|
}
|
|
102
106
|
onClick={(e) => {
|
|
103
107
|
setIsSidebarOpen(false);
|
|
104
|
-
handleClick(false);
|
|
108
|
+
// handleClick(false);
|
|
105
109
|
}}
|
|
106
110
|
>
|
|
107
111
|
<MenuIcon /> {appName}
|
|
@@ -152,7 +156,7 @@ export default function Container({
|
|
|
152
156
|
className="fixed inset-0 bg-black bg-opacity-40 z-40"
|
|
153
157
|
onClick={() => {
|
|
154
158
|
setIsSidebarOpen(false);
|
|
155
|
-
handleClick(false);
|
|
159
|
+
// handleClick(false);
|
|
156
160
|
}}
|
|
157
161
|
/>
|
|
158
162
|
)}
|