Skip to content

Commit 3438fdb

Browse files
authored
v0.3 (#1)
* Add Prisma build hooks * Add prisma migrations folder * Add seed file * Change toast to modal * Add revalidation to static prop generator * Fix issue where QR code disappears after scanning * Fix footer hyperlink to not show underline
1 parent f49dc97 commit 3438fdb

File tree

7 files changed

+60
-47
lines changed

7 files changed

+60
-47
lines changed

components/Checkin.tsx

+25-29
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,39 @@ const Checkin: React.FC = () => {
1313
const [error, setError] = useState(false);
1414
const [suggestions, setSuggestions] = useState(null);
1515

16-
useEffect(() => {
17-
function onScanSuccess(decodedResult) {
18-
let code;
19-
try {
20-
const url = new URL(decodedResult);
21-
code = url.pathname.replace("/rsvp/", "");
22-
setError(false);
23-
setInviteCode(code);
24-
} catch (e) {
25-
setError(true);
26-
}
16+
function onScanSuccess(decodedResult) {
17+
let code;
18+
try {
19+
const url = new URL(decodedResult);
20+
code = url.pathname.replace("/rsvp/", "");
21+
setError(false);
22+
setInviteCode(code);
23+
} catch (e) {
24+
setError(true);
2725
}
26+
}
2827

29-
function onScanFailure(error) {}
28+
function onScanFailure(error) {}
3029

31-
let html5QrcodeScanner = new Html5QrcodeScanner(
32-
"qrscanner",
33-
{
34-
fps: 10,
35-
supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA],
36-
},
37-
false
38-
);
39-
40-
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
41-
return () => {
42-
setInviteCode("");
43-
setError(false);
44-
html5QrcodeScanner.clear();
45-
};
46-
}, []);
30+
useEffect(() => {
31+
if (!checkinCard) {
32+
let html5QrcodeScanner = new Html5QrcodeScanner(
33+
"qrscanner",
34+
{
35+
fps: 10,
36+
supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA],
37+
},
38+
false
39+
);
40+
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
41+
}
42+
}, [checkinCard]);
4743

4844
const back = (e: React.SyntheticEvent) => {
4945
e.preventDefault();
5046
setCheckinCard(null);
5147
setInviteCode("");
52-
router.push("/checkin", undefined, { shallow: true });
48+
setError(false);
5349
};
5450

5551
const checkin = async (e: React.SyntheticEvent) => {

components/InviteCard.tsx

+19-12
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,26 @@ const InviteCard: React.FC<{
197197
<p>{responseModalText}</p>
198198
</Modal.Body>
199199
<Modal.Footer>
200-
<Button variant="secondary" onClick={handleCloseModal}>Edit response</Button>
201-
{ hasError ? <></> :
200+
<Button variant="secondary" onClick={handleCloseModal}>
201+
Edit response
202+
</Button>
203+
{hasError ? (
204+
<></>
205+
) : (
202206
<Button
203-
variant="primary"
204-
onClick={() => {
205-
// showBack flag is set to False for /rsvp component
206-
if (showBack) {
207-
router.reload();
208-
} else {
209-
router.push("/");
210-
}
211-
}}>Go to homepage</Button>
212-
}
207+
variant="primary"
208+
onClick={() => {
209+
// showBack flag is set to False for /rsvp component
210+
if (showBack) {
211+
router.reload();
212+
} else {
213+
router.push("/");
214+
}
215+
}}
216+
>
217+
Go to homepage
218+
</Button>
219+
)}
213220
</Modal.Footer>
214221
</Modal>
215222
<Card>

pages/_document.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function Document() {
1212
/>
1313
<link
1414
rel="stylesheet"
15-
href="https://fonts.googleapis.com/css?family=Licorice&display=optional"
15+
href="https://fonts.googleapis.com/css?family=Licorice"
1616
/>
1717
<link rel="shortcut icon" href="/favicon.ico" />
1818
</Head>

pages/god/guests/index.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Guest, Invite, Table as GuestTable, Feature } from ".prisma/client";
22
import { withPageAuthRequired } from "@auth0/nextjs-auth0";
33
import { GetServerSideProps } from "next";
44
import React from "react";
5-
import { Button, Row, Table } from "react-bootstrap";
5+
import { Row, Table } from "react-bootstrap";
66
import Main from "../../../components/Main";
77
import {
88
QuickAddGuest,
@@ -75,7 +75,10 @@ const GodGuests: React.FC = (props: any) => {
7575
<Main>
7676
<Row className="m-3">
7777
<h3>Guest Management</h3>
78-
<p>Count: {guests.length}</p>
78+
<p>
79+
Attending/Count: {guests.filter((g) => g.isAttending).length}/
80+
{guests.length}
81+
</p>
7982
<QuickAddGuest />
8083
<QuickAssignTableInvite quickAdd={quickAddProps} />
8184
<QuickGenerateInvite quickAdd={quickAddProps} />
@@ -95,6 +98,12 @@ const GodGuests: React.FC = (props: any) => {
9598
{sortedTables.map((t) => {
9699
return (
97100
<td key={t.id}>
101+
{
102+
guests.filter((g) => {
103+
return g.tableId === t.id && g.isAttending;
104+
}).length
105+
}
106+
/
98107
{
99108
guests.filter((g) => {
100109
return g.tableId === t.id;
@@ -167,7 +176,7 @@ const GodGuests: React.FC = (props: any) => {
167176
<td>{invite?.type}</td>
168177
<td>
169178
{g.isAttending == null
170-
? "?"
179+
? "Wait"
171180
: g.isAttending === true
172181
? "Yes"
173182
: "No"}

pages/god/invites/[inviteId].tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ const InviteRsvpPage: React.FC = (props: any) => {
133133
<a href={`https://wedo.sg/rsvp/${invite.inviteCode}`}>
134134
https://wedo.sg/rsvp/{invite.inviteCode}
135135
</a>{" "}
136-
by {moment(invite.respondBy).format("MMM Do YYYY")}, or reply to
137-
this message with your response.
136+
by {moment(invite.respondBy).format("MMM Do YYYY")}.
138137
</p>
139138
<p>Thank you and we hope to see you there!</p>
140139
<p>Regards, Justin Ng &amp; Alethea Sim</p>

pages/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const getStaticProps: GetStaticProps = async () => {
6969
enableRsvpForm: enableRsvpForm,
7070
splashPhotos: splashPhotos,
7171
},
72+
revalidate: 3600,
7273
};
7374
};
7475

styles/globals.css

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ a {
4848
justify-content: center;
4949
align-items: center;
5050
flex-grow: 1;
51+
text-decoration: none;
5152
}
5253

5354
.title a {

0 commit comments

Comments
 (0)