Skip to content

Commit a786fa7

Browse files
committed
Finish UI
1 parent 14be87b commit a786fa7

File tree

6 files changed

+179
-8
lines changed

6 files changed

+179
-8
lines changed

app/[board_name]/[layout_id]/[size_id]/[set_ids]/[angle]/list/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default async function DynamicResultsPage({
2929
fetchBoardDetails(parsedParams.board_name, parsedParams.layout_id, parsedParams.size_id, parsedParams.set_ids),
3030
]);
3131

32-
if (!fetchedResults || fetchedResults.climbs.length === 0) {
32+
if (!fetchedResults || fetchedResults.climbs?.length === 0) {
3333
notFound();
3434
}
3535

app/components/search-drawer/basic-search-form.tsx

Lines changed: 128 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
'use client';
22

33
import React from 'react';
4-
import { Form, InputNumber, Row, Col, Select, Input } from 'antd';
4+
import { Form, InputNumber, Row, Col, Select, Input, Switch, Alert, Typography } from 'antd';
55
import { TENSION_KILTER_GRADES } from '@/app/lib/board-data';
66
import { useUISearchParams } from '@/app/components/queue-control/ui-searchparams-provider';
77
import SearchClimbNameInput from './search-climb-name-input';
8+
import { useBoardProvider } from '../board-provider/board-provider-context';
9+
10+
const { Title } = Typography;
811

912
const BasicSearchForm: React.FC = () => {
1013
const { uiSearchParams, updateFilters } = useUISearchParams();
14+
const { user } = useBoardProvider();
15+
const userId = user?.id;
1116
const grades = TENSION_KILTER_GRADES;
1217

1318
const handleGradeChange = (type: 'min' | 'max', value: number | undefined) => {
@@ -18,6 +23,53 @@ const BasicSearchForm: React.FC = () => {
1823
}
1924
};
2025

26+
const renderLogbookSection = () => {
27+
if (!userId) {
28+
return (
29+
<Form.Item>
30+
<Alert
31+
message="Sign in to access your logbook"
32+
description="Login to your account to search for your favourite climbs, climbs you've done, or attempted."
33+
type="info"
34+
showIcon
35+
/>
36+
</Form.Item>
37+
);
38+
}
39+
40+
return (
41+
<>
42+
<Form.Item label="Climbs I have Done" valuePropName="checked">
43+
<Switch
44+
checked={uiSearchParams.showDone}
45+
onChange={(checked) => updateFilters({ showDone: checked })}
46+
/>
47+
</Form.Item>
48+
49+
<Form.Item label="Climbs I have Attempted" valuePropName="checked">
50+
<Switch
51+
checked={uiSearchParams.showAttempted}
52+
onChange={(checked) => updateFilters({ showAttempted: checked })}
53+
/>
54+
</Form.Item>
55+
56+
<Form.Item label="Climbs I have Not Attempted" valuePropName="checked">
57+
<Switch
58+
checked={uiSearchParams.showNotAttempted}
59+
onChange={(checked) => updateFilters({ showNotAttempted: checked })}
60+
/>
61+
</Form.Item>
62+
63+
<Form.Item label="Climbs I Liked" valuePropName="checked">
64+
<Switch
65+
checked={uiSearchParams.showOnlyLiked}
66+
onChange={(checked) => updateFilters({ showOnlyLiked: checked })}
67+
/>
68+
</Form.Item>
69+
</>
70+
);
71+
};
72+
2173
return (
2274
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}>
2375
<Form.Item label="Climb Name">
@@ -139,8 +191,82 @@ const BasicSearchForm: React.FC = () => {
139191
<Form.Item label="Setter Name">
140192
<Input value={uiSearchParams.settername} onChange={(e) => updateFilters({ settername: e.target.value })} />
141193
</Form.Item>
194+
195+
<Form.Item>
196+
<Title level={5}>Logbook</Title>
197+
</Form.Item>
198+
199+
{renderLogbookSection()}
200+
201+
<Form.Item label="Only Climbs with Beta Videos" valuePropName="checked">
202+
<Switch
203+
checked={uiSearchParams.onlyWithBeta}
204+
onChange={(checked) => updateFilters({ onlyWithBeta: checked })}
205+
/>
206+
</Form.Item>
207+
208+
<Form.Item>
209+
<Title level={5}>Climb Types</Title>
210+
</Form.Item>
211+
212+
<Form.Item label="Boulders" valuePropName="checked">
213+
<Switch
214+
checked={uiSearchParams.showBoulders}
215+
onChange={(checked) => updateFilters({ showBoulders: checked })}
216+
/>
217+
</Form.Item>
218+
219+
<Form.Item label="Routes" valuePropName="checked">
220+
<Switch
221+
checked={uiSearchParams.showRoutes}
222+
onChange={(checked) => updateFilters({ showRoutes: checked })}
223+
/>
224+
</Form.Item>
225+
226+
<Form.Item>
227+
<Title level={5}>Climb Status</Title>
228+
</Form.Item>
229+
230+
<Form.Item label="Established" valuePropName="checked">
231+
<Switch
232+
checked={uiSearchParams.showEstablished}
233+
onChange={(checked) => updateFilters({ showEstablished: checked })}
234+
/>
235+
</Form.Item>
236+
237+
<Form.Item label="Open Projects" valuePropName="checked">
238+
<Switch
239+
checked={uiSearchParams.showProjects}
240+
onChange={(checked) => updateFilters({ showProjects: checked })}
241+
/>
242+
</Form.Item>
243+
244+
<Form.Item label="Drafts" valuePropName="checked">
245+
<Switch
246+
checked={uiSearchParams.showDrafts}
247+
onChange={(checked) => updateFilters({ showDrafts: checked })}
248+
/>
249+
</Form.Item>
250+
251+
<Form.Item>
252+
<Title level={5}>Climb Size & Shape</Title>
253+
</Form.Item>
254+
255+
<Form.Item label="Only Tall Climbs" valuePropName="checked">
256+
<Switch
257+
checked={uiSearchParams.onlyTall}
258+
onChange={(checked) => updateFilters({ onlyTall: checked })}
259+
/>
260+
</Form.Item>
261+
262+
<Form.Item label="Only Side Climbs" valuePropName="checked">
263+
<Switch
264+
checked={uiSearchParams.onlySide}
265+
onChange={(checked) => updateFilters({ onlySide: checked })}
266+
/>
267+
</Form.Item>
142268
</Form>
143269
);
144270
};
145271

146-
export default BasicSearchForm;
272+
export default BasicSearchForm;

app/components/search-drawer/search-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ const SearchForm: React.FC<SearchFormProps> = ({ boardDetails }) => {
2323
);
2424
};
2525

26-
export default SearchForm;
26+
export default SearchForm;

app/lib/data-sync/aurora/shared-sync.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export async function syncSharedData(board: BoardName): Promise<Record<string, {
349349
}
350350

351351
const upsertAllSharedTableData = async (board: BoardName, syncResults: SyncData) => {
352-
const results: Record<string, { synced: number }> = {};
352+
let results: Record<string, { synced: number }> = {};
353353

354354
await db.transaction(
355355
async (
@@ -372,9 +372,10 @@ const upsertAllSharedTableData = async (board: BoardName, syncResults: SyncData)
372372
console.log(`Updated ${tableName} with ${data.length} rows`);
373373
return [tableName, { synced: data.length }];
374374
});
375-
const results = Object.fromEntries(await Promise.all(promises));
375+
376+
results = Object.fromEntries(await Promise.all(promises));
376377
} catch (error) {
377-
//@ts-expect-error
378+
//@ts-expect-error TODO Fix later
378379
console.error('Failed to commit sync database transaction ', error.toString());
379380
tx.rollback();
380381
}

app/lib/types.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,41 @@ export type HoldStateFilter = {
6666
export type SearchRequest = {
6767
gradeAccuracy: number;
6868
maxGrade: number;
69-
minAscents: number;
7069
minGrade: number;
7170
minRating: number;
71+
minAscents: number;
7272
sortBy: 'ascents' | 'difficulty' | 'name' | 'quality';
7373
sortOrder: 'asc' | 'desc';
7474
name: string;
7575
onlyClassics: boolean;
7676
settername: string;
7777
setternameSuggestion: string;
7878
holdsFilter: HoldStateFilter;
79+
holds: string;
80+
mirroredHolds: string;
81+
82+
// Logbook filters
83+
showDone: boolean;
84+
showAttempted: boolean;
85+
showNotAttempted: boolean;
86+
showOnlyLiked: boolean;
87+
onlyWithBeta: boolean;
88+
89+
// Climb Type filters
90+
showBoulders: boolean;
91+
showRoutes: boolean;
92+
93+
// Climb Status filters
94+
showEstablished: boolean;
95+
showProjects: boolean;
96+
showDrafts: boolean;
97+
98+
// Climb Size & Shape filters
99+
onlyTall: boolean;
100+
onlySide: boolean;
79101
};
80102

103+
// SearchRequestPagination remains the same structure
81104
export type SearchRequestPagination = SearchRequest & {
82105
page: number;
83106
pageSize: number;

app/lib/url-utils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ export const DEFAULT_SEARCH_PARAMS: SearchRequestPagination = {
9191
holdsFilter: {},
9292
page: 0,
9393
pageSize: PAGE_LIMIT,
94+
95+
// New filter defaults
96+
// Logbook defaults - start with everything visible
97+
showDone: true,
98+
showAttempted: true,
99+
showNotAttempted: true,
100+
showOnlyLiked: false,
101+
onlyWithBeta: false,
102+
103+
// Climb Type defaults - show all types initially
104+
showBoulders: true,
105+
showRoutes: true,
106+
107+
// Climb Status defaults - show established climbs by default
108+
showEstablished: true,
109+
showProjects: false,
110+
showDrafts: false,
111+
112+
// Climb Size & Shape defaults - show all climbs initially
113+
onlyTall: false,
114+
onlySide: false,
94115
};
95116

96117
export const urlParamsToSearchParams = (urlParams: URLSearchParams): SearchRequestPagination => {

0 commit comments

Comments
 (0)