-
Notifications
You must be signed in to change notification settings - Fork 0
Hmt 44/qr code component #40
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d05b006
added qr component
burtonjong 05a9b88
Merge branch 'main' into HMT-44/QR-code-component
burtonjong 365e44c
Merge branch 'main' into HMT-44/QR-code-component
burtonjong 3142c51
format changes
burtonjong 12ca338
container change
burtonjong 0f080b4
Merge branch 'main' into HMT-44/QR-code-component
burtonjong 57f722f
moved to public
burtonjong 693f62a
resolved changes
burtonjong b63dddf
small change
burtonjong 0a55119
why not building
burtonjong c1bd81b
Merge branch 'main' into HMT-44/QR-code-component
burtonjong 36fb947
shouldwork now
burtonjong caf05e3
Forgot to install dep
burtonjong a49879b
bro
burtonjong 188b64e
resolved changes
burtonjong fe3aa6a
import changes
burtonjong 5460061
had to import React or else backend breaks
burtonjong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import UserFoodTicket from "@/components/UserProfile/FoodTicket"; | ||
|
||
export default function FoodTicket() { | ||
return <div> FoodTicket</div>; | ||
return ( | ||
<> | ||
<UserFoodTicket /> | ||
</> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
"use client"; | ||
|
||
import { generateClient } from "aws-amplify/api"; | ||
import Image from "next/image"; | ||
import { QRCode } from "react-qrcode-logo"; | ||
|
||
import { type Schema } from "@/amplify/data/resource"; | ||
import { createMessageAndCode } from "@/amplify/function/BusinessLogic/utils/crytography"; | ||
import { getUpcomingFoodEventDetails } from "@/app/get-food-ticket/actions"; | ||
import { useUser } from "@/components/contexts/UserContext"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
export default function UserFoodTicket() { | ||
const client = generateClient<Schema>(); | ||
|
||
const userId = useUser().currentUser.username as string; | ||
|
||
const { data, isFetching } = useQuery({ | ||
initialDataUpdatedAt: 0, | ||
queryKey: ["User", userId], | ||
queryFn: async () => { | ||
const { | ||
queuePosition, | ||
eventName, | ||
eventDescription, | ||
eventTime, | ||
timeslot, | ||
} = await getUpcomingFoodEventDetails(userId); | ||
|
||
let verificationCode = ""; | ||
|
||
const { data, errors } = await client.queries.GetUserMessageCode({ | ||
userMessage: userId, | ||
}); | ||
if (errors) { | ||
console.log(errors); | ||
verificationCode = "Error when generating your message code"; | ||
return; | ||
} | ||
|
||
if (data) { | ||
const json = JSON.parse(data.body as string); | ||
const code = json["value"]; | ||
|
||
const createdVerificationCode = createMessageAndCode(userId, code); | ||
verificationCode = createdVerificationCode; | ||
} else { | ||
verificationCode = "Error when generating your message code"; | ||
} | ||
|
||
return { | ||
queuePosition, | ||
eventName, | ||
eventDescription, | ||
eventTime, | ||
timeslot, | ||
verificationCode, | ||
}; | ||
}, | ||
}); | ||
|
||
const foodTicketData = { | ||
"Queue Position": `You are in position ${data?.queuePosition ?? "unknown"} in the queue.`, | ||
"Event Name": data?.eventName ?? "N/A", | ||
"Event Description": data?.eventDescription ?? "N/A", | ||
"Event Time": data?.eventTime ?? "N/A", | ||
timeslot: data?.timeslot ?? "N/A", | ||
userCode: data?.verificationCode ?? "N/A", | ||
}; | ||
|
||
return ( | ||
<> | ||
{isFetching ? ( | ||
<div className="flex h-screen w-full items-center justify-center bg-fuzzy-peach"> | ||
<h1 className="text-2xl">Loading...</h1> | ||
</div> | ||
) : ( | ||
<div className="flex size-full flex-col bg-fuzzy-peach"> | ||
<div className="hidden md:block"> | ||
<Image | ||
src="/images/userProfile/Star_Icons.svg" | ||
alt="Right Squiggly SVG" | ||
width={30} | ||
height={30} | ||
className="md:absolute md:left-10 md:top-[50rem]" | ||
/>{" "} | ||
<Image | ||
src="/images/userProfile/Star_Icons.svg" | ||
alt="Right Squiggly SVG" | ||
width={30} | ||
height={30} | ||
className="md:absolute md:right-8 md:top-[30rem]" | ||
/>{" "} | ||
<Image | ||
src="/images/userProfile/Star_Icons.svg" | ||
alt="Right Squiggly SVG" | ||
width={30} | ||
height={30} | ||
className="md:absolute md:right-10 md:top-[60rem]" | ||
/>{" "} | ||
</div> | ||
<div className="px-10 md:px-16 md:py-10"> | ||
<div className="mb-3 flex flex-col justify-between uppercase text-[#FF6B54] md:mx-10"> | ||
<div className="flex flex-row justify-between"> | ||
<h1 className="mt-3 text-lg font-bold md:text-2xl"> | ||
My Food Ticket | ||
</h1> | ||
</div> | ||
<div className="bg-pink mt-10 flex flex-col items-center gap-5 rounded-3xl border-4 border-white bg-white/30 px-8 py-20 sm:flex-row sm:justify-start lg:gap-12 lg:px-20 lg:py-16"> | ||
<QRCode | ||
value={foodTicketData.userCode} | ||
size={300} | ||
logoImage="/CTCLogo.svg" | ||
eyeColor={["#FF4D6F", "#FF4D6F", "#FF4D6F"]} | ||
eyeRadius={50} | ||
qrStyle="fluid" | ||
fgColor="#FF4D6F" | ||
style={{ borderRadius: "20px" }} | ||
logoPadding={3} | ||
logoPaddingStyle="square" | ||
/> | ||
<div className="flex flex-col flex-wrap"> | ||
{Object.entries(foodTicketData) | ||
.slice(0, -1) | ||
.map(([key, value]) => ( | ||
<div className="flex w-full flex-wrap" key={key}> | ||
<h1 className="my-2 w-fit text-lg md:mt-2 md:text-xl"> | ||
<strong>{key}:</strong>{" "} | ||
<span className="text-md">{` ${value}`}</span> | ||
</h1> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.