Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"dotenv": "^16.0.1",
"ethers": "^5.6.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.34.0",
"react-qr-code": "^2.0.7",
"react-router-dom": "^5.3.3",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"web3modal": "^1.9.8"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1 change: 0 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Route,
} from "react-router-dom";


export default function App() {
return (
<Router>
Expand Down
7 changes: 4 additions & 3 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import React from 'react'
import { Link } from 'react-router-dom'

const Header = () => {

return (
<div className="flex justify-between mx-auto h-[200px]">
<div className="w-[20rem] h-[6rem] my-10 ml-12">
<Link to={"/"}><img src="/blocktic_logo.png" alt="logo" className="h-full w-full" /></Link>
</div>
<div className="mr-[10%] my-auto">
<ul className="flex gap-14 text-2xl font-bold">
<li className="cursor-pointer menu-items"><Link to={"/create-event"}>Create Event</Link></li>
<li className="cursor-pointer menu-items"><Link to={"/my-created-events"}>My Created Events</Link> </li>
<li className="cursor-pointer menu-items"><Link to={"/all-events"}>All Events</Link></li>
<li className="cursor-pointer menu-items my-auto"><Link to={"/create-event"}>Create Event</Link></li>
<li className="cursor-pointer menu-items my-auto"><Link to={"/my-created-events"}>My Created Events</Link> </li>
<li className="cursor-pointer menu-items my-auto"><Link to={"/all-events"}>All Events</Link></li>
</ul>
</div>
</div>
Expand Down
94 changes: 42 additions & 52 deletions src/pages/Event.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { useParams } from "react-router-dom";
import Header from '../components/Header';
import { ethers } from 'ethers';

//temporary data until we have the API to call
const event = {
Expand All @@ -20,13 +21,20 @@ async function fetchEvent(eventId: string) {
return response;
}

//const ContractAddress = '0x1240c9...';

export default function Event() {
const price = event.price;

//uncomment this line to use the API
//const event = fetchEvent(useParams().id);

const [selectedValue, setSelectedValue] = useState<string>("1");
const [totalPrice, setTotalPrice] = useState<number>(price);
//const [IsLoading, setIsLoading] = useState<boolean>(false);
//const [success, setSuccess] = useState<boolean>(false);
//const [errorStatus, setErrorStatus] = useState<boolean>(false);
//const [txError, setTxError] = useState<string>('');

function handleChange(event: React.ChangeEvent<HTMLSelectElement>) {
setSelectedValue(event.target.value);
Expand All @@ -41,15 +49,45 @@ export default function Event() {
calcTotalPrice(event.price);
});



/*
async function buyTicket() {
try {
setIsLoading(true);

//register transfer event from smart contract
mintContract.removeAllListeners();
mintContract.on("Transfer", () => {
setSuccess(true);
setIsLoading(false);
})

//get the ticket price
const ticketContractPrice = await mintContract.price();

//mint the NFT
const tx = await mintContract.mint(account, 1, apiMessage, signature, { value: ethers.utils.parseEther(ticketContractPrice) });
setTxHash(tx.hash);
}
catch (error) {
console.log(error);
setErrorStatus(true);
setTxError("failed to mint");
}
}
*/

return (
<div>
<header>
<Header/>
</header>
<div className="block mx-auto md:grid md:grid-cols-4 md:gap-10 md:max-w-screen-lg">
<div className="block md:w-full md:mx-auto md:grid md:grid-cols-4 md:gap-10 md:max-w-screen-lg">

<img src={event.imageUrl} alt="event banner"
className="block mx-2 overflow-hidden md:col-span-2 rounded-md border border-gray-400 shadow-lg"/>

className="object-fit md:col-span-2 md:rounded-md md:border md:border-gray-400 md:shadow-lg"/>
<div className='mx-2 mt-5 border border-gray-400 rounded-md shadow-lg block md:col-span-2 md:mt-0'>
<h1 className='p-2 m-0 text-center text-lg text-white font-semibold rounded-t-md bg-green-400'>{event.title}</h1>
<hr/>
Expand All @@ -63,7 +101,7 @@ export default function Event() {
<p className="p-2 font-semibold col-span-1">Price per Ticket (ETH):</p><p className="p-2 col-span-2">{event.price}</p>
</div>
</div>
<div className='mx-2 block md:col-start-3 md:col-span-2 border border-gray-400 rounded-md shadow-lg'>
<div className='mx-2 mt-5 block md:mt-0 md:col-start-3 md:col-span-2 border border-gray-400 rounded-md shadow-lg'>
<div className='block md:grid md:grid-cols-4 md:gap-2'>
<label className='p-2 font-semibold col-span-1' htmlFor="number-of-tickets">Number of Tickets:</label>
<select value={selectedValue} onChange={handleChange}
Expand Down Expand Up @@ -93,51 +131,3 @@ export default function Event() {
</div>
)
}


/*
<div className="event-details-container">
<div className='event-picture-container'>
<img className="event-picture" src={event.imageUrl} alt="{event.title}"/>
</div>
<div className='event-details-container-child1'>
<div className='event-card'>
<div className="event-card-title">
<h1 className='event-details-title'>{event.title}</h1>
</div>
<hr className='event-card-hr'/>
<p>Event Name: {event.title}</p>
<p>Description: {event.description}</p>
<p>Organiser: {event.organiser}</p>
<p>Location: {event.location}</p>
<p>Date: {event.date}</p>
<p>Time: {event.time}</p>
</div>
<div className='event-buttons-container'>
<div className='event-buttons-buy-container'>
<label className='buy-tickets-label' htmlFor="number-of-tickets">Buy Ticket</label>
<select className="ticket-select" name="number-of-tickets" id="number-of-tickets">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<span className='ticket-price-label'>Price: {event.price} ETH each</span>
</div>
<div className='event-buttons-button-container'>
<button className='buy-button' type='submit' name="buy-button">Buy</button>
</div>
</div>
</div>

</div>
)
}

*/
Loading