-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRankedChoiceQueue.tsx
More file actions
38 lines (32 loc) · 1.17 KB
/
RankedChoiceQueue.tsx
File metadata and controls
38 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { FormGroupWithLabel } from '@neinteractiveliterature/litform';
import UserConProfileSelect from '../BuiltInFormControls/UserConProfileSelect';
import { DefaultUserConProfilesQueryData } from '../BuiltInFormControls/selectDefaultQueries.generated';
import { useEffect, useState } from 'react';
import { Outlet, useNavigate } from 'react-router';
type UserConProfileType = NonNullable<
DefaultUserConProfilesQueryData['convention']
>['user_con_profiles_paginated']['entries'][0];
function RankedChoiceQueue() {
const [userConProfile, setUserConProfile] = useState<UserConProfileType>();
const navigate = useNavigate();
useEffect(() => {
if (userConProfile != null) {
navigate(`${userConProfile.id}`, { replace: true, relative: 'route' });
}
}, [userConProfile, navigate]);
return (
<>
<FormGroupWithLabel label="Attendee">
{(id) => (
<UserConProfileSelect
id={id}
value={userConProfile}
onChange={(newUserConProfile) => setUserConProfile(newUserConProfile ?? undefined)}
/>
)}
</FormGroupWithLabel>
<Outlet />
</>
);
}
export const Component = RankedChoiceQueue;