update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import { Dialog, DialogTitle, IconButton } from "@mui/material";
|
||||
import CreateForm from "./Form";
|
||||
import CreateOrUpdateForm from "../../Forms/CreateOrUpdate";
|
||||
|
||||
const InquiryPrivacyFencingCreate = ({ open, handleClose, mutate }) => {
|
||||
|
||||
@@ -24,7 +24,7 @@ const InquiryPrivacyFencingCreate = ({ open, handleClose, mutate }) => {
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<CreateForm handleClose={handleClose} mutate={mutate} />
|
||||
<CreateOrUpdateForm handleClose={handleClose} mutate={mutate} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
@@ -66,9 +66,9 @@ const initValues = {
|
||||
ronevesht: '',
|
||||
}
|
||||
|
||||
const CreateForm = ({ handleClose, mutate }) => {
|
||||
const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues }) => {
|
||||
const request = useRequest()
|
||||
const { control, watch, register, handleSubmit, setValue, formState: { isSubmitting } } = useForm({ defaultValues: initValues });
|
||||
const { control, watch, register, handleSubmit, setValue, formState: { isSubmitting } } = useForm({ defaultValues: defaultValues || initValues });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData()
|
||||
@@ -567,4 +567,4 @@ const CreateForm = ({ handleClose, mutate }) => {
|
||||
</LocalizationProvider >
|
||||
);
|
||||
};
|
||||
export default CreateForm;
|
||||
export default CreateOrUpdateForm;
|
||||
@@ -1,8 +1,7 @@
|
||||
import MapLoading from "@/core/components/MapLayer/Loading";
|
||||
import MarkerLocation from "@/core/components/MapLayer/MarkerLocation";
|
||||
import { Paper, Stack } from "@mui/material";
|
||||
import { useFormikContext } from "formik";
|
||||
import dynamic from "next/dynamic";
|
||||
import MarkerLocation from "./MarkerLocation";
|
||||
|
||||
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
loading: () => <MapLoading />,
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Button } from "@mui/material";
|
||||
import AddCircleIcon from "@mui/icons-material/AddCircle";
|
||||
import { useState } from "react";
|
||||
import InquiryPrivacyFencingCreate from "@/components/dashboard/inquiryPrivacyFencing/Create";
|
||||
import InquiryPrivacyFencingCreate from "./Actions/Create";
|
||||
|
||||
const Toolbar = ({ mutate }) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const api = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
export const GET_CSRF = api + "/csrf";
|
||||
|
||||
export const GET_USER_ROUTE = api + "/webapi/user/get-permission";
|
||||
export const GET_LOGIN_ROUTE = api + "/login_dev";
|
||||
export const GET_INQUIRY_PRIVACY_FENCING_ROUTE = api + "/api/v3/harim/divarkeshi";
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
import { errorResponse } from "@/core/utils/errorResponse";
|
||||
import { GET_CSRF } from "@/core/utils/routes";
|
||||
import { successRequest } from "@/core/utils/successRequest";
|
||||
import axios from "axios";
|
||||
import { useAuth } from "../contexts/auth";
|
||||
|
||||
const getCsrfToken = async () => {
|
||||
try {
|
||||
const response = await axios.get(GET_CSRF);
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching CSRF token:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const defaultOptions = {
|
||||
data: {},
|
||||
requestOptions: {
|
||||
@@ -28,19 +17,6 @@ const defaultOptions = {
|
||||
|
||||
const useRequest = (initOptions) => {
|
||||
const { logout } = useAuth()
|
||||
const instance = axios.create();
|
||||
instance.interceptors.request.use(
|
||||
async function (config) {
|
||||
if (config.method !== 'get') {
|
||||
const csrfToken = await getCsrfToken();
|
||||
config.headers['X-CSRF-TOKEN'] = csrfToken;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
function (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
const _options = Object.assign({}, defaultOptions, initOptions);
|
||||
|
||||
@@ -48,7 +24,7 @@ const useRequest = (initOptions) => {
|
||||
const mergedOptions = Object.assign({}, _options, options);
|
||||
|
||||
try {
|
||||
const response = await instance({
|
||||
const response = await axios({
|
||||
url,
|
||||
method,
|
||||
data: method === "get" ? null : mergedOptions.data,
|
||||
|
||||
Reference in New Issue
Block a user