Resolve #86c2a59ap "Feature/change api v2 to v3 "
This commit is contained in:
@@ -4,9 +4,9 @@ import { Stack } from "@mui/material";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
<Stack direction={"row"} spacing={1}>
|
||||
<ComplaintList mutate={mutate} />
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@ import { Stack } from "@mui/material";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
<Stack direction={"row"} spacing={1}>
|
||||
<ComplaintList mutate={mutate} />
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import ObservedGashtCreate from "./Actions/ObservedGashtCreate";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<Stack direction={"row"} spacing={1}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
<OperatorCreate mutate={mutate} />
|
||||
<ObservedGashtCreate mutate={mutate} />
|
||||
|
||||
@@ -88,7 +88,11 @@ const CompeleteRequest = ({ allData, handlePrev, mutate, setOpen }) => {
|
||||
|
||||
const sendOtp = async (data) => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_OTP_TOKEN}?phone_number=${data.phoneNumber}`, "get");
|
||||
await requestServer(GET_OTP_TOKEN, "post", {
|
||||
data: {
|
||||
phone_number: data.phoneNumber,
|
||||
},
|
||||
});
|
||||
setOtpSended(true);
|
||||
setDelayPerRequest(true);
|
||||
setValueSend("phoneNumber", data.phoneNumber);
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Button, FormControl, InputLabel, OutlinedInput } from "@mui/material";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import ForwardToInboxIcon from "@mui/icons-material/ForwardToInbox";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_OTP_TOKEN, VERIFY_OTP } from "@/core/utils/routes";
|
||||
import { formatCounter } from "@/core/utils/formatCounter";
|
||||
|
||||
const PhoneValidation = ({ tabState, setTabState }) => {
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const [phoneNumber, setPhoneNumber] = useState("");
|
||||
const [verificationCode, setVerificationCode] = useState("");
|
||||
const [validPhone, setValidPhone] = useState(false);
|
||||
const [delayPerRequest, setDelayPerRequest] = useState(false);
|
||||
const [counter, setCounter] = useState(120);
|
||||
const [otpSended, setOtpSended] = useState(false);
|
||||
const [readyToVerify, setReadyToVerify] = useState(false);
|
||||
|
||||
const handleNumericInput = (e) => {
|
||||
e.target.value = e.target.value.replace(/[^0-9]/g, "");
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (phoneNumber.length === 11) {
|
||||
setValidPhone(true);
|
||||
} else {
|
||||
setValidPhone(false);
|
||||
}
|
||||
if (verificationCode.length === 6 && phoneNumber.length === 11) {
|
||||
setReadyToVerify(true);
|
||||
} else {
|
||||
setReadyToVerify(false);
|
||||
}
|
||||
}, [phoneNumber, verificationCode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (counter === 0) {
|
||||
setDelayPerRequest(false);
|
||||
return;
|
||||
}
|
||||
if (delayPerRequest && counter > 0) {
|
||||
const timer = setInterval(() => {
|
||||
setCounter((prevCounter) => prevCounter - 1);
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
}
|
||||
}, [counter, delayPerRequest]);
|
||||
|
||||
const sendOtp = () => {
|
||||
if (!validPhone) return false;
|
||||
requestServer(`${GET_OTP_TOKEN}?phone_number=${phoneNumber}`, "get")
|
||||
.then((response) => {})
|
||||
.catch(() => {});
|
||||
//////////**** (mohammad) this part should keep in success but for now we go next level ****////////////
|
||||
setOtpSended(true);
|
||||
setDelayPerRequest(true);
|
||||
};
|
||||
|
||||
const phoneRegister = () => {
|
||||
const formData = new FormData();
|
||||
formData.append("phone_number", phoneNumber);
|
||||
formData.append("verification_code", verificationCode);
|
||||
|
||||
setTabState(tabState + 1);
|
||||
requestServer(VERIFY_OTP, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
my: 3,
|
||||
}}
|
||||
>
|
||||
<Box sx={{ display: "flex", alignItems: "center", gap: 2, width: { xs: "100%", sm: "70%" } }}>
|
||||
<FormControl size="small" fullWidth variant="outlined">
|
||||
<InputLabel htmlFor="phone_number">شماره تلفن مامور گشت</InputLabel>
|
||||
<OutlinedInput
|
||||
id="phone_number"
|
||||
label={"شماره تلفن مامور گشت"}
|
||||
disabled={delayPerRequest}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
value={phoneNumber}
|
||||
onChange={(e) => setPhoneNumber(e.target.value)}
|
||||
onInput={handleNumericInput}
|
||||
type="text"
|
||||
inputProps={{
|
||||
maxLength: 11,
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<Button
|
||||
onClick={sendOtp}
|
||||
disabled={!validPhone || delayPerRequest}
|
||||
variant="contained"
|
||||
color="success"
|
||||
sx={{ width: "200px", height: "37px" }}
|
||||
endIcon={<ForwardToInboxIcon />}
|
||||
>
|
||||
{delayPerRequest ? formatCounter(counter) : "دریافت کد"}
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default PhoneValidation;
|
||||
@@ -1,13 +1,13 @@
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
import { Stack } from "@mui/material";
|
||||
import OperatorCreate from "./Actions/Create";
|
||||
import { Box } from "@mui/material";
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<OperatorCreate table={table} mutate={mutate} />
|
||||
<Stack direction={"row"} spacing={1}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
</Box>
|
||||
<OperatorCreate table={table} mutate={mutate} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default Toolbar;
|
||||
|
||||
@@ -7,7 +7,7 @@ const Toolbar = ({ table, filterData, mutate }) => {
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasCreatePermission = userPermissions?.includes("add-safety-and-privacy");
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<Stack direction={"row"} spacing={1}>
|
||||
<PrintExcel filterData={filterData} table={table} />
|
||||
{hasCreatePermission && <StepOne mutate={mutate} />}
|
||||
</Stack>
|
||||
|
||||
@@ -41,7 +41,7 @@ export const GET_ROAD_PATROL_OPERATOR_REPORT = api + "/v2/road_patrols/operator/
|
||||
export const GET_ROAD_PATROL_SUPERVISOR_REPORT = api + "/v2/road_patrols/operator/report";
|
||||
export const CREATE_PATROL = api + "/api/v3/road_patrols/store";
|
||||
export const GET_FMS_DATA = api + "/api/v3/fms_vehicle/get_activity";
|
||||
export const GET_OTP_TOKEN = api + "/v2/get_otp_token";
|
||||
export const GET_OTP_TOKEN = api + "/api/v3/otp/get_token";
|
||||
export const GET_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/road_patrol_reports/country_activity";
|
||||
export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/road_patrol_reports/province_activity";
|
||||
|
||||
@@ -58,8 +58,8 @@ export const EXPORT_PROVINCE_ROAD_ITEM_REPORTS_PER_SUB_ITEM =
|
||||
api + "/api/v3/road_item_reports/province_activity_excel_per_sub_item";
|
||||
export const EXPORT_COUNTRY_ROAD_ITEM_REPORTS_PER_SUB_ITEM =
|
||||
api + "/api/v3/road_item_reports/country_activity_excel_per_sub_item";
|
||||
export const GET_ROAD_ITEMS_ITEM = api + "/v2/items";
|
||||
export const GET_ROAD_ITEMS_SUB_ITEM = api + "/v2/sub_items";
|
||||
export const GET_ROAD_ITEMS_ITEM = api + "/api/v3/items";
|
||||
export const GET_ROAD_ITEMS_SUB_ITEM = api + "/api/v3/sub_items";
|
||||
export const GET_EDARAT_LISTS = api + "/public/contents/edarate_shahri_by_province";
|
||||
export const CREATE_ROAD_ITEMS = api + "/api/v3/road_items/store";
|
||||
export const UPDATE_ROAD_ITEMS = api + "/api/v3/road_items/update";
|
||||
|
||||
Reference in New Issue
Block a user