Skip to content

Commit

Permalink
event tokens for confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
shema-surge committed Oct 1, 2024
1 parent 51ced9b commit 93e7a21
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 250 deletions.
6 changes: 2 additions & 4 deletions src/Mutations/event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,11 @@ export const CANCEL_EVENT = gql`

export const RESPOND_TO_EVENT_INVITATION = gql`
mutation RespondToEventInvitation(
$eventId: String!
$inviteeResponse: String!
$eventToken: String!
$authToken: String!
) {
respondToEventInvitation(
eventId: $eventId,
inviteeResponse: $inviteeResponse,
eventToken: $eventToken,
authToken: $authToken
) {
end
Expand Down
86 changes: 46 additions & 40 deletions src/components/CalendarConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "react-toastify"
import moment from "moment";
import { Link } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import { RESPOND_TO_EVENT_INVITATION } from "../Mutations/event";

function CalendarConfirmation() {
const { t } = useTranslation()
const [respondToEventInvitation] = useMutation(RESPOND_TO_EVENT_INVITATION)
const [respondToEventInvitation, { data, loading, error }] = useMutation(RESPOND_TO_EVENT_INVITATION)
const params = new URLSearchParams(window.location.search)

if (!params.get('eventId') || !params.get('response')) toast.error("Missing URL Parameters")

const [event, setEvent] = useState({
title: '',
hostName: '',
Expand All @@ -24,22 +21,13 @@ function CalendarConfirmation() {
})
const respond = async () => {
try {
const { data } = await respondToEventInvitation({
console.log(data)

Check failure on line 24 in src/components/CalendarConfirmation.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
await respondToEventInvitation({
variables: {
eventId: params.get('eventId'),
inviteeResponse: params.get('response'),
eventToken: params.get('eventToken') || 'missing_token',
authToken: localStorage.getItem('auth_token'),
},
})
setEvent({
title: data.respondToEventInvitation.title,
hostName: data.respondToEventInvitation.hostName,
start: data.respondToEventInvitation.start,
end: data.respondToEventInvitation.end,
timeToStart: data.respondToEventInvitation.timeToStart,
timeToEnd: data.respondToEventInvitation.timeToEnd,
invitees: data.respondToEventInvitation.invitees
})
toast.success("Successfully responded to invitation")
} catch (err: any) {
toast.error(err.message)
Expand All @@ -57,30 +45,48 @@ function CalendarConfirmation() {
</h3>
<hr className=" bg-primary border-gray-300 my-3 w-full" />
</div>
<div className="my-6">
<ul className="">
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Title:</span> {event.title}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Hostname:</span> {event.hostName}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">When:</span> {moment(event.start).format("YYYY-MM-DD")} to {moment(event.end).format("YYYY-MM-DD")}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Time:</span> {event.timeToStart} to {event.timeToEnd}
</li>
<li className="text-sm dark:text-white flex gap-x-2 w-11/12 mb-2">
<span className="font-bold">Guests:</span>
<ul>
{event.invitees?.map((invitee: any)=>(
<li key={invitee.email}>{invitee.email} {invitee.status}</li>
))}
{
loading ?
<div className="my-6 text-center">
<p className="text-sm dark:text-white">..Loading</p>
</div>
: ''
}
{
error ?
<div className="my-6 text-center">
<p className="text-sm dark:text-white">An Error Occured!</p>
</div>
: ''
}
{
data ?
<div className="my-6">
<ul className="">
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Title:</span> {data?.respondToEventInvitation.title}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Hostname:</span> {data?.respondToEventInvitation.hostName}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">When:</span> {moment(data?.respondToEventInvitation.start).format("YYYY-MM-DD")} to {moment(data?.respondToEventInvitation.end).format("YYYY-MM-DD")}
</li>
<li className="text-sm dark:text-white w-11/12 mb-2">
<span className="font-bold">Time:</span> {data?.respondToEventInvitation.timeToStart} to {data?.respondToEventInvitation.timeToEnd}
</li>
<li className="text-sm dark:text-white flex gap-x-2 w-11/12 mb-2">
<span className="font-bold">Guests:</span>
<ul>
{data?.respondToEventInvitation.invitees?.map((invitee: any) => (
<li key={invitee.email}>{invitee.email} {invitee.status}</li>
))}
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
: ''
}
<Link to="/calendar" className="text-white py-2 px-4 w-1/2 md:w-1/3 bg-primary rounded">Go to calendar</Link>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ Array [
className="flex justify-between w-full"
>
<button
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="removeInviteModel"
disabled={false}
onClick={[Function]}
Expand All @@ -70,8 +69,7 @@ Array [
Cancel
</button>
<button
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
disabled={false}
onClick={[Function]}
type="button"
Expand Down Expand Up @@ -328,8 +326,7 @@ Array [
className="flex justify-between w-full"
>
<button
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="removeModel1"
disabled={false}
onClick={[Function]}
Expand All @@ -338,8 +335,7 @@ Array [
Cancel
</button>
<button
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
disabled={false}
onClick={[Function]}
type="button"
Expand Down Expand Up @@ -388,8 +384,7 @@ Array [
className="flex justify-between w-full"
>
<button
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="removeModel2"
disabled={false}
onClick={[Function]}
Expand All @@ -398,8 +393,7 @@ Array [
Cancel
</button>
<button
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="removeMemberFromCohort"
disabled={false}
onClick={[Function]}
Expand Down Expand Up @@ -446,7 +440,7 @@ Array [
Reason
</label>
<input
className="mt-1 px-3 py-2 w-full border border-gray-300 rounded-md focus:outline-none focus:ring focus:ring-primary dark:bg-dark-bg dark:text-white"
className="w-full px-3 py-2 mt-1 border border-gray-300 rounded-md focus:outline-none focus:ring focus:ring-primary dark:bg-dark-bg dark:text-white"
id="reason"
name="reason"
onChange={[Function]}
Expand All @@ -464,20 +458,19 @@ Array [
Date
</label>
<input
className="mt-1 px-3 py-2 w-full border border-gray-300 rounded-md focus:outline-none focus:ring focus:ring-primary dark:bg-dark-bg dark:text-white"
className="w-full px-3 py-2 mt-1 border border-gray-300 rounded-md focus:outline-none focus:ring focus:ring-primary dark:bg-dark-bg dark:text-white"
id="date"
name="date"
readOnly={true}
type="text"
value="2024-09-30"
value="2024-10-01"
/>
</div>
<div
className="flex justify-between w-full"
>
<button
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="dropModel"
disabled={false}
onClick={[Function]}
Expand All @@ -486,8 +479,7 @@ Array [
Cancel
</button>
<button
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="dropMemberFromCohort"
disabled={false}
onClick={[Function]}
Expand All @@ -502,18 +494,15 @@ Array [
</div>,
<div
className="h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4 hidden"
className="h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4 hidden"
>
<div
className="w-full p-4 pb-8 bg-indigo-100 rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12"
>
<div
className="flex flex-wrap items-center justify-center w-full card-title"
className="flex flex-wrap items-center justify-center w-full card-title"
>
<h3
className="w-11/12 text-sm font-bold text-center dark:text-white"
className="w-11/12 text-sm font-bold text-center dark:text-white"
>
Add Trainee
</h3>
Expand All @@ -526,11 +515,9 @@ Array [
>
<form
className="px-8 py-3"
className="px-8 py-3"
>
<div
className="my-3 input h-9"
className="my-3 input h-9"
>
<div
className="flex items-center w-full h-full rounded-md grouped-input"
Expand Down Expand Up @@ -639,7 +626,6 @@ Array [
</div>
<div
className="my-3 text-white input h-9"
className="my-3 text-white input h-9"
>
<div
className="flex items-center w-full h-full text-white rounded-md grouped-input"
Expand Down Expand Up @@ -748,7 +734,6 @@ Array [
</div>
<div
className="my-3 text-white input h-9"
className="my-3 text-white input h-9"
>
<div
className="flex items-center w-full h-full text-white rounded-md grouped-input"
Expand Down Expand Up @@ -859,8 +844,7 @@ Array [
className="flex justify-between w-full"
>
<button
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn info sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="removeModel"
disabled={false}
onClick={[Function]}
Expand All @@ -869,8 +853,7 @@ Array [
Cancel
</button>
<button
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
className="btn primary sm w-[40%] md:w-1/4 text-sm font-sans font-serif "
data-testid="saveButton"
disabled={false}
onClick={[Function]}
Expand Down Expand Up @@ -903,7 +886,6 @@ Array [
className="flex gap-2"
>
<button
className="btn primary lg m-0 font-serif "
className="btn primary lg m-0 font-serif "
data-testid="registerModel"
disabled={false}
Expand All @@ -915,7 +897,6 @@ Array [
</button>
<button
className="btn primary lg m-0 font-serif "
className="btn primary lg m-0 font-serif "
data-testid="inviteModel"
disabled={false}
Expand All @@ -930,7 +911,7 @@ Array [
className=""
>
<div
className="font-serif bg-indigo-100 dark:bg-dark-bg shadow-lg px-5 py-8 rounded-md w-[100%] \\"lg:ml-60 mx-auto\\"} mb-10"
className="font-serif bg-indigo-100 dark:bg-dark-bg shadow-lg h-fit px-5 py-8 rounded-md w-[100%] \\"lg:ml-60 mx-auto\\"} mb-10"
>
<div
className="flex items-center justify-between pb-6 "
Expand All @@ -943,19 +924,15 @@ Array [
</h2>
<input
aria-label="Filter table data"
className="px-5 py-2 mt-4 font-sans text-xs border border-primary rounded outline-none dark:bg-neutral-600 dark:text-white w-52 md:w-96"
className="px-5 py-2 mt-4 font-sans text-xs border rounded outline-none border-primary dark:bg-neutral-600 dark:text-white w-52 md:w-96"
onChange={[Function]}
placeholder="Filter"
value=""
/>
</div>
</div>
<div
style={
Object {
"overflowX": "auto",
}
}
className="overflow-visible "
>
<table
className="min-w-full leading-normal"
Expand Down Expand Up @@ -1065,7 +1042,7 @@ Array [
className="px-6 py-4 text-sm text-center text-gray-500 dark:text-gray-300 "
colSpan={6}
>
Loading...
A Loading...
</td>
</tr>
</tbody>
Expand All @@ -1090,7 +1067,7 @@ Array [
colSpan={6}
>
<div
className="w-full justify-between flex mx-auto flex-row items-center"
className="flex flex-row items-center justify-between w-full mx-auto"
>
<div
className="flex"
Expand Down Expand Up @@ -1167,7 +1144,7 @@ Array [
| Go to page:
<input
className=" outline-none border rounded-md appearance-none border-primary dark:bg-primary pl-1"
className="pl-1 border rounded-md outline-none appearance-none border-primary dark:bg-primary"
defaultValue={1}
onChange={[Function]}
style={
Expand All @@ -1183,7 +1160,7 @@ Array [
</span>
<select
className="px-1/2 font-raleway rounded-md border border-dark dark:bg-primary focus:outline-none"
className="border rounded-md px-1/2 font-raleway border-dark dark:bg-primary focus:outline-none"
onChange={[Function]}
style={
Object {
Expand Down
Loading

0 comments on commit 93e7a21

Please sign in to comment.