Feature/road safety form

This commit is contained in:
2024-09-29 07:27:17 +00:00
committed by AmirHossein Mahmoodi
parent bfa165408f
commit dceaf5332b
33 changed files with 883 additions and 8 deletions

View File

@@ -1,8 +1,10 @@
import { useState, useEffect } from "react";
import axios from "axios";
import { GET_PROVINCE_LISTS } from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
const useProvinces = () => {
const requestServer = useRequest()
const [provinces, setProvinces] = useState([]);
const [loadingProvinces, setLoadingProvinces] = useState(true);
const [errorProvinces, setErrorProvinces] = useState(null);
@@ -10,7 +12,7 @@ const useProvinces = () => {
useEffect(() => {
const fetchCities = async () => {
try {
const response = await axios.get(`${GET_PROVINCE_LISTS}`); // Fetch the cities from the API
const response = await requestServer(`${GET_PROVINCE_LISTS}`); // Fetch the cities from the API
setProvinces(response.data.data); // Set the cities data
setLoadingProvinces(false); // Set loading to false after successful fetch
} catch (e) {