From 660d7ccbbbb15435b1802eadc605615f62396120 Mon Sep 17 00:00:00 2001 From: BudzioT Date: Thu, 26 Dec 2024 01:59:06 +0100 Subject: [PATCH] Added multi flagging --- src/app/harbor/battles/battles.tsx | 62 ++++++++++++++------------- src/app/harbor/battles/fraud-utils.ts | 6 +-- src/components/ui/multi-select.tsx | 41 +++++++++++------- 3 files changed, 61 insertions(+), 48 deletions(-) diff --git a/src/app/harbor/battles/battles.tsx b/src/app/harbor/battles/battles.tsx index 33da9921..5c0ac3c3 100644 --- a/src/app/harbor/battles/battles.tsx +++ b/src/app/harbor/battles/battles.tsx @@ -26,6 +26,7 @@ import Modal from '@/components/ui/modal' import { sendFraudReport } from './fraud-utils' import { Button } from '@/components/ui/button' import { Howl } from 'howler' +import { MultiSelect } from '@/components/ui/multi-select' interface Matchup { project1: Ships project2: Ships @@ -47,7 +48,7 @@ export default function Matchups({ session }: { session: HsSession }) { const [blessed, setBlessed] = useState(false) const [fraudProject, setFraudProject] = useState() - const [fraudType, setFraudType] = useState() + const [fraudTypes, setFraudTypes] = useState() const [fraudReason, setFraudReason] = useState() const debounceTimeoutRef = useRef(null) @@ -390,11 +391,11 @@ export default function Matchups({ session }: { session: HsSession }) { window.clearTimeout(debounceTimeoutRef.current) } - if (!fraudProject || !fraudReason || !fraudType) return + if (!fraudProject || !fraudReason || !fraudTypes) return debounceTimeoutRef.current = window.setTimeout(async () => { try { - await sendFraudReport(fraudProject, fraudType, fraudReason) + await sendFraudReport(fraudProject, fraudTypes, fraudReason) } catch (error) { console.error('Failed to flag project:', error) } @@ -407,8 +408,8 @@ export default function Matchups({ session }: { session: HsSession }) { setFraudProject(undefined) setFraudReason('') - setFraudType('') - }, [fraudProject, fraudType, fraudReason]) + setFraudTypes(null) + }, [fraudProject, fraudTypes, fraudReason]) if (isReadmeView) { return ( @@ -508,47 +509,50 @@ export default function Matchups({ session }: { session: HsSession }) {

Why are you flagging {fraudProject?.title}?

- + + setFraudTypes(val)} + hideSelectAll={true} + className="my-4" + /> - {fraudType === 'Incomplete README' || - fraudType === 'No demo link' || - fraudType === 'No screenshot' || - fraudType === 'Wrong repo' ? ( + {fraudTypes?.includes('Suspected fraud') ? (

- The creator of this project will be notified. Thanks for - making High Seas better! :) + The creator of this project will not know you reported + them for potential fraud.{' '} + Only the High Seas team will see this.

) : null} - {fraudType === 'Suspected fraud' ? ( + {fraudTypes?.includes('Incomplete README') || + fraudTypes?.includes('No demo link') || + fraudTypes?.includes('No screenshot') || + fraudTypes?.includes('Wrong repo') ? (

- The creator of this project will not know you reported - them. Only the High Seas team will see this. + The creator of this project will be notified about + incorrect links. Thanks for making High Seas better! :)

) : null} @@ -564,7 +568,7 @@ export default function Matchups({ session }: { session: HsSession }) {