complete design of adding new test and bundling and saving map data next step...

This commit is contained in:
2024-10-26 05:31:11 +00:00
committed by AmirHossein Mahmoodi
parent 3058fc8c7b
commit 45d1665155
22 changed files with 1363 additions and 46 deletions

View File

@@ -1,6 +1,5 @@
import { useState, useEffect } from "react";
import axios from "axios";
import { GET_PROVINCE_LISTS } from "@/core/utils/routes";
import {useEffect, useState} from "react";
import {GET_PROVINCE_LISTS} from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
const useProvinces = () => {
@@ -25,7 +24,7 @@ const useProvinces = () => {
fetchCities(); // Call the fetch function
}, []); // Empty dependency array to ensure it only runs once
return { provinces, loadingProvinces, errorProvinces };
return {provinces, loadingProvinces, errorProvinces};
};
export default useProvinces;

30
src/lib/hooks/useTest.js Normal file
View File

@@ -0,0 +1,30 @@
import {useEffect, useState} from "react";
import {GET_TESTS_LIST} from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
const useTest = () => {
const requestServer = useRequest();
const [tests, setTests] = useState([]);
const [loadingTests, setLoadingTests] = useState(true);
const [errorTests, setErrorTests] = useState(null);
useEffect(() => {
const fetchTests = async () => {
try {
const response = await requestServer(`${GET_TESTS_LIST}`);
setTests(response.data.data);
setLoadingTests(false);
} catch (e) {
console.error("Error fetching tests types:", e);
setErrorTests(e);
setLoadingTests(false);
}
};
fetchTests();
}, []);
return {tests, loadingTests, errorTests};
};
export default useTest;