-
{title}
-
{data}
+
);
}
diff --git a/ui/CardTable.tsx b/ui/CardTable.tsx
index ea40a88..6a4afca 100644
--- a/ui/CardTable.tsx
+++ b/ui/CardTable.tsx
@@ -4,41 +4,42 @@ import AppLink from './AppLink';
export default function CardTable({ puzzles }: { puzzles: Puzzle[] }) {
return (
-
-
-
-
- Exercice |
- Tentative |
- Score |
- Dernier essai |
-
- Reprendre
- |
-
-
-
- {puzzles.length &&
- puzzles.map((puzzle) => (
-
-
- {puzzle.name}
- |
- 30 |
- 300 |
- 10/10/2010 |
-
-
- Reprendre
-
- |
-
- ))}
-
-
-
+ <>>
+ //
+ //
+ // {/*
+ //
+ // Exercice |
+ // Tentative |
+ // Score |
+ // Dernier essai |
+ //
+ // Reprendre
+ // |
+ //
+ // */}
+ //
+ // {puzzles.length &&
+ // puzzles.map((puzzle) => (
+ //
+ //
+ // {puzzle.name}
+ // |
+ // 30 |
+ // 300 |
+ // 10/10/2010 |
+ //
+ //
+ // Reprendre
+ //
+ // |
+ //
+ // ))}
+ //
+ //
+ //
);
}
diff --git a/ui/Puzzle.tsx b/ui/Puzzle.tsx
index dbe42ca..8c0c3a4 100644
--- a/ui/Puzzle.tsx
+++ b/ui/Puzzle.tsx
@@ -1,18 +1,18 @@
'use client';
-import { usePuzzle } from '@/lib/hooks/use-puzzles';
+import { Puzzle as PuzzleType } from '@/lib/puzzles';
import { notFound } from 'next/navigation';
import Button from './Button';
import Input from './Input';
import ToHTML from './ToHTML';
-export default function Puzzle({ id }: { id: number }) {
- const { data: puzzle, isLoading } = usePuzzle(id);
+export default function Puzzle({ puzzle }: { puzzle: PuzzleType }) {
+ // const puzzle = getPuzzle(id);
- if (isLoading) {
- return <>>;
- }
+ // if (isLoading) {
+ // return <>>;
+ // }
if (!puzzle) {
notFound();
diff --git a/ui/Puzzles.tsx b/ui/Puzzles.tsx
index 761a1f0..08ae810 100644
--- a/ui/Puzzles.tsx
+++ b/ui/Puzzles.tsx
@@ -1,39 +1,38 @@
'use client';
-import { usePuzzles } from '@/lib/hooks/use-puzzles';
+import { Chapter, Puzzle } from '@/lib/puzzles';
import AppLink from './AppLink';
import Icon from './Icon';
-export default function Puzzles() {
- const { data, isLoading } = usePuzzles();
+export default function Puzzles({ data }: { data: { chapters: Chapter[]; puzzles: Puzzle[] } }) {
+ // const { data, isLoading } = usePuzzles();
return (
<>
- {!isLoading &&
- data?.chapters?.map((chapter) => (
-
-
-
- Chapitre {chapter.id} - {chapter.name}
-
-
+ {data?.chapters?.map((chapter) => (
+
+
+
+ Chapitre {chapter.id} - {chapter.name}
+
+
-
- {data?.puzzles.map((puzzle) => (
-
- -
- {puzzle.name}
-
-
-
- ))}
-
- ))}
+
+ {data?.puzzles.map((puzzle) => (
+
+ -
+ {puzzle.name}
+
+
+
+ ))}
+
+
+ ))}
>
);
}
diff --git a/ui/UserAuthForm.tsx b/ui/UserAuthForm.tsx
index 59acd24..b57c4a1 100644
--- a/ui/UserAuthForm.tsx
+++ b/ui/UserAuthForm.tsx
@@ -15,9 +15,14 @@ export default function UserAuthForm() {
}
type FormData = {
- email?: string;
- username: string;
- password: string;
+ pseudo: string;
+ email: string;
+ passwd: string;
+ firstname: string;
+ lastname: string;
+ description: string;
+ sgroup: string;
+ avatar: string;
};
function AuthForm() {
@@ -28,9 +33,14 @@ function AuthForm() {
setError
} = useForm
({
defaultValues: {
+ pseudo: '',
email: '',
- username: '',
- password: ''
+ passwd: '',
+ firstname: '',
+ lastname: '',
+ description: '',
+ sgroup: '',
+ avatar: ''
}
});
@@ -39,59 +49,114 @@ function AuthForm() {
const isSignIn = pathname.includes('sign-in');
async function onSubmit(data: FormData) {
- const res = await fetch(`http://170.75.166.204/${isSignIn ? 'login' : 'register'}`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- ...data
- })
- });
+ const response = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/${isSignIn ? 'login' : 'register'}`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ ...data
+ })
+ }
+ );
- if (res.status === 200) {
+ const status = response.status;
+ const json = await response.json();
+
+ console.log(json, status);
+
+ if (status === 200) {
router.push('/dashboard');
}
}
return (
-