Skip to content

Commit

Permalink
Add "Check In (A.S.)" button next to the Add Feedback button
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Sep 23, 2024
1 parent 7a91132 commit bdb0caf
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/components/events/CheckInModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Modal, Typography } from '@/components/common';
import { config } from '@/lib';
import { PublicEvent } from '@/lib/types/apiResponses';
import { prefillAsCheckinUrl } from '@/lib/utils';
import Image from 'next/image';
import Link from 'next/link';
import { useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -114,6 +115,13 @@ const CheckInModal = ({ open, event, onClose }: CheckInModalProps) => {
>
<Typography variant="h4/bold">Add Feedback</Typography>
</Link>
<Link
href={prefillAsCheckinUrl(event.title)}
className={`${style.button} ${style.addFeedback}`}
target="_blank"
>
<Typography variant="h4/bold">Check In (A.S.)</Typography>
</Link>
<button type="submit" className={style.button}>
<Typography variant="h4/bold">Close</Typography>
</button>
Expand Down
26 changes: 20 additions & 6 deletions src/components/events/EventDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import CalendarButtons from '@/components/events/CalendarButtons';
import EventBadges from '@/components/events/EventBadges';
import { config } from '@/lib';
import { PublicEvent, PublicOrderPickupEvent } from '@/lib/types/apiResponses';
import { formatEventDate, getDefaultEventCover, isOrderPickupEvent } from '@/lib/utils';
import {
formatEventDate,
getDefaultEventCover,
isOrderPickupEvent,
prefillAsCheckinUrl,
} from '@/lib/utils';
import CloseIcon from '@/public/assets/icons/close-icon.svg';
import Image from 'next/image';
import Link from 'next/link';
import { IoFastFoodOutline } from 'react-icons/io5';
import { VscFeedback } from 'react-icons/vsc';
import styles from './style.module.scss';

Expand All @@ -31,12 +37,20 @@ const EventDetail = ({ event, attended, inModal = false }: EventDetailProps) =>
if (!isOrderPickupEvent(event)) {
if (isUpcomingEvent) {
buttons = <CalendarButtons event={event} />;
} else if (inModal) {
} else {
buttons = (
<Link href={`${config.eventsRoute}/${event.uuid}`} className={styles.feedbackBtn}>
<VscFeedback aria-hidden />
Add Feedback
</Link>
<div className={styles.buttons}>
{inModal ? (
<Link href={`${config.eventsRoute}/${event.uuid}`} className={styles.button}>
<VscFeedback aria-hidden />
Add Feedback
</Link>
) : null}
<Link href={prefillAsCheckinUrl(event.title)} className={styles.button} target="_blank">
<IoFastFoodOutline aria-hidden />
Check In (A.S.)
</Link>
</div>
);
}
}
Expand Down
27 changes: 16 additions & 11 deletions src/components/events/EventDetail/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,25 @@
}
}

.feedbackBtn {
align-items: center;
align-self: flex-start;
background-color: var(--theme-elevated-background);
border: 1px solid var(--theme-elevated-stroke);
border-radius: 10px;
.buttons {
display: flex;
gap: 0.5rem;
justify-content: flex-start;
padding: 0.75rem;
transition: all 0.2s;

&:hover {
background: var(--theme-surface-2);
.button {
align-items: center;
align-self: flex-start;
background-color: var(--theme-elevated-background);
border: 1px solid var(--theme-elevated-stroke);
border-radius: 10px;
display: flex;
gap: 0.5rem;
justify-content: flex-start;
padding: 0.75rem;
transition: all 0.2s;

&:hover {
background: var(--theme-surface-2);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/events/EventDetail/style.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
export type Styles = {
badges: string;
button: string;
buttons: string;
close: string;
closeIcon: string;
container: string;
description: string;
eventDetails: string;
eventInfo: string;
eventTitle: string;
feedbackBtn: string;
header: string;
image: string;
standalone: string;
Expand Down
24 changes: 24 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,3 +485,27 @@ export function seededRandom(a: number, b: number, c: number, d: number): () =>
export function getFileName(url: string, defaultName: string): string {
return decodeURIComponent(url.split('/').at(-1) ?? defaultName);
}

/**
* The name of the org as known to AS. Assuming no data entry errors, the form
* will probably contain a corresponding entry for the event following the
* format `<org_name> - <event_name>`.
*/
const AS_ORG_NAME = 'Sample Org 1';
const GFORM_URL =
'https://docs.google.com/forms/d/e/1FAIpQLSc-akfqTNzrWUmOub_rMDj5wExBUDfakMXDbeGicOrpxBr6jg/viewform';
/**
* ID of the "Select the event you are signing in to:" dropdown in the check-in
* form.
*/
const GFORM_EVENT_FIELD = 'entry.219446721';

/**
* Generates the URL to AS's funded event attendance check-in form with the
* event prefilled.
*/
export function prefillAsCheckinUrl(eventName: string): string {
return `${GFORM_URL}?${new URLSearchParams({
[GFORM_EVENT_FIELD]: `${AS_ORG_NAME} - ${eventName}`,
})}`;
}

0 comments on commit bdb0caf

Please sign in to comment.