-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 1884-get-contest-submission-informations-abo…
…ut-one-user
- Loading branch information
Showing
43 changed files
with
649 additions
and
350 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
apps/backend/prisma/migrations/20240805054610_add_map_image/migration.sql
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,26 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Image` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Image" DROP CONSTRAINT "Image_createdById_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "Image"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "image" ( | ||
"filename" TEXT NOT NULL, | ||
"createdById" INTEGER, | ||
"create_time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "image_pkey" PRIMARY KEY ("filename") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "image_filename_key" ON "image"("filename"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "image" ADD CONSTRAINT "image_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
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 |
---|---|---|
@@ -1,70 +1,91 @@ | ||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' | ||
'use client' | ||
|
||
import { cn, dateFormatter } from '@/lib/utils' | ||
import CalendarIcon from '@/public/20_calendar.svg' | ||
import ClockIcon from '@/public/20_clock.svg' | ||
import type { Contest } from '@/types/type' | ||
import { FaRegClock } from 'react-icons/fa' | ||
import { FaRegCalendarAlt } from 'react-icons/fa' | ||
import Badge from './Badge' | ||
import Image from 'next/image' | ||
import { CircularProgressbar } from 'react-circular-progressbar' | ||
import 'react-circular-progressbar/dist/styles.css' | ||
import StatusBadge from './StatusBadge' | ||
import TimeDiff from './TimeDiff' | ||
|
||
const variants = { | ||
ongoing: 'bg-gradient-to-br from-blue-500 to-blue-950', | ||
upcoming: 'bg-gradient-to-br from-emerald-600 to-emerald-900', | ||
const bgVariants = { | ||
ongoing: 'bg-gradient-to-b from-blue-100 to-white', | ||
upcoming: 'bg-white', | ||
finished: 'bg-gray-500', | ||
registeredOngoing: 'bg-gradient-to-br from-blue-500 to-blue-950', | ||
registeredUpcoming: 'bg-gradient-to-br from-emerald-600 to-emerald-900' | ||
registeredOngoing: 'bg-gradient-to-b from-blue-100 to-white', | ||
registeredUpcoming: 'bg-white' | ||
} | ||
|
||
const txtVariants = { | ||
ongoing: 'text-blue-500', | ||
upcoming: 'text-red-400', | ||
finished: 'text-gray-500', | ||
registeredOngoing: 'text-blue-500', | ||
registeredUpcoming: 'text-red-400' | ||
} | ||
interface Props { | ||
contest: Contest | ||
} | ||
|
||
const format = (target: Date, year: number): string => | ||
new Date(target).getFullYear() === year | ||
? dateFormatter(target, 'MMM DD') | ||
: dateFormatter(target, 'MMM DD, YYYY') | ||
|
||
export default function ContestCard({ contest }: Props) { | ||
const year = new Date().getFullYear() | ||
const startTime = format(contest.startTime, year) | ||
const endTime = format(contest.endTime, year) | ||
const startTime = dateFormatter(contest.startTime, 'YYYY-MM-DD') | ||
const endTime = dateFormatter(contest.endTime, 'YYYY-MM-DD') | ||
|
||
return ( | ||
<Card | ||
<div | ||
className={cn( | ||
'flex w-full flex-col justify-between gap-1 border-none text-white shadow-none transition hover:scale-105 hover:opacity-80', | ||
variants[contest.status] | ||
'flex w-full flex-col justify-between gap-1 rounded-md border border-gray-200 px-3 shadow-none transition hover:scale-105 hover:opacity-80', | ||
bgVariants[contest.status] | ||
)} | ||
> | ||
<CardHeader className="pb-0"> | ||
<Badge type={contest.status}> | ||
<p> | ||
{contest.status.startsWith('registered') | ||
? 'registered' | ||
: contest.status} | ||
</p> | ||
</Badge> | ||
<CardTitle className="overflow-hidden text-ellipsis whitespace-nowrap text-lg font-semibold"> | ||
<div | ||
className={cn( | ||
'flex flex-col justify-between gap-4 pt-4 uppercase', | ||
txtVariants[contest.status] | ||
)} | ||
> | ||
<StatusBadge variant={contest.status} /> | ||
<div className="line-clamp-2 h-14 whitespace-pre-wrap text-lg font-semibold leading-tight text-black"> | ||
{contest.title} | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent className="inline-flex items-center gap-1 whitespace-nowrap text-xs text-white opacity-80"> | ||
{contest.status === 'finished' ? ( | ||
<> | ||
<FaRegCalendarAlt className="shrink-0" /> | ||
</div> | ||
</div> | ||
<div className="mb-4 flex items-center justify-between"> | ||
<div className="flex flex-col gap-2"> | ||
<div className="inline-flex items-center gap-2 whitespace-nowrap text-xs text-gray-800 opacity-80"> | ||
<Image src={CalendarIcon} alt="Calendar" /> | ||
<p className="overflow-hidden text-ellipsis whitespace-nowrap"> | ||
{startTime} - {endTime} | ||
{startTime} ~ {endTime} | ||
</p> | ||
</> | ||
) : ( | ||
<> | ||
<FaRegClock className="shrink-0" /> | ||
{contest.status === 'ongoing' ? 'Ends in' : 'Starts in'} | ||
<p className="overflow-hidden text-ellipsis whitespace-nowrap"> | ||
<TimeDiff timeRef={contest.endTime}></TimeDiff> | ||
</p> | ||
</> | ||
</div> | ||
|
||
<div className="inline-flex items-center gap-2 whitespace-nowrap text-xs text-gray-800 opacity-80"> | ||
{contest.status === 'finished' ? ( | ||
<> | ||
<Image src={CalendarIcon} alt="Calendar" /> | ||
<p className="overflow-hidden text-ellipsis whitespace-nowrap"> | ||
{startTime} - {endTime} | ||
</p> | ||
</> | ||
) : ( | ||
<> | ||
<Image src={ClockIcon} alt="Clock" /> | ||
{contest.status === 'ongoing' ? 'Ends in' : 'Starts in'} | ||
<p className="overflow-hidden text-ellipsis whitespace-nowrap"> | ||
<TimeDiff timeRef={contest.endTime}></TimeDiff> | ||
</p> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
{(contest.status == 'ongoing' || | ||
contest.status == 'registeredOngoing') && ( | ||
<div className="h-12 w-12"> | ||
<CircularProgressbar value={60} text={`60%`} /> | ||
</div> | ||
)} | ||
</CardContent> | ||
</Card> | ||
</div> | ||
</div> | ||
) | ||
} |
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
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,48 @@ | ||
import { cn } from '@/lib/utils' | ||
import FinishedIcon from '@/public/20_finished.svg' | ||
import OngoingIcon from '@/public/20_ongoing.svg' | ||
import UpcomingIcon from '@/public/20_upcoming.svg' | ||
import Image from 'next/image' | ||
import React from 'react' | ||
|
||
const variants = { | ||
registeredOngoing: { | ||
image: OngoingIcon, | ||
text: 'ONGOING', | ||
color: 'text-blue-500' | ||
}, | ||
registeredUpcoming: { | ||
image: UpcomingIcon, | ||
text: 'UPCOMING', | ||
color: 'text-red-400' | ||
}, | ||
ongoing: { | ||
image: OngoingIcon, | ||
text: 'ONGOING', | ||
color: 'text-blue-500' | ||
}, | ||
upcoming: { | ||
image: UpcomingIcon, | ||
text: 'UPCOMING', | ||
color: 'text-red-400' | ||
}, | ||
finished: { | ||
image: FinishedIcon, | ||
text: 'FINISHED', | ||
color: 'text-gray-400' | ||
} | ||
} | ||
|
||
interface Props { | ||
variant: keyof typeof variants | ||
} | ||
|
||
export default function StatusBadge({ variant }: Props) { | ||
const { image, text, color } = variants[variant] | ||
return ( | ||
<div className="inline-flex items-center gap-2"> | ||
<Image src={image} alt={text} /> | ||
<p className={cn('font-mono font-medium', color)}>{text}</p> | ||
</div> | ||
) | ||
} |
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.