diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 7e0d6d2..0000000 --- a/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -app/node_modules/ -app/.env - -# testing -app/coverage - -# next.js -app/.next/ -app/out/ - -# production -app/build - -# debug -app/npm-debug.log* - -# typescript -app/*.tsbuildinfo -app/next-env.d.ts - -# data -app/tools/data/* -app/data/misc/* -app/data/commander/* -app/data/card-commander/* -app/data/bset/* -app/tools/json/* -app/.pg diff --git a/README.md b/README.md deleted file mode 100644 index 1f7ba30..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Projet Brawl Set - -Ce dépot contient le code et la documentation pour le projet Brawl Set. -Pour plus d'information sur l'avancé, allez dans [la section projet](https://git.shenanigans.cc/globuzma/brawlset/projects) du dépot. diff --git a/app/.dockerignore b/app/.dockerignore deleted file mode 100644 index d1a4242..0000000 --- a/app/.dockerignore +++ /dev/null @@ -1,28 +0,0 @@ -node_modules/ -.env - -# testing -coverage - -# next.js -.next/ -out/ - -# production -build - -# debug -npm-debug.log* - -# typescript -*.tsbuildinfo -next-env.d.ts - -# data -tools/data/* -tools/json -data/misc/* -data/commander/* -data/card-commander/* -data/bset/* -.pg/ diff --git a/app/.eslintignore b/app/.eslintignore deleted file mode 100644 index 63ca953..0000000 --- a/app/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -/components/ui/**.tsx diff --git a/app/.eslintrc.json b/app/.eslintrc.json deleted file mode 100644 index 3722418..0000000 --- a/app/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index fd3dbb5..0000000 --- a/app/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/app/Dockerfile b/app/Dockerfile deleted file mode 100644 index 3d8dbca..0000000 --- a/app/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM node:alpine AS build - -WORKDIR /app -COPY package.json ./ -# install dependencies -RUN npm install -COPY . . -# build -RUN npx prisma generate -RUN npm run build - -FROM node:alpine - -WORKDIR /app - -RUN apk add --no-cache openssl -# copy from build image -COPY --from=build /app/package.json ./package.json -COPY --from=build /app/node_modules ./node_modules -COPY --from=build /app/.next ./.next -COPY --from=build /app/public ./public -COPY --from=build /app/tools ./tools -COPY --from=build /app/data ./data -COPY --from=build /app/prisma ./prisma - -EXPOSE 3000 -CMD ["npm","run","start"] diff --git a/app/README.md b/app/README.md deleted file mode 100644 index e215bc4..0000000 --- a/app/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/app/app/account/profile/decks/page.tsx b/app/app/account/profile/decks/page.tsx deleted file mode 100644 index fff5bd9..0000000 --- a/app/app/account/profile/decks/page.tsx +++ /dev/null @@ -1,440 +0,0 @@ -'use client' - -import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog" -import { - Dialog, - DialogContent, - DialogFooter, - DialogClose, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog" - -import { useEffect, useState, useRef } from "react" -import { useRouter } from 'next/navigation' -import { getCookie } from "@/lib/utils" -import { Textarea } from "@/components/ui/textarea" -import { MTGCardTextHover } from "@/components/ui/mtg-card-text-hover" -import { Toaster } from "@/components/ui/toaster" -import { useToast } from "@/hooks/use-toast" -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from "@/components/ui/deck-accordion" -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, -} from "@/components/ui/command" -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover" -import { Spinner } from "@/components/ui/spinner" - -import type { deck, bset, carte, cartes_dans_deck } from "@prisma/client"; - -interface bsetJson extends bset { - set_codes: string[], - icons: string[] -} - -interface deckExtended extends deck { - commander: carte - cartes: cartes_dans_deckExtended[] -} - -interface cartes_dans_deckExtended extends cartes_dans_deck { - carte: carte -} - -interface cardEntryAPIProps { - amount: number, - sanitized_name: string, -} - -interface deckAPIProps { - id?: string, // For Update API - name: string, - selected_bset?: string, // For Create API - url?: string, - commander_name?: string, - cards: cardEntryAPIProps[] -} - -export default function Signin() { - const [deckName, setDeckName] = useState("") - const [deckUrl, setDeckUrl] = useState("") - const [deckCommanderName, setDeckCommanderName] = useState("") - const [deckImporter, setDeckImporter] = useState("") - const [selectedBset, setSelectedBset] = useState("") - const [decks, setDecks] = useState([]) - const [displayedDecks, setDisplayedDecks] = useState([]) - - const [loading, setLoading] = useState(true) - - const [bsets, setBsets] = useState([]) - - const [openSelectBset, setOpenSelectBset] = useState(false) - const router = useRouter() - const token = getCookie('JWT') - - const [deckIdToDelete, setDeckIdToDelete] = useState("") - const deleteDialogRef = useRef(null) - - const [editDeckUrl, setEditDeckUrl] = useState("") - const [editDeckId, setEditDeckId] = useState("") - const [editDeckName, setEditDeckName] = useState("") - const [editDeckImporter, setEditDeckImporter] = useState("") - const [editDeckCommanderName, setEditDeckCommanderName] = useState("") - const editDialogRef = useRef(null) - - const { toast } = useToast() - - useEffect(() => { - if(getCookie('JWT') == "") { - router.refresh() - router.push('/') - } - - fetch('/api/account/decks/', { - method: "GET", - headers: {Authorization: 'Bearer ' + token}, - }).then((res) => { - if(res.status == 200) { - res.json().then((apiData) => { - console.log(apiData.data) - setDecks(apiData.data) - setDisplayedDecks(apiData.data) - setLoading(false) - }) - } - }) - - fetch('/api/json/misc/bsets.json').then((res) => { - if(res.status == 200) { - res.json().then((data) => { - setBsets(data) - }) - } - }) - - },[]) - - function getDataFromLine(line: string){ - if(line != "") { - const data = line.split(" ") - const amount = parseInt(data[0]) - const name = data.slice(1).join(" ").split("/")[0].replace(/[^a-zA-Z0-9]/gim,"-").toLowerCase() - return {"sanitized_name":name, "amount":amount} - } else { - return null - } - - } - - function deleteDeck(id:string){ - fetch('/api/account/decks/delete', { - method: "DELETE", - headers: {Authorization: 'Bearer ' + token}, - body: JSON.stringify({ id }) - }).then((res) => { - if(res.status == 200) { - setDecks(old => old.filter((deck: deck) => deck.id != id)) - setDisplayedDecks(old => old.filter((deck: deck) => deck.id != id)) - toast({ - title: "Deck supprimé", - }) - } - }) - } - - function updateDeckInput(txt:string){ - setDeckImporter(txt) - const lines = txt.split("\n") - setDeckCommanderName(lines[lines.length - 1].slice(1)) - } - - function updateEditDeckInput(txt:string){ - setEditDeckImporter(txt) - const lines = txt.split("\n") - setEditDeckCommanderName(lines[lines.length - 1].slice(1)) - } - - function editDialogHandler(id:string){ - const deck_to_edit = decks.find((deck: deck) => deck.id === id) - setEditDeckId(id) - setEditDeckName(deck_to_edit ? deck_to_edit.name : "") - setEditDeckUrl(deck_to_edit && deck_to_edit.url != null ? deck_to_edit.url : "") - editDialogRef.current?.click() - } - - function importDeck(){ - const deckText = deckImporter - let lines = deckText.split("\n") - lines = lines.filter((line) => line.match(/[0-9]+\s[\w]+/) != undefined) - const dataToSend : deckAPIProps = { name: deckName, url: deckUrl, selected_bset: selectedBset.replace(/[^a-zA-Z0-9]/gim,"-").toLowerCase() ,commander_name: getDataFromLine(deckCommanderName)!.sanitized_name, cards: [] } - lines.slice(0, lines.length - 1).forEach((line: string) => { - const data = getDataFromLine(line) - if(data != null) { - dataToSend.cards.push(data) - } - }); - - fetch('/api/account/decks/create', { - method: "POST", - headers: {Authorization: 'Bearer ' + token}, - body: JSON.stringify(dataToSend) - }).then((res) => { - if(res.status == 200) { - res.json().then((apiData) => { - const new_deck: deckExtended = apiData.data - setDisplayedDecks([...decks, new_deck]) - setDecks(oldDecks => [...oldDecks, new_deck]) - setDeckName("") - setDeckImporter("") - setSelectedBset("") - setDeckCommanderName("") - setDeckUrl("") - toast({ - title: "Deck " + new_deck.name + " créé.", - }) - }) - } else if (res.status == 401) { - res.json().then((apiData) => { - toast({ - title: "ERROR : " + apiData.message, - }) - }) - } - }) - } - - function updateDeck(){ - const deckText = editDeckImporter - let lines = deckText.split("\n") - lines = lines.filter((line) => line.match(/[0-9]+\s[\w]+/) != undefined) - const dataToSend : deckAPIProps = { id: editDeckId, name: editDeckName, url: editDeckUrl, commander_name: editDeckCommanderName != "" ? getDataFromLine(editDeckCommanderName)!.sanitized_name : undefined, cards: [] } - if (editDeckImporter != "") { - lines.slice(0, lines.length - 1).forEach((line: string) => { - const data = getDataFromLine(line) - if(data != null) { - dataToSend.cards.push(data) - } - }) - } - console.log(dataToSend) - - fetch('/api/account/decks/update', { - method: "PUT", - headers: {Authorization: 'Bearer ' + token}, - body: JSON.stringify(dataToSend) - }).then((res) => { - if(res.status == 200) { - res.json().then((apiData) => { - const new_deck = apiData.data - - const displayedDecksIndex = displayedDecks.findIndex((deck) => deck.id == new_deck.id) - if (displayedDecksIndex != -1) { setDisplayedDecks(oldDecks => [...oldDecks.slice(0, displayedDecksIndex),new_deck,...oldDecks.slice(displayedDecksIndex + 1)]) } - - const decksIndex = decks.findIndex((deck) => deck.id == new_deck.id) - if (decksIndex != -1) { setDecks(oldDecks => [...oldDecks.slice(0, decksIndex),new_deck,...oldDecks.slice(decksIndex + 1)]) } - - console.log(apiData) - toast({ - title: "Deck " + new_deck.name + " mis à jour.", - }) - }) - } else if (res.status == 401) { - res.json().then((apiData) => { - toast({ - title: "ERROR : " + apiData.message, - }) - }) - } - }) - } - - function deleteAlertHandler(id:string, mode:string) { - if (mode == "set") { - deleteDialogRef.current?.click() - } else if (mode == "delete") { - deleteDeck(deckIdToDelete) - } - setDeckIdToDelete(id) - } - - function filterDecks(searchString:string) { - if(searchString != "") { - setDisplayedDecks(decks.filter((deck) => deck.name.toLowerCase().includes(searchString.toLowerCase()))) - } else { - setDisplayedDecks(decks) - } - } - - return ( -
-
-
-
-