all good
This commit is contained in:
parent
47d89f6fad
commit
017902b8e6
82 changed files with 331466 additions and 54841 deletions
|
|
@ -318,6 +318,7 @@ export default function App() {
|
|||
|
||||
const savedSearches = useSavedSearches(user?.id ?? null);
|
||||
const [showSaveModal, setShowSaveModal] = useState(false);
|
||||
const [editingSearch, setEditingSearch] = useState<{ id: string; name: string } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
|
|
@ -374,11 +375,52 @@ export default function App() {
|
|||
}
|
||||
setRouteHash(targetHash);
|
||||
setActivePage(page);
|
||||
setEditingSearch(null);
|
||||
if (targetHash) scrollToHash(targetHash);
|
||||
},
|
||||
[inviteCode]
|
||||
);
|
||||
|
||||
const handleEditSearch = useCallback(
|
||||
(id: string, name: string, params: string) => {
|
||||
const search = params.startsWith('?') ? params : `?${params}`;
|
||||
dashboardSearchRef.current = search;
|
||||
const url = `/dashboard${search}`;
|
||||
window.history.pushState({ page: 'dashboard', hash: '' }, '', url);
|
||||
setMapUrlState(parseUrlState());
|
||||
setDashboardRouteKey(search);
|
||||
setRouteHash('');
|
||||
setActivePage('dashboard');
|
||||
setEditingSearch({ id, name });
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleCancelEdit = useCallback(() => {
|
||||
setEditingSearch(null);
|
||||
}, []);
|
||||
|
||||
const updateEditingSearch = useCallback(
|
||||
async (params: string) => {
|
||||
if (!editingSearch) return;
|
||||
await savedSearches.updateSearchParams(editingSearch.id, params);
|
||||
setEditingSearch(null);
|
||||
},
|
||||
[editingSearch, savedSearches]
|
||||
);
|
||||
|
||||
const handleUpdateEdit = useCallback(
|
||||
async (params: string) => {
|
||||
try {
|
||||
await updateEditingSearch(params);
|
||||
navigateTo('saved');
|
||||
} catch {
|
||||
// Error stored on savedSearches.error
|
||||
}
|
||||
},
|
||||
[updateEditingSearch, navigateTo]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (authLoading || !user || postAuthIntent !== 'checkout') return;
|
||||
|
||||
|
|
@ -439,6 +481,8 @@ export default function App() {
|
|||
if (page === 'dashboard') {
|
||||
setMapUrlState(parseUrlState());
|
||||
setDashboardRouteKey(window.location.search);
|
||||
} else {
|
||||
setEditingSearch(null);
|
||||
}
|
||||
};
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
|
|
@ -517,8 +561,17 @@ export default function App() {
|
|||
onToggleTheme={toggleTheme}
|
||||
exportState={activePage === 'dashboard' ? exportState : null}
|
||||
dashboardParams={activePage === 'dashboard' ? dashboardParams : ''}
|
||||
onSaveSearch={activePage === 'dashboard' && user ? () => setShowSaveModal(true) : null}
|
||||
onSaveSearch={
|
||||
activePage === 'dashboard' && user
|
||||
? editingSearch
|
||||
? () => handleUpdateEdit(dashboardParams)
|
||||
: () => setShowSaveModal(true)
|
||||
: null
|
||||
}
|
||||
savingSearch={savedSearches.saving}
|
||||
editingSearch={activePage === 'dashboard' ? editingSearch : null}
|
||||
onCancelEdit={handleCancelEdit}
|
||||
onUpdateEdit={() => handleUpdateEdit(dashboardParams)}
|
||||
user={user}
|
||||
onLoginClick={() => openAuthModal('login')}
|
||||
onRegisterClick={() => openAuthModal('register')}
|
||||
|
|
@ -553,9 +606,7 @@ export default function App() {
|
|||
onDeleteSearch={savedSearches.deleteSearch}
|
||||
onUpdateSearchNotes={savedSearches.updateSearchNotes}
|
||||
onUpdateSearchName={savedSearches.updateSearchName}
|
||||
onOpenSearch={(params) => {
|
||||
window.location.href = `/dashboard?${params}`;
|
||||
}}
|
||||
onOpenSearch={handleEditSearch}
|
||||
/>
|
||||
) : activePage === 'account' && user ? (
|
||||
<AccountPage
|
||||
|
|
@ -609,6 +660,10 @@ export default function App() {
|
|||
deferTutorial={licenseSuccessStatus !== 'hidden'}
|
||||
onSaveSearch={user ? savedSearches.saveSearch : undefined}
|
||||
savingSearch={savedSearches.saving}
|
||||
editingSearch={editingSearch}
|
||||
onCancelEdit={handleCancelEdit}
|
||||
onUpdateEdit={handleUpdateEdit}
|
||||
onUpdateEditInPlace={updateEditingSearch}
|
||||
/>
|
||||
)}
|
||||
</Suspense>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue