Skip to content

Instantly share code, notes, and snippets.

@Daltonic
Created June 25, 2023 10:06
Show Gist options
  • Save Daltonic/70578ed923d7ac21ed7ed141878b124b to your computer and use it in GitHub Desktop.
Save Daltonic/70578ed923d7ac21ed7ed141878b124b to your computer and use it in GitHub Desktop.
Dapp Cinemas
import React, { useEffect } from 'react'
import { Link, useParams } from 'react-router-dom'
import { getMovie, getSlot, getTicketHolders } from '../services/blockchain'
import {
convertTimestampToDate,
setGlobalState,
useGlobalState,
} from '../store'
import TicketHoldersTable from '../components/TicketHoldersTable'
const TicketHolders = () => {
const { slotId, movieId } = useParams()
const [slot] = useGlobalState('slot')
const [movie] = useGlobalState('movie')
const [holders] = useGlobalState('ticketHolders')
useEffect(() => {
const fetchData = async () => {
await getSlot(slotId)
await getMovie(movieId)
await getTicketHolders(movieId, slotId)
}
fetchData()
}, [])
return (
<div className="w-full min-h-screen p-3 space-y-6 mb-10">
<h3 className="my-3 text-3xl font-bold">
{movie?.name}:{' '}
<span className="text-gray-500">
{convertTimestampToDate(slot?.day)}
</span>
</h3>
<TicketHoldersTable holders={holders} slot={slot} />
<div className="flex space-x-2">
<button
onClick={() => setGlobalState('holderSearchModal', 'scale-100')}
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded"
>
Find Holder
</button>
<Link
to={'/timeslot/' + movieId}
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
Back
</Link>
</div>
</div>
)
}
export default TicketHolders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment