Merge branch 'feature/change_edare_to_city_in_damages' into 'develop'
Feature/change edare to city in damages See merge request witel-front-end/rms!95
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import useCities from "@/lib/hooks/useCities";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const CityContent = ({ provinceID, field, fieldState: { error } }) => {
|
||||
const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(provinceID);
|
||||
const { cityList, loadingCityList, errorCityList } = useCities(provinceID);
|
||||
const [prevDependency, setPrevDependency] = useState(provinceID);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -15,22 +15,16 @@ const CityContent = ({ provinceID, field, fieldState: { error } }) => {
|
||||
return (
|
||||
<SelectBox
|
||||
value={
|
||||
!provinceID
|
||||
? "dependency"
|
||||
: errorEdaratList
|
||||
? "error"
|
||||
: loadingEdaratList
|
||||
? "loading"
|
||||
: field.value || ""
|
||||
!provinceID ? "dependency" : errorCityList ? "error" : loadingCityList ? "loading" : field.value || ""
|
||||
}
|
||||
label={"شهرستان"}
|
||||
selectors={edaratList}
|
||||
selectors={cityList}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={loadingEdaratList}
|
||||
errorEcured={errorEdaratList}
|
||||
isLoading={loadingCityList}
|
||||
errorEcured={errorCityList}
|
||||
isDependency={!provinceID}
|
||||
dependencyLabel={"ابتدا استان را انتخاب کنید"}
|
||||
/>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
"use client";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import Toolbar from "./Toolbar";
|
||||
import { GET_TECHNICAL_DAMAGE_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import { GET_TECHNICAL_DAMAGE_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
import useCities from "@/lib/hooks/useCities";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import RowActions from "./RowActions";
|
||||
import DamageItemDialog from "./RowActions/DamageItemDialog";
|
||||
import DamageReportDialog from "./RowActions/DamageReport";
|
||||
import ImageDialog from "./RowActions/ImageDialog";
|
||||
import LocationForm from "./RowActions/LocationForm";
|
||||
import ShowPlate from "./RowActions/ShowPlate";
|
||||
import DamageItemDialog from "./RowActions/DamageItemDialog";
|
||||
import DamageReportDialog from "./RowActions/DamageReport";
|
||||
import Toolbar from "./Toolbar";
|
||||
|
||||
const OperatorList = () => {
|
||||
const statusOptions = [
|
||||
@@ -94,7 +94,7 @@ const OperatorList = () => {
|
||||
grow: false,
|
||||
size: 120,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
|
||||
const { cityList, loadingCityList, errorCityList } = useCities(
|
||||
props.dependencyFieldValue.value
|
||||
);
|
||||
const [prevDependency, setPrevDependency] = useState(props.dependencyFieldValue.value);
|
||||
@@ -103,20 +103,20 @@ const OperatorList = () => {
|
||||
if (props.dependencyFieldValue.value === "") {
|
||||
return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }];
|
||||
}
|
||||
if (loadingEdaratList) {
|
||||
if (loadingCityList) {
|
||||
return [{ value: "loading", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
if (errorEdaratList) {
|
||||
if (errorCityList) {
|
||||
return [{ value: "error", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
return [
|
||||
{ value: "", label: "کل شهر ها" },
|
||||
...edaratList.map((edare) => ({
|
||||
value: edare.id,
|
||||
label: edare.name_fa,
|
||||
...cityList.map((city) => ({
|
||||
value: city.id,
|
||||
label: city.name_fa,
|
||||
})),
|
||||
];
|
||||
}, [edaratList, loadingEdaratList, errorEdaratList]);
|
||||
}, [cityList, loadingCityList, errorCityList]);
|
||||
useEffect(() => {
|
||||
if (prevDependency === props.dependencyFieldValue?.value) return;
|
||||
props.handleChange({ ...props.filterParameters, value: "" });
|
||||
@@ -128,7 +128,7 @@ const OperatorList = () => {
|
||||
value={
|
||||
props.dependencyFieldValue?.value === ""
|
||||
? "empty"
|
||||
: loadingEdaratList
|
||||
: loadingCityList
|
||||
? "loading"
|
||||
: props.filterParameters.value
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ const DamagesReportPage = () => {
|
||||
setData({
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.cities.map((edare) => {
|
||||
const filteredReports = result.activities.find((report) => report.city_id == edare.id);
|
||||
...result.cities.map((city) => {
|
||||
const filteredReports = result.activities.find((report) => report.city_id == city.id);
|
||||
return {
|
||||
edare_name: edare.name_fa,
|
||||
edare_name: city.name_fa,
|
||||
...filteredReports,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -198,7 +198,7 @@ const ReportPage = () => {
|
||||
};
|
||||
}),
|
||||
]);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
} else {
|
||||
try {
|
||||
const response = await requestServer(`${GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
@@ -222,7 +222,7 @@ const ReportPage = () => {
|
||||
};
|
||||
}),
|
||||
]);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
@@ -9,7 +9,7 @@ const useDamageItemList = () => {
|
||||
const [errorDamageItemList, setErrorDamageItemList] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
const fetchDamageItem = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_DAMAGE_ITEM_LIST}`);
|
||||
setDamageItemList(response.data.data);
|
||||
@@ -20,7 +20,7 @@ const useDamageItemList = () => {
|
||||
}
|
||||
};
|
||||
|
||||
fetchCities();
|
||||
fetchDamageItem();
|
||||
}, []);
|
||||
|
||||
return { damageItemList, loadingDamageItemList, errorDamageItemList };
|
||||
|
||||
@@ -10,19 +10,19 @@ const usePrevStateOpinion = () => {
|
||||
const [errorMessage, setErrorMessage] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
const fetchStateOpnion = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_PREV_STATE_OPINION}`);
|
||||
setMessage(response.data.message);
|
||||
setLoadingMessage(false);
|
||||
} catch (e) {
|
||||
console.error("Error fetching cities:", e);
|
||||
console.error("Error fetching state:", e);
|
||||
setErrorMessage(e);
|
||||
setLoadingMessage(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCities();
|
||||
fetchStateOpnion();
|
||||
}, []);
|
||||
|
||||
return { message, loadingMessage, errorMessage };
|
||||
|
||||
@@ -9,7 +9,7 @@ const useProvinces = () => {
|
||||
const [errorProvinces, setErrorProvinces] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
const fetchProvinces = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_PROVINCE_LISTS}`);
|
||||
setProvinces(response.data.data);
|
||||
@@ -20,7 +20,7 @@ const useProvinces = () => {
|
||||
}
|
||||
};
|
||||
|
||||
fetchCities();
|
||||
fetchProvinces();
|
||||
}, []);
|
||||
|
||||
return { provinces, loadingProvinces, errorProvinces };
|
||||
|
||||
Reference in New Issue
Block a user