-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Staging to Production
- Loading branch information
Showing
13 changed files
with
229 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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.
Binary file not shown.
This file contains 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 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 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,99 @@ | ||
import React, { useCallback, useRef } from "react"; | ||
import { toPng } from "html-to-image"; | ||
import QRCode from "react-qr-code"; | ||
import moment from "moment"; | ||
|
||
/** | ||
* | ||
* @param {{ | ||
* headerImage: "", | ||
* ticketNo: "", | ||
* studentName: "", | ||
* studentItNo: "", | ||
* title: "", | ||
* subTitle: "", | ||
* date: "", | ||
* url: "", | ||
* }} props | ||
* @property url - The url is required to generate the QR code | ||
* @example | ||
* <Ticket | ||
headerImage={logo} | ||
title="Mini Hackathon 2022" | ||
subTitle="Awareness Session 📣" | ||
date={new Date()} | ||
ticketNo="334535" | ||
studentItNo="IT19104218" | ||
studentName="Rusiru Abhisheak" | ||
url={SessionInfo.awarenessSessionLink} | ||
/> | ||
*/ | ||
const Ticket = (props) => { | ||
const isDebugModeOn = false; | ||
const ref = useRef(null); | ||
|
||
const onButtonClick = useCallback(() => { | ||
if (ref.current === null) { | ||
return; | ||
} | ||
|
||
toPng(ref.current, { cacheBust: true }) | ||
.then((dataUrl) => { | ||
const link = document.createElement("a"); | ||
link.download = `${props.studentItNo}.png`; | ||
link.href = dataUrl; | ||
link.click(); | ||
}) | ||
.catch((err) => { | ||
isDebugModeOn && console.log(err); | ||
}); | ||
}, [ref, isDebugModeOn, props.studentItNo]); | ||
|
||
return ( | ||
<div> | ||
<div className="m-6 flex justify-center"> | ||
<div | ||
ref={ref} | ||
className="bg-white w-5/12 rounded-lg border-2 border-gray-600" | ||
> | ||
<div className="p-4"> | ||
<div className="grid grid-cols-2 gap-0"> | ||
<div> | ||
<img src={props.headerImage} alt="logo" width={100} /> | ||
<div className="flex font-semibold text-xl">{props.title}</div> | ||
<div>{props.subTitle}</div> | ||
<div>{moment(props.date).format("LLL")}</div> | ||
<div className="text-2xl font-bold mt-3"> | ||
№ {props.ticketNo} | ||
</div> | ||
<div className="flex"> | ||
<div>{props.studentItNo}</div> | ||
<div className="ml-5">{props.studentName}</div> | ||
</div> | ||
</div> | ||
<div> | ||
<div className="flex justify-end"> | ||
<QRCode value={props.url} size={180} /> | ||
</div> | ||
<div className="flex justify-end"> | ||
<small className="">Scan the code to join</small> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="flex justify-center"> | ||
<button | ||
onClick={onButtonClick} | ||
className="bg-black text-white hover:bg-gray-300 hover:text-black transition duration-0 hover:duration-500 rounded border-0 pt-2 pb-2 pl-4 pr-4" | ||
> | ||
Save My Ticket | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Ticket; |
This file contains 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,5 +1,6 @@ | ||
import Footer from "./Footer"; | ||
import Navbar from "./Navbar"; | ||
import TimelineComponent from "./TimelineCard"; | ||
import Ticket from "./Ticket"; | ||
|
||
export { Footer, Navbar, TimelineComponent }; | ||
export { Footer, Navbar, TimelineComponent, Ticket }; |
This file contains 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 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,3 @@ | ||
{ | ||
"awarenessSessionLink": "https://teams.microsoft.com/l/meetup-join/19%3a6646ce03cf974130b2a09e76bd7d35d3%40thread.tacv2/1654087666693?context=%7b%22Tid%22%3a%2244e3cf94-19c9-4e32-96c3-14f5bf01391a%22%2c%22Oid%22%3a%22e65f5f7d-c523-492e-a1af-be2b1c6d9cd3%22%7d" | ||
} |
Empty file.
This file contains 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 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
Oops, something went wrong.