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