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

logout while in organizer view #201

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default function Dashboard() {
data.set('file', waiverFile);
const requiredFields = ["first_name","last_name","resume","github","major","short_answer","shirt_size","hackathon_count","dietary_restrictions","special_needs","age","school","grad_year","gender","level_of_study","country_of_residence","ethnicity","how_you_heard_about_hackru","reasons","phone_number"]
const fieldtext = ["First Name", "Last Name", "Resume", "Github", "major", "What are you hoping to experience at HackRU?", "Shirt Size", "Hackathon Count", "Dietary Restrictions", "Anything we should account for?",
'age', "schhool", "Graduation Year", "Gender", "Level of Study", "Country of Residence", "Ethnicity", "How you heard about hackru", "reasons for attending", "phone number"
'age', "school", "Graduation Year", "Gender", "Level of Study", "Country of Residence", "Ethnicity", "How you heard about hackru", "reasons for attending", "phone number"
]
for (let i = 0; i < requiredFields.length; i++) {
if (!userData[requiredFields[i]]){
Expand Down
17 changes: 17 additions & 0 deletions app/dashboard/views/organizerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EventScan from './eventScan';
import { AttendEventScan, GetUser, SetUser } from '@/app/lib/actions';
import PopupDialog from '../components/dialog';
import { set } from 'zod';
import Page from '@/app/(pre-dashboard)/(landing)/page';

type STATUS =
| 'SUCCESSFUL'
Expand Down Expand Up @@ -107,6 +108,7 @@ function OrganizerView() {
const [houseOfScannedUser, setHouseOfScannedUser] = useState<string>('');
const [scannedName, setScannedName] = useState<string>('');
const [confirmation, setConfirmation] = useState<boolean>(false);
const [isLoggedIn, setIsLoggedIn] = useState(true);

const resetScanLog = () => {
setScannedName('');
Expand All @@ -115,6 +117,14 @@ function OrganizerView() {
setStatus('AWAITING SCAN');
};

const logout = () => {
setIsLoggedIn(false);
}

if(!isLoggedIn) {
return <Page /> //render page is user is not logged in
}

const handleOnScan = async (
result: string,
forceAttendance: boolean = false,
Expand Down Expand Up @@ -231,6 +241,13 @@ function OrganizerView() {
Event
</button>
</div>

<button
className='mt-2 rounded bg-red-500 px-4 py-2 font-bold text-white hover:bg-red-700'
onClick={logout}
>
Logout
</button>
</div>
{showForceAttendance && (
<PopupDialog
Expand Down
Loading