Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organizer Refactor - New useSWR hooks and abstraction #360

Merged
merged 30 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ced3b05
Comment to start PR
jacoblurie29 Sep 7, 2023
1660f63
Merge branch 'main' into organizer-refactor
jacoblurie29 Sep 7, 2023
b9d3cce
Generic customSWR and ScheduleTab abstracted
jacoblurie29 Sep 8, 2023
c85c673
Updated SWR package to v2.2.2
jacoblurie29 Sep 8, 2023
3a9f281
Refactor sample to potential and simplify UI logic
jacoblurie29 Sep 8, 2023
7c721f1
First run finished for refactor of ScheduleTab
jacoblurie29 Sep 8, 2023
14849be
Merge branch 'main' into organizer-refactor
jacoblurie29 Sep 8, 2023
ec9ae42
Update next-auth package to reflext SWR changes
jacoblurie29 Sep 8, 2023
818c9a9
Revert SWR package to previous version, next-auth package requires up…
jacoblurie29 Sep 8, 2023
9a07f67
Reverted important changes for reversion of swr package
jacoblurie29 Sep 8, 2023
959cb60
Reverted version of next-auth
jacoblurie29 Sep 8, 2023
fb9c343
One more minor change
jacoblurie29 Sep 8, 2023
9695ad3
Another small change
jacoblurie29 Sep 8, 2023
307ef4c
Added some ignores to test a theory about vercel breaking
jacoblurie29 Sep 8, 2023
e38951a
Remove ignores
jacoblurie29 Sep 8, 2023
bb70048
Fixed the issue
jacoblurie29 Sep 8, 2023
f27d6cb
Refactor and abstract JudgingTab
jacoblurie29 Sep 9, 2023
6ab88af
Refactor Manage Users tab
lisaliuu Sep 11, 2023
a18c21e
Run Prettier
lisaliuu Sep 11, 2023
d4d76a9
Refactor Pre-Add Users tab
lisaliuu Sep 11, 2023
7e67608
Merging unpulled changes
lisaliuu Sep 11, 2023
c52a704
Run Prettier
lisaliuu Sep 11, 2023
94b50c4
Refactor applicants tab and restructure folders
jacoblurie29 Sep 11, 2023
61eaed6
Refactor events tab SWR
jacoblurie29 Sep 11, 2023
28f043d
Merge main into organizer-refactor branch
jacoblurie29 Sep 12, 2023
a32639a
== to ===
jacoblurie29 Sep 12, 2023
70b3d2c
Move components into correct component folders
jacoblurie29 Sep 12, 2023
d93c940
More folder changes
jacoblurie29 Sep 12, 2023
0fe7dbc
Clean up if statements
lisaliuu Sep 12, 2023
a339fe1
Switch error and null data check
jacoblurie29 Sep 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions components/Organizer/PreAddUsersTab/PreAddUsersTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {Empty, Skeleton } from 'antd';
import { useSWRConfig } from 'swr';
import { useCustomSWR, RequestType } from '../../../utils/request-utils';
import { handlePreAddDelete } from '../../../utils/organizer-utils';
import {PreAddData } from '../../../types/database';
import PreAddForm from '../../../components/preAddForm';
import PreAddDisplay from '../../../components/preAddDisplay';

const PreAddUsersTab = () => {
const { mutate } = useSWRConfig();

// Preadd data
const { data: preAddData, error: preAddError } = useCustomSWR<PreAddData>({
url: '/api/preadd',
method: RequestType.GET,
errorMessage: 'Failed to get list of preadded users.',
});

return (
<>
{preAddData && preAddData.length == 0 && (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={<span>No preadded users lmao</span>}
/>
)}
{preAddData && preAddData.length > 0 && (
<PreAddDisplay
data={preAddData!}
onDelete={user => handlePreAddDelete(user, mutate)}
/>
)}
jacoblurie29 marked this conversation as resolved.
Show resolved Hide resolved
<PreAddForm />
</>
)
}

export default PreAddUsersTab
31 changes: 3 additions & 28 deletions pages/Organizer/OrganizerDash.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Button, Empty, Skeleton, Space, Tabs } from 'antd';
import { useSWRConfig } from 'swr';
import AllScores from '../../components/allScores';
import PreAddForm from '../../components/preAddForm';
import { ScoreData, TeamData, UserData, PreAddData } from '../../types/database';
import PreAddDisplay from '../../components/preAddDisplay';
import { ScoreData, TeamData, UserData } from '../../types/database';
import ApplicantsDisplay from '../../components/applicantsDisplay';
import Events from '../../components/events';
import { signOut, useSession } from 'next-auth/react';
import { handlePreAddDelete } from '../../utils/organizer-utils';
import ScheduleTab from '../../components/Organizer/ScheduleTab/ScheduleTab';
import { RequestType, useCustomSWR } from '../../utils/request-utils';
import JudgingTab from '../../components/Organizer/JudgingTab/JudgingTab';
import ManageUsersTab from '../../components/Organizer/ManageUsersTab/ManageUsersTab';
import PreAddUsersTab from '../../components/Organizer/PreAddUsersTab/PreAddUsersTab';

export default function OrganizerDash() {
const { mutate } = useSWRConfig();
Expand All @@ -23,13 +21,6 @@ export default function OrganizerDash() {
errorMessage: 'Failed to get list of hackers.',
});

// Preadd data
const { data: preAddData, error: preAddError } = useCustomSWR<PreAddData>({
url: '/api/preadd',
method: RequestType.GET,
errorMessage: 'Failed to get list of preadded users.',
});

// Get session data
const { data: session, status } = useSession();

Expand Down Expand Up @@ -63,23 +54,7 @@ export default function OrganizerDash() {
{
label: `Pre-Add Users`,
key: '4',
children: (
<>
{preAddData && preAddData.length == 0 && (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={<span>No preadded users lmao</span>}
/>
)}
{preAddData && preAddData.length > 0 && (
<PreAddDisplay
data={preAddData!}
onDelete={user => handlePreAddDelete(user, mutate)}
/>
)}
<PreAddForm />
</>
),
children: <PreAddUsersTab />
},
{
label: `Manage Applications`,
Expand Down