good stuff

This commit is contained in:
Andras Schmelczer 2026-03-15 21:10:54 +00:00
parent ea8389ef40
commit f4de0eeb9f
39 changed files with 5165 additions and 348 deletions

View file

@ -24,6 +24,7 @@ export interface SavedProperty {
address: string;
postcode: string;
data: SavedPropertyData;
notes: string;
created: string;
}
@ -58,6 +59,7 @@ export function useSavedProperties(userId: string | null) {
address: raw.address as string,
postcode: raw.postcode as string,
data,
notes: (raw.notes as string) || '',
created: r.created,
};
})
@ -135,6 +137,15 @@ export function useSavedProperties(userId: string | null) {
[properties]
);
const updatePropertyNotes = useCallback(async (id: string, notes: string) => {
try {
await pb.collection('saved_properties').update(id, { notes });
setProperties((prev) => prev.map((p) => (p.id === id ? { ...p, notes } : p)));
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to update notes');
}
}, []);
return {
properties,
loading,
@ -144,5 +155,6 @@ export function useSavedProperties(userId: string | null) {
deleteProperty,
isPropertySaved,
getSavedPropertyId,
updatePropertyNotes,
};
}

View file

@ -8,6 +8,7 @@ export interface SavedSearch {
name: string;
params: string;
screenshotUrl: string;
notes: string;
created: string;
}
@ -34,6 +35,7 @@ export function useSavedSearches(userId: string | null) {
screenshotUrl: (r as Record<string, unknown>).screenshot
? pb.files.getURL(r, (r as Record<string, unknown>).screenshot as string)
: '',
notes: ((r as Record<string, unknown>).notes as string) || '',
created: r.created,
}))
);
@ -72,9 +74,10 @@ export function useSavedSearches(userId: string | null) {
})
.then((blob) => {
const patch = new FormData();
patch.append('screenshot', blob, 'screenshot.png');
patch.append('screenshot', blob, 'screenshot.jpg');
return pb.collection('saved_searches').update(record.id, patch);
})
.then(() => fetchSearches())
.catch((err) => {
console.warn('Background screenshot failed:', err);
});
@ -100,5 +103,23 @@ export function useSavedSearches(userId: string | null) {
}
}, []);
return { searches, loading, saving, error, fetchSearches, saveSearch, deleteSearch };
const updateSearchNotes = useCallback(async (id: string, notes: string) => {
try {
await pb.collection('saved_searches').update(id, { notes });
setSearches((prev) => prev.map((s) => (s.id === id ? { ...s, notes } : s)));
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to update notes');
}
}, []);
return {
searches,
loading,
saving,
error,
fetchSearches,
saveSearch,
deleteSearch,
updateSearchNotes,
};
}