Skip to content

Commit 9ab3749

Browse files
Highlight special users in organizer view
1 parent 88dbd9d commit 9ab3749

File tree

2 files changed

+115
-78
lines changed

2 files changed

+115
-78
lines changed

app/dashboard/views/organizerView.tsx

Lines changed: 98 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getSelf } from '@/app/lib/data';
1111
import PopupDialog from '../components/dialog';
1212
import { set } from 'zod';
1313
import Page from '@/app/(pre-dashboard)/(landing)/page';
14+
import { specialEmails } from '@/app/lib/data';
1415

1516
type STATUS =
1617
| 'SUCCESSFUL'
@@ -22,65 +23,78 @@ type ScannerTab = 'CHECK IN' | 'EVENT' | 'MANUAL' | 'SPONSOR';
2223
const timeWhenAllHackersCanComeThrough = new Date(2024, 2, 23, 12, 0); // March 23rd, 12PM
2324

2425
const eventPoints = {
25-
"breakfast-sunday-real": 0,
26-
"lunch-sunday-real": 0,
27-
"github-copilot": 25,
28-
"figma-workshop": 25,
29-
"wakefern-coffee-chat": 15,
30-
"wakefern-cafe": 15,
31-
"midnight-surprise": 15,
32-
"icims-tech-talk": 25,
33-
"lunch-saturday": 0,
34-
"dinner-saturday": 0,
35-
"breakfast-sunday": 0,
36-
"lunch-sunday": 0,
37-
"meal-placeholder": 0,
38-
"overcookd-4person-3-stars": 30,
39-
"overcookd-4person-2-stars": 20,
40-
"overcookd-4person-1-star": 15,
41-
"overcookd-2v2-winner": 15,
42-
"food-texture-guess": 10,
43-
"tea-tasting-guess": 20,
44-
45-
"chess": 5,
46-
47-
"cup-stack-large-shorter-time": 15,
48-
"cup-stack-large-longer-time": 10,
49-
"cup-stack-small-shorter-time": 15,
50-
"cup-stack-small-longer-time": 10,
51-
"stack-cup-game-win": 25,
52-
53-
"jellybean-first-place": 75,
54-
"jellybean-second-place": 50,
55-
"jellybean-third-place": 30,
56-
57-
"shop-food-keychains": -15,
58-
"shop-small-squishmallows": -70,
59-
"shop-boba-keychain": -50,
60-
"shop-scented-candles": -60,
61-
"shop-hackru-mugs": -75,
62-
"shop-dumpling-night-light": -80,
63-
"shop-toast-plushie": -80,
64-
"shop-tea-house-set": -90,
65-
"shop-avocado-rug": -120,
66-
"shop-boba": 0,
67-
"shop-giant-baguette": -150,
26+
'breakfast-sunday-real': 0,
27+
'lunch-sunday-real': 0,
28+
'github-copilot': 25,
29+
'figma-workshop': 25,
30+
'wakefern-coffee-chat': 15,
31+
'wakefern-cafe': 15,
32+
'midnight-surprise': 15,
33+
'icims-tech-talk': 25,
34+
'lunch-saturday': 0,
35+
'dinner-saturday': 0,
36+
'breakfast-sunday': 0,
37+
'lunch-sunday': 0,
38+
'meal-placeholder': 0,
39+
'overcookd-4person-3-stars': 30,
40+
'overcookd-4person-2-stars': 20,
41+
'overcookd-4person-1-star': 15,
42+
'overcookd-2v2-winner': 15,
43+
'food-texture-guess': 10,
44+
'tea-tasting-guess': 20,
45+
46+
chess: 5,
47+
48+
'cup-stack-large-shorter-time': 15,
49+
'cup-stack-large-longer-time': 10,
50+
'cup-stack-small-shorter-time': 15,
51+
'cup-stack-small-longer-time': 10,
52+
'stack-cup-game-win': 25,
53+
54+
'jellybean-first-place': 75,
55+
'jellybean-second-place': 50,
56+
'jellybean-third-place': 30,
57+
58+
'shop-food-keychains': -15,
59+
'shop-small-squishmallows': -70,
60+
'shop-boba-keychain': -50,
61+
'shop-scented-candles': -60,
62+
'shop-hackru-mugs': -75,
63+
'shop-dumpling-night-light': -80,
64+
'shop-toast-plushie': -80,
65+
'shop-tea-house-set': -90,
66+
'shop-avocado-rug': -120,
67+
'shop-boba': 0,
68+
'shop-giant-baguette': -150,
6869
};
6970

71+
// MODIFICATION: Added 'isSpecialUser' prop to display the indicator
7072
function ScanStatus(props: {
7173
status: STATUS;
7274
scanType: ScannerTab;
7375
fullName: string;
76+
isSpecialUser: boolean; // New prop
7477
}) {
75-
const { status, scanType, fullName } = props;
78+
const { status, scanType, fullName, isSpecialUser } = props;
7679

7780
return (
7881
<div className="w-full text-center">
7982
<p className="">
8083
Scan QR to {scanType === 'CHECK IN' ? 'check in' : 'scan for an event'}
8184
</p>
8285
<p className="">Status: </p>
83-
<p>{fullName && <p className="text-white">Found User: {fullName}</p>}</p>
86+
{/* MODIFICATION: Added a flex container and the orange dot indicator */}
87+
{fullName && (
88+
<div className="flex items-center justify-center gap-2 text-white">
89+
<p>Found User: {fullName}</p>
90+
{isSpecialUser && (
91+
<span
92+
className="h-3 w-3 rounded-full bg-orange-500"
93+
title="This user is on the special list."
94+
></span>
95+
)}
96+
</div>
97+
)}
8498
<p className="">
8599
{status === 'SUCCESSFUL' && (
86100
<p className="text-green-500">Successful.</p>
@@ -125,11 +139,15 @@ function OrganizerView() {
125139
);
126140
const [isSponsor, setIsSponsor] = useState<boolean>(false);
127141

142+
// MODIFICATION: Add new state to track if the user is on the special list
143+
const [isSpecialUser, setIsSpecialUser] = useState<boolean>(false);
144+
128145
const resetScanLog = () => {
129146
setScannedName('');
130147
setLatestScannedEmail('');
131148
setScanResponse('');
132149
setStatus('AWAITING SCAN');
150+
setIsSpecialUser(false); // MODIFICATION: Reset the special user status
133151
};
134152

135153
const handleOnScan = async (
@@ -141,6 +159,13 @@ function OrganizerView() {
141159
setStatus('AWAITING RESPONSE');
142160
setLatestScannedEmail(result);
143161

162+
// MODIFICATION: Check if the scanned email is in the special list
163+
if (specialEmails.includes(result)) {
164+
setIsSpecialUser(true);
165+
} else {
166+
setIsSpecialUser(false);
167+
}
168+
144169
const resp = await GetUser(result);
145170
if (typeof resp.response === 'string') {
146171
if (resp.response.includes('error')) {
@@ -308,8 +333,9 @@ function OrganizerView() {
308333
<div className="grid justify-center space-x-4 md:grid-cols-5">
309334
<button
310335
disabled={isSponsor}
311-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${scannerTab === 'CHECK IN' ? 'bg-blue-700' : ''
312-
} ${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
336+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
337+
scannerTab === 'CHECK IN' ? 'bg-blue-700' : ''
338+
} ${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
313339
onClick={() => {
314340
setScannerTab('CHECK IN');
315341
resetScanLog();
@@ -319,8 +345,9 @@ function OrganizerView() {
319345
</button>
320346
<button
321347
disabled={isSponsor}
322-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${scannerTab === 'EVENT' ? 'bg-blue-700' : ''
323-
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
348+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
349+
scannerTab === 'EVENT' ? 'bg-blue-700' : ''
350+
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
324351
onClick={() => {
325352
setScannerTab('EVENT');
326353
resetScanLog();
@@ -330,8 +357,9 @@ function OrganizerView() {
330357
</button>
331358
<button
332359
disabled={isSponsor}
333-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${scannerTab === 'MANUAL' ? 'bg-blue-700' : ''
334-
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
360+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
361+
scannerTab === 'MANUAL' ? 'bg-blue-700' : ''
362+
}${isSponsor ? 'bg-blue-500 hover:bg-blue-500' : ''}`}
335363
onClick={() => {
336364
setScannerTab('MANUAL');
337365
resetScanLog();
@@ -340,8 +368,9 @@ function OrganizerView() {
340368
Manual
341369
</button>
342370
<button
343-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${scannerTab === 'SPONSOR' ? 'bg-blue-700' : ''
344-
}`}
371+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
372+
scannerTab === 'SPONSOR' ? 'bg-blue-700' : ''
373+
}`}
345374
onClick={() => {
346375
setScannerTab('SPONSOR');
347376
resetScanLog();
@@ -391,10 +420,12 @@ function OrganizerView() {
391420
/>
392421
)}
393422
<div className="my-10 flex flex-col items-center">
423+
{/* MODIFICATION: Pass the new isSpecialUser state to the component */}
394424
<ScanStatus
395425
status={status}
396426
scanType={scannerTab}
397427
fullName={scannedName}
428+
isSpecialUser={isSpecialUser}
398429
/>
399430
{scannerTab === 'CHECK IN' ? (
400431
<CheckInScan status={status} />
@@ -407,8 +438,9 @@ function OrganizerView() {
407438
) : scannerTab === 'SPONSOR' ? (
408439
<div>
409440
<button
410-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${selectedABList ? 'bg-blue-700' : ''
411-
}`}
441+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
442+
selectedABList ? 'bg-blue-700' : ''
443+
}`}
412444
onClick={() => {
413445
setSelectedABList(true);
414446
resetScanLog();
@@ -417,8 +449,9 @@ function OrganizerView() {
417449
A
418450
</button>
419451
<button
420-
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${!selectedABList ? 'bg-blue-700' : ''
421-
}`}
452+
className={`rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 ${
453+
!selectedABList ? 'bg-blue-700' : ''
454+
}`}
422455
onClick={() => {
423456
setSelectedABList(false);
424457
resetScanLog();
@@ -439,17 +472,19 @@ function OrganizerView() {
439472
/>
440473
<div className="mt-2 flex justify-center">
441474
<button
442-
className={`mr-2 rounded px-4 py-2 font-bold text-white ${pointOperation === 'add' ? 'bg-green-500' : 'bg-gray-500'
443-
}`}
475+
className={`mr-2 rounded px-4 py-2 font-bold text-white ${
476+
pointOperation === 'add' ? 'bg-green-500' : 'bg-gray-500'
477+
}`}
444478
onClick={() => setPointOperation('add')}
445479
>
446480
+
447481
</button>
448482
<button
449-
className={`rounded px-4 py-2 font-bold text-white ${pointOperation === 'subtract'
450-
? 'bg-red-500'
451-
: 'bg-gray-500'
452-
}`}
483+
className={`rounded px-4 py-2 font-bold text-white ${
484+
pointOperation === 'subtract'
485+
? 'bg-red-500'
486+
: 'bg-gray-500'
487+
}`}
453488
onClick={() => setPointOperation('subtract')}
454489
>
455490
-

app/lib/data.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,16 @@ export async function getSelf(): Promise<{
135135

136136
//console.log(resp)
137137

138-
139138
if (resp.error === '') {
140139
return {
141140
response: resp.response as unknown as Record<any, any>,
142141
error: '',
143142
};
144-
}
145-
else if (resp.error){
143+
} else if (resp.error) {
146144
return {
147-
error: resp.error ,
145+
error: resp.error,
148146
response: {},
149-
}
147+
};
150148
}
151149
}
152150

@@ -188,37 +186,34 @@ export async function RegisterSelf() {
188186
return 'Something went wrong';
189187
}
190188

191-
export async function OptInSelf(stat:boolean) {
189+
export async function OptInSelf(stat: boolean) {
192190
const session = await auth();
193191
console.log('Register Self');
194192
if (session?.user && session?.user?.email) {
195-
const resp = await SetUser(
196-
{ opt_in: stat},
197-
session.user.email,
198-
);
193+
const resp = await SetUser({ opt_in: stat }, session.user.email);
199194

200195
if (resp.error === '') {
201-
return "GOOD";
196+
return 'GOOD';
202197
}
203198
return resp.error;
204199
}
205200

206201
return 'Something went wrong';
207202
}
208203

209-
export async function TransportMethodSelf(method:string) {
204+
export async function TransportMethodSelf(method: string) {
210205
const session = await auth();
211206
console.log('Tansport Self');
212207
if (session?.user && session?.user?.email) {
213208
const resp = await SetUser(
214-
{ transportation_method: method},
209+
{ transportation_method: method },
215210
session.user.email,
216211
);
217212

218213
console.log(resp);
219214

220215
if (resp.error === '') {
221-
return "GOOD";
216+
return 'GOOD';
222217
}
223218
return resp.error;
224219
}
@@ -382,5 +377,12 @@ export async function getUsers() {
382377

383378
export async function UpdateUser() {
384379
//double check that the whoever is logged in and is sending this request is an admin
385-
console.log('updaing a user');
380+
console.log('updating a user');
386381
}
382+
383+
// temp special emails list
384+
export const specialEmails: string[] = [
385+
'important.person@example.com',
386+
'vip.attendee@example.com',
387+
'guest.speaker@example.com',
388+
];

0 commit comments

Comments
 (0)