Skip to content

Commit

Permalink
yarn build and yarn start working
Browse files Browse the repository at this point in the history
  • Loading branch information
Kappaccinoh committed Jun 19, 2023
1 parent b82397b commit 90d06c1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 19 deletions.
8 changes: 3 additions & 5 deletions src/components/attendance/DataTableModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import dayjs from 'dayjs'
import Image from 'next/image'
import { type BodyProps } from '~/types/event/event.type'
import Link from 'next/link'
import { useRouter } from 'next/navigation'

const DataTableModal = () => {
const modal = useContext(ModalContext)
const { data, isLoading } = trpc.attendance.getEventForUser.useQuery(modal.id)
const { data, isLoading } = trpc.event.getEvent.useQuery(modal.id)

if (!modal.id) {
return null
Expand Down Expand Up @@ -55,17 +54,16 @@ const DataTableModal = () => {
}

const Body: React.FC<{ data: BodyProps | null | undefined }> = ({ data }) => {
const modal = useContext(ModalContext)
const toast = useToast()
if (!data) {
return <div>No Event Found</div>
}

dayjs.extend(LocalizedFormat)
const startDate = dayjs(data.startDate).format('lll')
const endDate = dayjs(data.endDate).format('lll')
const router = useRouter()
const toast = useToast()

const modal = useContext(ModalContext)
const { mutateAsync, isLoading: isSubmitting } = trpc.event.deleteEvent.useMutation()
const confirmDelete = async() => {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/events/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Container from '~/components/auth/Container'
import { useRouter } from 'next/router'
import TopNavbar from '~/components/common/TopNavbar'
import withAuth, { type BaseProps } from '~/utils/withAuth'
import { query } from 'firebase/firestore'

const EventPage: React.FC<BaseProps> = ({ session }) => {
const router = useRouter()
Expand Down Expand Up @@ -76,8 +75,9 @@ const EventPage: React.FC<BaseProps> = ({ session }) => {
if (invalidAttendees) {
return false
}

await mutateAsync({
id: eventData.id,
id: eventData!.id!,
name: formData.eventName,
startDate: new Date(formData.startDate),
endDate: new Date(formData.endDate),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/events/attendance/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const ConfirmAttendance: React.FC<BaseProps> = ({ session }) => {
{data.name}
</h1>
<h1 className="mb-2 self-center text-center text-3xl font-medium">
{dayjs(data.startDate.toDate()).format('lll')}
{dayjs(data.startDate).format('lll')}
</h1>
<UserActionRequired
isAttendanceRequired={data.isAttendanceRequired}
Expand Down
2 changes: 2 additions & 0 deletions src/server/trpc/router/attendance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { router } from '~/server/trpc/trpc'
import { getAllAttendance } from './getAllAttendance'
import { getAllAttendanceButSelf } from './getAllUsersButSelf'
import { markAttendance } from './markAttendance'
import { getEventForUser } from './getEventForUser'

export const attendanceRouter = router({
getAllAttendance,
getAllAttendanceButSelf,
markAttendance,
getEventForUser,
})
4 changes: 0 additions & 4 deletions src/server/trpc/router/event/deleteEvent.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { protectedProcedure } from '~/server/trpc/trpc'
import { z } from 'zod'
import { toDataURL } from 'qrcode'
import { randomUUID } from 'crypto'
import { env } from '~/env/server.mjs'
import eventCollection from '~/server/db/collections/EventCollection'
import { Timestamp } from 'firebase/firestore'
import userCollection from '~/server/db/collections/UserCollection'
import logCollection from '~/server/db/collections/LogCollection'

export const deleteEvent = protectedProcedure
Expand Down
7 changes: 0 additions & 7 deletions src/server/trpc/router/event/updateEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export const updateEvent = protectedProcedure
let qr_code: string | undefined
const id = randomUUID()

if (input.isQrRequired) {
qr_code = await toDataURL(`${env.DOMAIN}/events/${id}`)
}

const users = await Promise.all(
input.attendees.map(async (attendee) => {
const data = await userCollection.getById(attendee)
Expand All @@ -42,16 +38,13 @@ export const updateEvent = protectedProcedure
})
)

const eventID =

await eventCollection.update(input.id, {
attendees: 0,
endDate: Timestamp.fromDate(input.endDate),
hasStarted: false,
invitedAttendees: users,
name: input.name,
startDate: Timestamp.fromDate(input.startDate),
qrCode: qr_code || '',
})
} catch (e) {
await logCollection.add({
Expand Down

0 comments on commit 90d06c1

Please sign in to comment.