build and format
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_HISTORY_LIST } from "@/core/utils/routes";
|
||||
|
||||
export const useHistory = (rowId) => {
|
||||
const requestServer = useRequest();
|
||||
const [historyData, setHistoryData] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!rowId) return;
|
||||
|
||||
const fetchHistory = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await requestServer(`${GET_HISTORY_LIST}/${rowId}`);
|
||||
setHistoryData(response.data.data);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchHistory();
|
||||
}, [rowId]);
|
||||
|
||||
return { historyData, loading, error };
|
||||
};
|
||||
import { useState, useEffect } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_HISTORY_LIST } from "@/core/utils/routes";
|
||||
|
||||
export const useHistory = (rowId) => {
|
||||
const requestServer = useRequest();
|
||||
const [historyData, setHistoryData] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!rowId) return;
|
||||
|
||||
const fetchHistory = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await requestServer(`${GET_HISTORY_LIST}/${rowId}`);
|
||||
setHistoryData(response.data.data);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchHistory();
|
||||
}, [rowId]);
|
||||
|
||||
return { historyData, loading, error };
|
||||
};
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { GET_INQUIRY_PRIVACY_STATE_LIST } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useInquiryPrivacyState = () => {
|
||||
const requestServer = useRequest();
|
||||
const [itemsList, setItemsList] = useState([]);
|
||||
const [loadingItemsList, setLoadingItemsList] = useState(true);
|
||||
const [errorItemsList, setErrorItemsList] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchItems = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_INQUIRY_PRIVACY_STATE_LIST}`);
|
||||
setItemsList(response.data.data);
|
||||
setLoadingItemsList(false);
|
||||
setErrorItemsList(false);
|
||||
} catch (e) {
|
||||
setErrorItemsList(e);
|
||||
setLoadingItemsList(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchItems();
|
||||
}, []);
|
||||
|
||||
return { itemsList, loadingItemsList, errorItemsList };
|
||||
};
|
||||
|
||||
export default useInquiryPrivacyState;
|
||||
import { GET_INQUIRY_PRIVACY_STATE_LIST } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useInquiryPrivacyState = () => {
|
||||
const requestServer = useRequest();
|
||||
const [itemsList, setItemsList] = useState([]);
|
||||
const [loadingItemsList, setLoadingItemsList] = useState(true);
|
||||
const [errorItemsList, setErrorItemsList] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchItems = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_INQUIRY_PRIVACY_STATE_LIST}`);
|
||||
setItemsList(response.data.data);
|
||||
setLoadingItemsList(false);
|
||||
setErrorItemsList(false);
|
||||
} catch (e) {
|
||||
setErrorItemsList(e);
|
||||
setLoadingItemsList(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchItems();
|
||||
}, []);
|
||||
|
||||
return { itemsList, loadingItemsList, errorItemsList };
|
||||
};
|
||||
|
||||
export default useInquiryPrivacyState;
|
||||
|
||||
Reference in New Issue
Block a user