[WIP] work on tree for move operation
This commit is contained in:
parent
de96ce6f16
commit
10a5bb3ba1
|
@ -5,9 +5,8 @@ import { axiosConfigWithoutToken } from "./config/axiosConfig";
|
||||||
import InnovenergyTextfield from "./components/Layout/InnovenergyTextfield";
|
import InnovenergyTextfield from "./components/Layout/InnovenergyTextfield";
|
||||||
|
|
||||||
const loginUser = async (username: string, password: string) => {
|
const loginUser = async (username: string, password: string) => {
|
||||||
return axiosConfigWithoutToken.post("/Login", {
|
return axiosConfigWithoutToken.post("/Login", null, {
|
||||||
username,
|
params: { username, password },
|
||||||
password,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ const Login = ({ setToken }: { setToken: (value: string) => void }) => {
|
||||||
|
|
||||||
const verifyToken = async (token: string) => {
|
const verifyToken = async (token: string) => {
|
||||||
axiosConfigWithoutToken.get("/GetAllInstallations", {
|
axiosConfigWithoutToken.get("/GetAllInstallations", {
|
||||||
headers: { auth: token },
|
params: { authToken: token },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ import { I_Folder, I_Installation } from "../../util/types";
|
||||||
interface GroupContextProviderProps {
|
interface GroupContextProviderProps {
|
||||||
currentType: string;
|
currentType: string;
|
||||||
setCurrentType: (value: string) => void;
|
setCurrentType: (value: string) => void;
|
||||||
isMove: boolean;
|
|
||||||
setIsMove: (value: boolean) => void;
|
|
||||||
data: (I_Folder | I_Installation)[];
|
data: (I_Folder | I_Installation)[];
|
||||||
setData: (value: (I_Folder | I_Installation)[]) => void;
|
setData: (value: (I_Folder | I_Installation)[]) => void;
|
||||||
fetchData: () => Promise<void>;
|
fetchData: () => Promise<void>;
|
||||||
|
@ -19,8 +17,6 @@ interface GroupContextProviderProps {
|
||||||
export const GroupContext = createContext<GroupContextProviderProps>({
|
export const GroupContext = createContext<GroupContextProviderProps>({
|
||||||
currentType: "",
|
currentType: "",
|
||||||
setCurrentType: () => {},
|
setCurrentType: () => {},
|
||||||
isMove: false,
|
|
||||||
setIsMove: () => {},
|
|
||||||
data: [],
|
data: [],
|
||||||
setData: () => {},
|
setData: () => {},
|
||||||
fetchData: () => Promise.resolve(),
|
fetchData: () => Promise.resolve(),
|
||||||
|
@ -31,7 +27,6 @@ export const GroupContext = createContext<GroupContextProviderProps>({
|
||||||
|
|
||||||
const GroupContextProvider = ({ children }: { children: ReactNode }) => {
|
const GroupContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const [currentType, setCurrentType] = useState("");
|
const [currentType, setCurrentType] = useState("");
|
||||||
const [isMove, setIsMove] = useState(false);
|
|
||||||
const [data, setData] = useState<(I_Folder | I_Installation)[]>([]);
|
const [data, setData] = useState<(I_Folder | I_Installation)[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [getError, setGetError] = useState(false);
|
const [getError, setGetError] = useState(false);
|
||||||
|
@ -55,8 +50,7 @@ const GroupContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
value={{
|
value={{
|
||||||
currentType,
|
currentType,
|
||||||
setCurrentType,
|
setCurrentType,
|
||||||
isMove,
|
|
||||||
setIsMove,
|
|
||||||
data,
|
data,
|
||||||
setData,
|
setData,
|
||||||
fetchData,
|
fetchData,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { Button, CircularProgress, Grid, InputLabel } from "@mui/material";
|
import { Button, CircularProgress, Grid, InputLabel } from "@mui/material";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import { useContext, useState } from "react";
|
import { useState } from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
import axiosConfig from "../../config/axiosConfig";
|
import axiosConfig from "../../config/axiosConfig";
|
||||||
import { I_Folder } from "../../util/types";
|
import { I_Folder } from "../../util/types";
|
||||||
import { GroupContext } from "../Context/GroupContextProvider";
|
|
||||||
import InnovenergySnackbar from "../InnovenergySnackbar";
|
import InnovenergySnackbar from "../InnovenergySnackbar";
|
||||||
import InnovenergyTextfield from "../Layout/InnovenergyTextfield";
|
import InnovenergyTextfield from "../Layout/InnovenergyTextfield";
|
||||||
import MoveTree from "./Tree/MoveTree";
|
import MoveTree from "./Tree/MoveTree";
|
||||||
|
@ -21,7 +20,6 @@ const updateFolder = (data: I_Folder) => {
|
||||||
const FolderForm = (props: I_CustomerFormProps) => {
|
const FolderForm = (props: I_CustomerFormProps) => {
|
||||||
const { values, id } = props;
|
const { values, id } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { isMove, setIsMove } = useContext(GroupContext);
|
|
||||||
|
|
||||||
const [snackbarOpen, setSnackbarOpen] = useState(false);
|
const [snackbarOpen, setSnackbarOpen] = useState(false);
|
||||||
const [error, setError] = useState();
|
const [error, setError] = useState();
|
||||||
|
@ -77,20 +75,13 @@ const FolderForm = (props: I_CustomerFormProps) => {
|
||||||
handleChange={formik.handleChange}
|
handleChange={formik.handleChange}
|
||||||
/>
|
/>
|
||||||
<Grid container direction="row" alignItems="center" spacing={2}>
|
<Grid container direction="row" alignItems="center" spacing={2}>
|
||||||
<Grid item xs={3}>
|
<Grid item xs={3} alignItems="start">
|
||||||
<InputLabel>
|
<InputLabel style={{ marginBottom: "180px" }}>
|
||||||
<FormattedMessage id="location" defaultMessage="Location" />
|
<FormattedMessage id="location" defaultMessage="Location" />
|
||||||
</InputLabel>
|
</InputLabel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={9} display="inline">
|
<Grid item xs={9} display="inline">
|
||||||
<Button
|
<MoveTree setSelectedParentId={setSelectedParentId} />
|
||||||
variant="outlined"
|
|
||||||
sx={{ height: 40, ml: 2 }}
|
|
||||||
onClick={() => setIsMove(true)}
|
|
||||||
>
|
|
||||||
<FormattedMessage id="move" defaultMessage="Move" />
|
|
||||||
</Button>
|
|
||||||
{isMove && <MoveTree setSelectedParentId={setSelectedParentId} />}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid container justifyContent="flex-end" sx={{ pt: 1 }}>
|
<Grid container justifyContent="flex-end" sx={{ pt: 1 }}>
|
||||||
|
|
|
@ -43,7 +43,13 @@ const GroupTree = (props: GroupTreeProps) => {
|
||||||
aria-label="rich object"
|
aria-label="rich object"
|
||||||
defaultCollapseIcon={<ExpandMoreIcon />}
|
defaultCollapseIcon={<ExpandMoreIcon />}
|
||||||
defaultExpandIcon={<ChevronRightIcon />}
|
defaultExpandIcon={<ChevronRightIcon />}
|
||||||
sx={{ height: 200, flexGrow: 1, width: 400, overflow: "auto" }}
|
sx={{
|
||||||
|
height: 200,
|
||||||
|
flexGrow: 1,
|
||||||
|
width: 400,
|
||||||
|
overflow: "auto",
|
||||||
|
overflowX: "hidden",
|
||||||
|
}}
|
||||||
onNodeSelect={(e: any, id: string) =>
|
onNodeSelect={(e: any, id: string) =>
|
||||||
props.setSelectedParentId(parseInt(id))
|
props.setSelectedParentId(parseInt(id))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,13 @@ export const axiosConfigWithoutToken = axios.create({
|
||||||
const axiosConfig = axios.create({
|
const axiosConfig = axios.create({
|
||||||
baseURL: "https://localhost:7087/api",
|
baseURL: "https://localhost:7087/api",
|
||||||
});
|
});
|
||||||
|
axiosConfig.defaults.params = {};
|
||||||
axiosConfig.interceptors.request.use(
|
axiosConfig.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
const tokenString = sessionStorage.getItem("token");
|
const tokenString = sessionStorage.getItem("token");
|
||||||
const token = tokenString !== null ? JSON.parse(tokenString) : "";
|
const token = tokenString !== null ? JSON.parse(tokenString) : "";
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers.auth = token;
|
config.params["authToken"] = token;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue