changed useDirectory hook calling format
This commit is contained in:
parent
bae8b130de
commit
1f8ba16447
@ -77,9 +77,7 @@ export const useContactProfile = (id) => {
|
|||||||
const [Error, setError] = useState("");
|
const [Error, setError] = useState("");
|
||||||
|
|
||||||
const fetchContactProfile = async () => {
|
const fetchContactProfile = async () => {
|
||||||
const cached = getCachedData("Contact Profile");
|
|
||||||
|
|
||||||
if (!cached || cached.contactId !== id) {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const resp = await DirectoryRepository.GetContactProfile(id);
|
const resp = await DirectoryRepository.GetContactProfile(id);
|
||||||
@ -94,18 +92,20 @@ export const useContactProfile = (id) => {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect( () =>
|
||||||
|
{
|
||||||
|
const cached = getCachedData("Contact Profile");
|
||||||
|
if (!cached || cached.contactId !== id) {
|
||||||
|
fetchContactProfile(id);
|
||||||
} else {
|
} else {
|
||||||
setContactProfile(cached.data);
|
setContactProfile(cached.data);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (id) {
|
|
||||||
fetchContactProfile(id);
|
|
||||||
}
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return { contactProfile, loading, Error };
|
return { contactProfile, loading, Error ,refetch:fetchContactProfile};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useContactNotes = (id, IsActive) => {
|
export const useContactNotes = (id, IsActive) => {
|
||||||
@ -113,10 +113,9 @@ export const useContactNotes = (id, IsActive) => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [Error, setError] = useState("");
|
const [Error, setError] = useState("");
|
||||||
|
|
||||||
const fetchContactNotes = async () => {
|
const fetchContactNotes = async (id,IsActive) => {
|
||||||
const cached = getCachedData("Contact Notes");
|
|
||||||
|
|
||||||
if (!cached || cached.contactId !== id) {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const resp = await DirectoryRepository.GetNote(id, IsActive);
|
const resp = await DirectoryRepository.GetNote(id, IsActive);
|
||||||
@ -131,18 +130,19 @@ export const useContactNotes = (id, IsActive) => {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setContactNotes(cached.data);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
const cached = getCachedData("Contact Notes");
|
||||||
fetchContactNotes(id);
|
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 = () => {
|
export const useOrganization = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user