Skip to content

Commit

Permalink
feat(upload): upload page logic wip
Browse files Browse the repository at this point in the history
  • Loading branch information
finnc0 committed Mar 25, 2024
1 parent 7d8641b commit f019fe4
Show file tree
Hide file tree
Showing 15 changed files with 1,051 additions and 14 deletions.
4 changes: 2 additions & 2 deletions apps/app/app/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function Header({

return (
<>
<div className="flex justify-between items-center pr-4 w-full py-2 text-gray-500 ">
<div className="flex justify-between items-center pr-4 w-full py-2 text-gray-500 bg-gray-700">
<div className="flex m-8 mx-12">
<div className="font-semibold text-md gap-3 items-center flex flex-row">
<Bars3Icon
Expand All @@ -37,7 +37,7 @@ export default function Header({
) : (
<Spinner />
)}
<span className="text-gray-700 text-nowrap">
<span className="text-white text-nowrap font-medium">
{session && session.name}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const Sidebar = () => {

return (
<>
<div className="hidden lg:flex md:flex w-max ">
<div className="hidden lg:flex md:flex w-max bg-gray-700">
{/* Main Container */}
<div className="pt-12 flex flex-col gap-7 rounded-tr-xl rounded-br-xl bg-black px-6 pr-4 min-h-screen">
{/* Icon Container */}
Expand Down
4 changes: 3 additions & 1 deletion apps/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Header from './components/Header';
import { V2Session, createSession } from 'identity';
import Loading from './components/Loading';
import MobileSidebar from './components/MobileSidebar';
import { Toaster } from 'ui';
function RootLayout({ children }: { children: React.ReactNode }) {
const [session, setSessionState] = useState<V2Session | undefined>();
const [openMobileSidebar, setOpenMobileSidebar] = useState<boolean>(false);
Expand Down Expand Up @@ -45,7 +46,8 @@ function RootLayout({ children }: { children: React.ReactNode }) {
</div>
<div className="flex flex-col w-full">
<Header openMobileSidebarFunc={openMobileSidebarFunc} />
<main className="flex-grow ">{children}</main>
<main className="flex-grow bg-gray-700">{children}</main>
<Toaster />
</div>
</div>
)}
Expand Down
6 changes: 3 additions & 3 deletions apps/app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { Card, CardContent, CardHeader, CardTitle } from 'ui';
const Page = () => {
return (
<div className="flex w-full text-black flex-col gap-6 px-12">
<h1 className="text-2xl font-bold">Waldo Dashboard</h1>
<h1 className="text-2xl font-bold text-white">Waldo Dashboard</h1>
<div className="space-y-3 md:space-y-0 md:flex md:flex-col lg:flex lg:flex-row gap-2 items-stretch w-full">
<Card className="bg-black text-white rounded-lg flex-1">
<Card className="bg-black text-white rounded-lg flex-1 border-none">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">My Uploads</CardTitle>
<ArrowUpOnSquareIcon className="h-4 w-4 text-muted-foreground" />
Expand All @@ -21,7 +21,7 @@ const Page = () => {
<p className="text-xs text-yellow-400">+20.1% recently</p>
</CardContent>
</Card>
<Card className="bg-black text-white rounded-lg flex-1">
<Card className="bg-black text-white rounded-lg flex-1 border-none">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">My Reviews</CardTitle>
<PencilSquareIcon className="h-4 w-4 text-muted-foreground" />
Expand Down
252 changes: 247 additions & 5 deletions apps/app/app/submissions/upload/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,255 @@
import React from 'react';
'use client';
import { useSession } from '@contexts/SessionContext';
import React, { useState, useEffect } from 'react';
import { TbReload } from 'react-icons/tb';
import {
Input,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Checkbox,
useToast,
Button,
} from 'ui';

interface GameItem {
name: string;
id: string;
}

interface CheatItem {
name: string;
id: string;
}

const Upload = () => {
const { toast } = useToast();
const s = useSession();
const session = s?.session;

const [loading, setLoading] = useState<boolean>(false);
const [permissionCheck, setPermissionCheck] = useState<boolean>(false);
const [containCheck, setContainCheck] = useState<boolean>(false);
const [violationAgreement, setViolationAgreement] = useState<boolean>(false);
const [gameplayUrl, setGameplayUrl] = useState<string>('');

const [gameplayType, setGameplayType] = useState<GameItem>();
const [cheatType, setCheatType] = useState<CheatItem>();

const togglePermissionCheck = () => setPermissionCheck(!permissionCheck);
const toggleContainCheck = () => setContainCheck(!containCheck);
const toggleViolationAgreement = () =>
setViolationAgreement(!violationAgreement);

const handleUrlInput = (url: string) => {
if (url.length > 0) {
setGameplayUrl('https:' + url);
} else {
setGameplayUrl('');
}
};

const submit = async () => {
setLoading(true);
// check a few things
console.log(permissionCheck);
if (!violationAgreement || !containCheck || !permissionCheck) {
toast({
title: 'Uh oh! Something went wrong.',
description: 'Please agree to all of the terms.',
});
}
if (gameplayUrl.length < 1) {
toast({
title: 'Uh oh! Something went wrong.',
description: 'Please input your url.',
});
}
setLoading(false);
};

return (
<div className="flex w-full text-black flex-col gap-6 px-12">
<h1 className=" bg-gradient-to-r from-[#6F1DD8] to-[#A21CAF] text-transparent bg-clip-text font-bold text-2xl">
Upload <span className="text-black text-2xl font-bold">your clip</span>
</h1>
<div className="flex flex-col w-full text-black gap-6 px-12 h-full">
<div className="flex flex-row gap-2">
<h1 className=" bg-gradient-to-r from-sigp to-[#A21CAF] text-transparent bg-clip-text font-bold text-2xl">
Upload
</h1>
<span className="text-white text-2xl font-bold">your gameplay</span>
</div>
<div className="w-full h-full flex border-0 border-dashed mb-12 rounded-xl ">
{/* Upload Container Pri */}

<div className="flex px-6 py-5 w-full">
<div className="flex flex-col w-full gap-6">
<div>
<h1 className="text-white font-semibold text-lg">Video URL:</h1>
<Input
onChange={event => handleUrlInput(event.target.value)}
placeholder={'https://outplayed.tv/clip/dfsdgfdg'}
className="mt-2 w-full text-white placeholder:text-gray-500 font-medium border-[1.5px] border-gray-500 bg-transparent"
/>
</div>
<div className="flex w-full flex-col gap-2">
<h1 className="text-white font-semibold text-lg">
Clip Attributes:
</h1>
<div className="flex flex-row gap-6">
<Select>
<SelectTrigger className="w-[180px] bg-black focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 border-none text-white rounded-lg">
<SelectValue placeholder="Select a Game:" />
</SelectTrigger>
<SelectContent className=" text-white bg-black border-none ">
{games.map((game, index) => (
<SelectItem
key={index}
value={game.id}
className="cursor-pointer hover:bg-sigp ho"
>
{game.name}
</SelectItem>
))}
</SelectContent>
</Select>
{session &&
session.scope.includes('write:Gameplay:verified') && (
<Select>
<SelectTrigger className="w-[180px] bg-black focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 border-none text-white rounded-lg">
<SelectValue placeholder="Select a Cheat:" />
</SelectTrigger>
<SelectContent className=" text-white bg-black border-none ">
{cheats.map((cheat, index) => (
<SelectItem
key={index}
value={cheat.id}
className="cursor-pointer hover:bg-sigp ho"
>
{cheat.name}
</SelectItem>
))}
</SelectContent>
</Select>
)}
</div>
<div className="flex mt-6 flex-col gap-6">
<div className="flex items-center space-x-2">
<Checkbox
id="terms"
className="border-bg-black"
onCheckedChange={() => togglePermissionCheck()}
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white"
>
Do you have permission from the owner to submit?
</label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id="terms"
className="border-bg-black"
onCheckedChange={() => toggleContainCheck()}
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white"
>
Does this clip contain the selected game footage?
</label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id="terms"
className="border-bg-black"
onCheckedChange={() => toggleViolationAgreement()}
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-white"
>
I understand any violations I make will result in a
suspension.
</label>
</div>
</div>
<div>
<Button
className="bg-white hover:bg-white text-black px-4 mt-3 font-semibold"
onClick={() => submit()}
disabled={loading}
>
{loading && (
<TbReload className="mr-2 h-4 w-4 animate-spin" />
)}
Submit
</Button>
</div>
</div>
</div>
</div>
</div>
</div>
);
};

const games: GameItem[] = [
{
name: 'Counter Strike: Global Offensive',
id: 'CSGO',
},
{
name: 'VALORANT',
id: 'VALO',
},
{
name: 'Team Fortress 2',
id: 'TF2',
},
{
name: 'Apex Legends',
id: 'APEX',
},
{
name: 'Call of Duty: Warzone',
id: 'CODW',
},
{
name: 'Rainbow Six Siege',
id: 'R6S',
},
{
name: 'Overwatch 2',
id: 'OW2',
},
{
name: 'Counter Strike 2',
id: 'CS2',
},
];

const cheats: CheatItem[] = [
{
name: 'No Cheat',
id: 'NOCHEAT',
},
{
name: 'Aimbot',
id: 'AIMBOT',
},
{
name: 'Trigger Bot',
id: 'TRIGGERBOT',
},
{
name: 'ESP',
id: 'ESP',
},
{
name: 'Spinbot',
id: 'Spinbot',
},
];

export default Upload;
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@marsidev/react-turnstile": "^0.5.3",
"@next-auth/prisma-adapter": "^1.0.7",
"@novu/notification-center": "^0.24.0",
"@radix-ui/react-select": "^2.0.0",
"@sentry/integrations": "^7.107.0",
"@sentry/nextjs": "^7.107.0",
"@sentry/profiling-node": "^7.107.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/identity/rbac/scopes/write/gameplay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Gameplay = {
create: 'write:Gameplay',
verified: 'write:Gameplay',
verified: 'write:Gameplay:verified',
};

export { Gameplay };
28 changes: 28 additions & 0 deletions packages/ui/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';

import { cn } from '../../lib/utils';

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
className,
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;

export { Checkbox };
Loading

0 comments on commit f019fe4

Please sign in to comment.