Add loadApplications callback
cgen-a629593df2314e599febb9ee9d6fb0ec
This commit is contained in:
parent
11525c5170
commit
0e4696fd01
1 changed files with 25 additions and 0 deletions
|
|
@ -112,6 +112,31 @@ export default function Admin() {
|
||||||
.catch(() => void 0);
|
.catch(() => void 0);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const loadApplications = useCallback(async () => {
|
||||||
|
if (!user?.id) return;
|
||||||
|
setApplicationsLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`/api/applications?owner=${encodeURIComponent(user.id)}`,
|
||||||
|
);
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
setApplications(Array.isArray(data) ? data : []);
|
||||||
|
} else {
|
||||||
|
setApplications([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Failed to load applications:", error);
|
||||||
|
setApplications([]);
|
||||||
|
} finally {
|
||||||
|
setApplicationsLoading(false);
|
||||||
|
}
|
||||||
|
}, [user?.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadApplications().catch(() => undefined);
|
||||||
|
}, [loadApplications]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue