changed useDirectory hook calling format

This commit is contained in:
Pramod Mahajan 2025-05-29 17:26:07 +05:30
parent b9f24e9954
commit 5a59e79160

View File

@ -77,9 +77,7 @@ export const useContactProfile = (id) => {
const [Error, setError] = useState("");
const fetchContactProfile = async () => {
const cached = getCachedData("Contact Profile");
if (!cached || cached.contactId !== id) {
setLoading(true);
try {
const resp = await DirectoryRepository.GetContactProfile(id);
@ -94,18 +92,20 @@ export const useContactProfile = (id) => {
} finally {
setLoading(false);
}
};
useEffect( () =>
{
const cached = getCachedData("Contact Profile");
if (!cached || cached.contactId !== id) {
fetchContactProfile(id);
} else {
setContactProfile(cached.data);
}
};
useEffect(() => {
if (id) {
fetchContactProfile(id);
}
}, [id]);
return { contactProfile, loading, Error };
return { contactProfile, loading, Error ,refetch:fetchContactProfile};
};
export const useContactNotes = (id, IsActive) => {
@ -113,10 +113,9 @@ export const useContactNotes = (id, IsActive) => {
const [loading, setLoading] = useState(false);
const [Error, setError] = useState("");
const fetchContactNotes = async () => {
const cached = getCachedData("Contact Notes");
const fetchContactNotes = async (id,IsActive) => {
if (!cached || cached.contactId !== id) {
setLoading(true);
try {
const resp = await DirectoryRepository.GetNote(id, IsActive);
@ -131,18 +130,19 @@ export const useContactNotes = (id, IsActive) => {
} finally {
setLoading(false);
}
} else {
setContactNotes(cached.data);
}
};
useEffect(() => {
if (id) {
fetchContactNotes(id);
const cached = getCachedData("Contact Notes");
if (!cached || cached.contactId !== id) {
fetchContactNotes(id,IsActive);
} else {
setContactNotes(cached.data);
}
}, [id]);
}, [id,IsActive]);
return { contactNotes, loading, Error };
return { contactNotes, loading, Error,refetch:fetchContactNotes };
};
export const useOrganization = () => {