Merge branch 'release/v0.10.1'
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
NEXT_PUBLIC_VERSION="0.10.0"
|
NEXT_PUBLIC_VERSION="0.10.1"
|
||||||
NEXT_PUBLIC_API_URL="https://rms.witel.ir"
|
NEXT_PUBLIC_API_URL="https://rms.witel.ir"
|
||||||
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"
|
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import WithAuthMiddleware from "@/core/middlewares/withAuth";
|
import WithAuthMiddleware from "@/core/middlewares/withAuth";
|
||||||
import LoadingHardPage from "@/core/components/LoadingHardPage";
|
import LoadingHardPage from "@/core/components/LoadingHardPage";
|
||||||
import { useAuth } from "@/lib/contexts/auth";
|
import { useAuth } from "@/lib/contexts/auth";
|
||||||
|
import { Typography, Stack } from "@mui/material";
|
||||||
|
|
||||||
const Layout = ({ children }) => {
|
const Layout = ({ children }) => {
|
||||||
const { isAuth, initAuthState, errorState } = useAuth();
|
const { isAuth, initAuthState, errorState } = useAuth();
|
||||||
@@ -9,9 +10,16 @@ const Layout = ({ children }) => {
|
|||||||
if (!initAuthState && !isAuth)
|
if (!initAuthState && !isAuth)
|
||||||
return (
|
return (
|
||||||
<LoadingHardPage
|
<LoadingHardPage
|
||||||
authState={!!errorState}
|
authState={errorState.status}
|
||||||
label={
|
label={
|
||||||
!!errorState ? "مشکلی در احراز هویت رخ داده است . دقایقی بعد امتحان کنید!!!" : "درحال احراز هویت..."
|
errorState.status ? (
|
||||||
|
<Stack justifyContent={"center"} alignItems={"center"}>
|
||||||
|
<Typography variant={"body1"}>{errorState.message}</Typography>
|
||||||
|
<Typography variant={"body1"}> کد : {errorState.status}</Typography>
|
||||||
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<Typography variant={"body1"}>درحال احراز هویت...</Typography>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
loading={true}
|
loading={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import FilterAltIcon from "@mui/icons-material/FilterAlt";
|
import FilterAltIcon from "@mui/icons-material/FilterAlt";
|
||||||
import { IconButton, Tooltip } from "@mui/material";
|
import { IconButton, Tooltip, Badge } from "@mui/material";
|
||||||
|
import useDataTable from "@/lib/hooks/useDataTable";
|
||||||
|
|
||||||
function FilterButton({ drawerState, setDrawerState }) {
|
function FilterButton({ drawerState, setDrawerState }) {
|
||||||
|
const { filterData } = useDataTable();
|
||||||
|
const isValueEmpty = (value) => {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value.length === 0 || value.every((v) => v === "");
|
||||||
|
}
|
||||||
|
return value === "" || value === null || value === undefined;
|
||||||
|
};
|
||||||
|
const filteredFilterData = Object.values(filterData).filter((filter) => !isValueEmpty(filter.value));
|
||||||
return (
|
return (
|
||||||
<Tooltip title="فیلتر">
|
<Tooltip title="فیلتر">
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -11,10 +20,18 @@ function FilterButton({ drawerState, setDrawerState }) {
|
|||||||
}}
|
}}
|
||||||
aria-label="filter table"
|
aria-label="filter table"
|
||||||
>
|
>
|
||||||
<FilterAltIcon />
|
<Badge
|
||||||
|
badgeContent={filteredFilterData.length}
|
||||||
|
color="primary"
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "left",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FilterAltIcon />
|
||||||
|
</Badge>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FilterButton;
|
export default FilterButton;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import FilterButton from "@/core/components/DataTable/filter/FilterButton";
|
import FilterButton from "@/core/components/DataTable/filter/FilterButton";
|
||||||
import FilterBody from "@/core/components/DataTable/filter/FilterBody";
|
import FilterBody from "@/core/components/DataTable/filter/FilterBody";
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import ViewColumnIcon from "@mui/icons-material/ViewColumn";
|
import ViewColumnIcon from "@mui/icons-material/ViewColumn";
|
||||||
import { IconButton, Tooltip } from "@mui/material";
|
import { IconButton, Tooltip, Badge } from "@mui/material";
|
||||||
|
import useDataTable from "@/lib/hooks/useDataTable";
|
||||||
|
import { flattenObjectOfObjects } from "@/core/utils/flattenObjectOfObjects";
|
||||||
|
|
||||||
function HideButton({ drawerState, setDrawerState }) {
|
function HideButton({ drawerState, setDrawerState }) {
|
||||||
|
const { hideData } = useDataTable();
|
||||||
|
const flattenHideData = flattenObjectOfObjects(hideData);
|
||||||
|
const falseCount = Object.values(flattenHideData).filter((value) => value === false).length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title="نمایش/مخفی کردن ستون ها">
|
<Tooltip title="نمایش/مخفی کردن ستون ها">
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -12,7 +17,16 @@ function HideButton({ drawerState, setDrawerState }) {
|
|||||||
}}
|
}}
|
||||||
aria-label="hide table column"
|
aria-label="hide table column"
|
||||||
>
|
>
|
||||||
<ViewColumnIcon />
|
<Badge
|
||||||
|
badgeContent={falseCount}
|
||||||
|
color="primary"
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "left",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ViewColumnIcon />
|
||||||
|
</Badge>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const DataTable_TopToolbar = ({
|
|||||||
gap: "0.5rem",
|
gap: "0.5rem",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
py: "0.5rem",
|
p: "0.5rem",
|
||||||
position: stackAlertBanner ? "relative" : "absolute",
|
position: stackAlertBanner ? "relative" : "absolute",
|
||||||
right: 0,
|
right: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ const LoadingHardPage = ({
|
|||||||
)}
|
)}
|
||||||
</LoadingImage>
|
</LoadingImage>
|
||||||
)}
|
)}
|
||||||
<Typography variant={"body2"} sx={{ color: authState ? "error.main" : "primary.main" }}>
|
<Stack sx={{ color: authState ? "error.main" : "primary.main" }}>{label}</Stack>
|
||||||
{label}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Backdrop>
|
</Backdrop>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const authReducer = (state, action) => {
|
|||||||
const AuthContext = createContext();
|
const AuthContext = createContext();
|
||||||
|
|
||||||
export const AuthProvider = ({ children }) => {
|
export const AuthProvider = ({ children }) => {
|
||||||
const [errorState, setErrorState] = useState(null);
|
const [errorState, setErrorState] = useState({ status: null, message: "" });
|
||||||
const [state, dispatch] = useReducer(authReducer, initAuth);
|
const [state, dispatch] = useReducer(authReducer, initAuth);
|
||||||
|
|
||||||
const clearUser = useCallback(() => {
|
const clearUser = useCallback(() => {
|
||||||
@@ -66,7 +66,8 @@ export const AuthProvider = ({ children }) => {
|
|||||||
changeInitAuth(true);
|
changeInitAuth(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setErrorState(true);
|
let status = error.response && error.response.status ? error.response.status : "نامشخص";
|
||||||
|
setErrorState({ status, message: " مشکلی در احراز هویت رخ داده است . دقایقی بعد امتحان کنید!!!" });
|
||||||
}
|
}
|
||||||
}, [clearUser, changeUser, changeAuthState, changeInitAuth]);
|
}, [clearUser, changeUser, changeAuthState, changeInitAuth]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user