diff --git a/src/app/_components/feedArticleList/feedArticleList.tsx b/src/app/_components/feedArticleList/feedArticleList.tsx
deleted file mode 100644
index 437d40f..0000000
--- a/src/app/_components/feedArticleList/feedArticleList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Pagination, PaginationItem } from "@/modules/common/components/pagination";
-import { calcTotalPageNumber } from "@/modules/common/functions/pagination";
-import { ArticleCard } from "@/modules/features/article/components/articleCard";
-import { fetchFeedArticles } from "@/modules/features/article/fetch/fetchArticleList";
-
-const Pages = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => (
-
- {[...Array(totalPages)].map((_, index) => {
- const page = index + 1;
- const href = `/?tab=global&page=${page}`;
- return (
-
- {page}
-
- );
- })}
-
-);
-
-export const FeedArticleList = async ({ currentPage }: { currentPage: number }) => {
- const { articles, articlesCount } = await fetchFeedArticles(currentPage);
- const totalPages = calcTotalPageNumber(articlesCount, 10);
-
- return articles.length < 1 ? (
-
No articles found.
- ) : (
- <>
- {articles.map((article, index) => (
-
- ))}
- {1 < totalPages && }
- >
- );
-};
diff --git a/src/app/_components/feedArticleList/index.ts b/src/app/_components/feedArticleList/index.ts
deleted file mode 100644
index 030dad4..0000000
--- a/src/app/_components/feedArticleList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./feedArticleList";
diff --git a/src/app/_components/globalArticleList/globalArticleList.tsx b/src/app/_components/globalArticleList/globalArticleList.tsx
deleted file mode 100644
index cb79c31..0000000
--- a/src/app/_components/globalArticleList/globalArticleList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Pagination, PaginationItem } from "@/modules/common/components/pagination";
-import { calcTotalPageNumber } from "@/modules/common/functions/pagination";
-import { ArticleCard } from "@/modules/features/article/components/articleCard";
-import { fetchGlobalArticles } from "@/modules/features/article/fetch/fetchArticleList";
-
-const Pages = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => (
-
- {[...Array(totalPages)].map((_, index) => {
- const page = index + 1;
- const href = `/?tab=global&page=${page}`;
- return (
-
- {page}
-
- );
- })}
-
-);
-
-export const GlobalArticleList = async ({ currentPage }: { currentPage: number }) => {
- const { articles, articlesCount } = await fetchGlobalArticles(currentPage);
- const totalPages = calcTotalPageNumber(articlesCount, 10);
-
- return articles.length < 1 ? (
- No articles found.
- ) : (
- <>
- {articles.map((article, index) => (
-
- ))}
- {1 < totalPages && }
- >
- );
-};
diff --git a/src/app/_components/globalArticleList/index.ts b/src/app/_components/globalArticleList/index.ts
deleted file mode 100644
index 599df6a..0000000
--- a/src/app/_components/globalArticleList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./globalArticleList";
diff --git a/src/app/_components/layoutElements/index.ts b/src/app/_components/layoutElements/index.ts
deleted file mode 100644
index a2fcb59..0000000
--- a/src/app/_components/layoutElements/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./logoHeader";
-export * from "./logoSmall";
\ No newline at end of file
diff --git a/src/app/_components/layoutElements/logoHeader.tsx b/src/app/_components/layoutElements/logoHeader.tsx
deleted file mode 100644
index 1595f4e..0000000
--- a/src/app/_components/layoutElements/logoHeader.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-const LogoHeader: React.FC = () => {
- return (
-
- );
-};
-
-export default LogoHeader;
diff --git a/src/app/_components/layoutElements/logoSmall.tsx b/src/app/_components/layoutElements/logoSmall.tsx
deleted file mode 100644
index f353085..0000000
--- a/src/app/_components/layoutElements/logoSmall.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-const LogoSmall: React.FC = () => {
- return (
-
- );
-};
-
-export default LogoSmall;
diff --git a/src/app/_components/tagArticleList/index.ts b/src/app/_components/tagArticleList/index.ts
deleted file mode 100644
index 571cbff..0000000
--- a/src/app/_components/tagArticleList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./tagArticleList";
diff --git a/src/app/_components/tagArticleList/tagArticleList.tsx b/src/app/_components/tagArticleList/tagArticleList.tsx
deleted file mode 100644
index 6c91df8..0000000
--- a/src/app/_components/tagArticleList/tagArticleList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Pagination, PaginationItem } from "@/modules/common/components/pagination";
-import { calcTotalPageNumber } from "@/modules/common/functions/pagination";
-import { ArticleCard } from "@/modules/features/article/components/articleCard";
-import { fetchArticlesByTag } from "@/modules/features/article/fetch/fetchArticleList";
-
-const Pages = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => (
-
- {[...Array(totalPages)].map((_, index) => {
- const page = index + 1;
- const href = `/?tab=global&page=${page}`;
- return (
-
- {page}
-
- );
- })}
-
-);
-
-export const TagArticleList = async ({ tag, currentPage }: { tag: string; currentPage: number }) => {
- const { articles, articlesCount } = await fetchArticlesByTag(tag, currentPage);
- const totalPages = calcTotalPageNumber(articlesCount, 10);
-
- return articles.length < 1 ? (
- No articles found.
- ) : (
- <>
- {articles.map((article, index) => (
-
- ))}
- {1 < totalPages && }
- >
- );
-};
diff --git a/src/app/_components/tagList/container.tsx b/src/app/_components/tagList/container.tsx
deleted file mode 100644
index 620a37b..0000000
--- a/src/app/_components/tagList/container.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { fetchTagsList } from "@/modules/features/article/fetch/fetchTagsList";
-import { TagList as TagListPresentation } from "./presentation";
-
-export const TagList = async () => {
- const tags = await fetchTagsList();
- return ;
-};
diff --git a/src/app/_components/tagList/index.ts b/src/app/_components/tagList/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/_components/tagList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/_components/tagList/presentation.tsx b/src/app/_components/tagList/presentation.tsx
deleted file mode 100644
index 152b78f..0000000
--- a/src/app/_components/tagList/presentation.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Tag } from "@/modules/features/article/components/tag";
-
-type Props = { tags: string[] };
-
-export const TagList = ({ tags }: Props) => (
-
-
Popular Tags
-
- {tags.map((tag, index) => (
-
- {tag}
-
- ))}
-
-
-);
diff --git a/src/app/_components/timeClock/index.ts b/src/app/_components/timeClock/index.ts
deleted file mode 100644
index 27bf14f..0000000
--- a/src/app/_components/timeClock/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./timeClock";
diff --git a/src/app/_components/timeClock/timeClock.tsx b/src/app/_components/timeClock/timeClock.tsx
deleted file mode 100644
index c2ca8bd..0000000
--- a/src/app/_components/timeClock/timeClock.tsx
+++ /dev/null
@@ -1,184 +0,0 @@
-"use client";
-
-import React, { useEffect } from "react";
-
-const TimeClock: React.FC = () => {
- useEffect(() => {
- const numbers = [
- [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1], // 0
- [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1], // 1
- [1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1], // 2
- [1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 3
- [1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1], // 4
- [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1], // 5
- [1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1], // 6
- [1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0], // 7
- [1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 8
- [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 9
- ];
-
- const blocks: Array = [];
- const digits = Array.from(document.querySelectorAll(".block"));
-
- for (let i = 0; i < 4; i++) {
- blocks.push(digits.slice(i * 15, i * 15 + 15));
- }
-
- const setNum = (block: Array, num: number) => {
- const n = numbers[num];
- for (let i = 0; i < block.length; i++) {
- block[i].classList[n[i] === 1 ? "add" : "remove"]("active");
- }
- };
-
- const time = {
- s: "",
- m: "",
- h: "",
- p: 0,
- };
-
- // time loop
- const animator = () => {
- const d = new Date();
- let h = d.getHours().toString(),
- m = d.getMinutes().toString(),
- s = d.getSeconds().toString();
-
- s = s.length === 1 ? "0" + s : s;
- m = m.length === 1 ? "0" + m : m;
- h = h.length === 1 ? "0" + h : h;
-
- if (s !== time.s) {
- for (let i = 0; i < digits.length; i++) {
- const d = digits[i];
- if (i === +s) {
- d.classList.add("second");
- if (time.p !== null) digits[time.p].classList.remove("second");
- time.p = i;
- time.s = s;
- }
- }
- }
-
- if (m !== time.m) {
- setNum(blocks[2], parseInt(Array.from(m)[0]));
- setNum(blocks[3], parseInt(Array.from(m)[1]));
- time.m = m;
- }
-
- if (h !== time.h) {
- setNum(blocks[0], parseInt(Array.from(h)[0]));
- setNum(blocks[1], parseInt(Array.from(h)[1]));
- time.h = h;
- }
- window.requestAnimationFrame(animator);
- };
-
- // init
- window.requestAnimationFrame(animator);
-
- // toggle button
- const d = new Date();
- const days = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"];
- const months = [
- "Janvier",
- "Février",
- "Mars",
- "Avril",
- "Mai",
- "Juin",
- "Juillet",
- "Août",
- "Septembre",
- "Octobre",
- "Novembre",
- "Décembre",
- ];
- const lib_d = days[d.getDay()];
- const lib_m = months[d.getMonth()];
- const lib_n = d.getDate();
- const lib_y = d.getFullYear();
- document.getElementById("datelib")!.innerHTML = lib_d + " " + lib_n + " " + lib_m + " " + lib_y;
- }, []);
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-};
-
-export default TimeClock;
diff --git a/src/app/_types/index.ts b/src/app/_types/index.ts
deleted file mode 100644
index 7016380..0000000
--- a/src/app/_types/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { z } from "zod";
-
-export const SearchParams = z.object({
- page: z.coerce.number().int().min(1).catch(1),
- tab: z.enum(["yours", "global", "tag"]).default("global"),
- tag: z.string().optional(),
-});
-
-export type SearchParams = z.infer;
diff --git a/src/app/article/[slug]/_components/articleArea/articleArea.module.css b/src/app/article/[slug]/_components/articleArea/articleArea.module.css
deleted file mode 100644
index 527f81c..0000000
--- a/src/app/article/[slug]/_components/articleArea/articleArea.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.actions {
- & * + * {
- margin-left: 10px;
- }
-}
-
-.action-btn + .action-btn {
- margin-left: 5px;
-}
diff --git a/src/app/article/[slug]/_components/articleArea/articleArea.tsx b/src/app/article/[slug]/_components/articleArea/articleArea.tsx
deleted file mode 100644
index 4c07695..0000000
--- a/src/app/article/[slug]/_components/articleArea/articleArea.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import { Button } from "@/modules/common/components/button";
-import { DeleteArticleButton } from "@/modules/features/article/components/deleteArticleButton";
-import { FavoriteButton } from "@/modules/features/article/components/favoriteButton";
-import { Tag } from "@/modules/features/article/components/tag";
-import { fetchArticle } from "@/modules/features/article/fetch/fetchArticle";
-import { convertMarkdownToHtml } from "@/modules/features/article/functions";
-import { FollowButton } from "@/modules/features/profile/components/followButton";
-import { Article, User } from "@/utils/types/models";
-import Link from "next/link";
-import Image from "next/image";
-import { ReactNode } from "react";
-import styles from "./articleArea.module.css";
-import { showDeleteArticleButton, showEditArticleButton, showFollowButton } from "./functions";
-import { getSession } from "@/utils/auth/session";
-import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
-
-const Actions = ({ article, currentUser }: { article: Article; currentUser?: User }) => {
- const profile = article.author;
-
- return (
-
-
{profile.image &&
}
-
-
- {profile.username}
-
- {article.createdAt.toDateString()}
-
- {showFollowButton(profile.username, currentUser) && (
-
- )}
-
- {showEditArticleButton(profile.username, currentUser) && (
-
- )}
- {showDeleteArticleButton(profile.username, currentUser) && (
-
- )}
-
- );
-};
-
-export const ArticleArea = async ({ slug, children }: { slug: string; children: ReactNode }) => {
- const article = await fetchArticle(slug);
- const body = await convertMarkdownToHtml(article.body);
- const currentUser = (await getSession()) ? await fetchCurrentUser() : undefined;
-
- return (
-
-
- {article.title}
-
-
-
-
-
-
-
- {article.tagList.map((tag, index) => (
- -
-
- {tag}
-
-
- ))}
-
-
-
-
-
- {children}
-
-
- );
-};
diff --git a/src/app/article/[slug]/_components/articleArea/functions.ts b/src/app/article/[slug]/_components/articleArea/functions.ts
deleted file mode 100644
index 4c39799..0000000
--- a/src/app/article/[slug]/_components/articleArea/functions.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { User } from "@/utils/types/models";
-
-export const showFollowButton = (authorUsername: string, currentUser: User | undefined) => {
- return authorUsername !== currentUser?.username;
-};
-
-export const showEditArticleButton = (authorUsername: string, currentUser: User | undefined) => {
- return authorUsername === currentUser?.username;
-};
-
-export const showDeleteArticleButton = (authorUsername: string, currentUser: User | undefined) => {
- return authorUsername === currentUser?.username;
-};
diff --git a/src/app/article/[slug]/_components/articleArea/index.ts b/src/app/article/[slug]/_components/articleArea/index.ts
deleted file mode 100644
index ebe58aa..0000000
--- a/src/app/article/[slug]/_components/articleArea/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./articleArea";
diff --git a/src/app/article/[slug]/_components/commentCard/action.ts b/src/app/article/[slug]/_components/commentCard/action.ts
deleted file mode 100644
index 1aec53a..0000000
--- a/src/app/article/[slug]/_components/commentCard/action.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-"use server";
-
-import { createApiClient } from "@/utils/api/apiClient";
-import { getSession } from "@/utils/auth/session";
-import { revalidateTag } from "next/cache";
-import { redirect } from "next/navigation";
-import { Inputs } from "./types";
-
-export const deleteCommentAction = async (_prevState: undefined, inputs: Inputs): Promise => {
- if ((await getSession()) == null) {
- redirect("/login");
- }
-
- const apiClient = createApiClient({
- path: "/articles/{slug}/comments/{id}",
- method: "delete",
- params: {
- path: inputs,
- },
- });
-
- const response = await apiClient.sendRequest();
-
- if (response.result === "success") {
- revalidateTag("");
- return undefined;
- }
-
- throw new Error("api error");
-};
diff --git a/src/app/article/[slug]/_components/commentCard/container.tsx b/src/app/article/[slug]/_components/commentCard/container.tsx
deleted file mode 100644
index 5e6b400..0000000
--- a/src/app/article/[slug]/_components/commentCard/container.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-"use client";
-
-import { Comment, User } from "@/utils/types/models";
-import { use, useActionState } from "react";
-import { deleteCommentAction as serverAction } from "./action";
-import { CommentCard as CommentCardPresentation } from "./presentation";
-import { showDeleteCommentButton } from "./functions";
-
-type Props = {
- slug: string;
- comment: Comment;
- currentUserPromise?: Promise;
-};
-
-export const CommentCard = ({ slug, comment, currentUserPromise }: Props) => {
- const [_state, dispatch, isPending] = useActionState(serverAction, undefined);
-
- const action = () => {
- if (!confirm("Delete comment?")) {
- return;
- }
- dispatch({ slug, id: comment.id });
- };
-
- return (
-
- );
-};
diff --git a/src/app/article/[slug]/_components/commentCard/functions.ts b/src/app/article/[slug]/_components/commentCard/functions.ts
deleted file mode 100644
index f128b35..0000000
--- a/src/app/article/[slug]/_components/commentCard/functions.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { User } from "@/utils/types/models";
-
-export const showDeleteCommentButton = (commentAuthorUsername: string, currentUser?: User) => {
- return commentAuthorUsername === currentUser?.username;
-};
diff --git a/src/app/article/[slug]/_components/commentCard/index.ts b/src/app/article/[slug]/_components/commentCard/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/article/[slug]/_components/commentCard/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/article/[slug]/_components/commentCard/presentation.module.css b/src/app/article/[slug]/_components/commentCard/presentation.module.css
deleted file mode 100644
index 5b1c050..0000000
--- a/src/app/article/[slug]/_components/commentCard/presentation.module.css
+++ /dev/null
@@ -1,13 +0,0 @@
-.form {
- display: inline;
-
- & button {
- background: none;
- color: inherit;
- border: none;
- padding: 0;
- font: inherit;
- cursor: pointer;
- outline: inherit;
- }
-}
diff --git a/src/app/article/[slug]/_components/commentCard/presentation.tsx b/src/app/article/[slug]/_components/commentCard/presentation.tsx
deleted file mode 100644
index 764e3f6..0000000
--- a/src/app/article/[slug]/_components/commentCard/presentation.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Button, Form } from "react-bootstrap";
-import Link from "next/link";
-import Image from "next/image";
-import { Comment } from "@/utils/types/models";
-import styles from "./presentation.module.css";
-
-type Props = {
- comment: Comment;
- showDeleteCommentButton?: boolean;
- deleteCommentAction?: () => void;
- isPending?: boolean;
-};
-
-export const CommentCard = ({ comment, showDeleteCommentButton, deleteCommentAction }: Props) => {
- return (
-
-
-
-
- {comment.author.image && }
-
-
-
- {comment.author.username}
-
- {comment.createdAt.toDateString()}
- {showDeleteCommentButton && (
-
- )}
-
-
- );
-};
diff --git a/src/app/article/[slug]/_components/commentCard/types.ts b/src/app/article/[slug]/_components/commentCard/types.ts
deleted file mode 100644
index 919dd86..0000000
--- a/src/app/article/[slug]/_components/commentCard/types.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export type Inputs = {
- slug: string;
- id: string;
-};
diff --git a/src/app/article/[slug]/_components/commentForm/action.ts b/src/app/article/[slug]/_components/commentForm/action.ts
deleted file mode 100644
index b63369d..0000000
--- a/src/app/article/[slug]/_components/commentForm/action.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-"use server";
-
-import { createApiClient } from "@/utils/api/apiClient";
-import { getSession } from "@/utils/auth/session";
-import { SubmissionResult } from "@conform-to/react";
-import { parseWithZod } from "@conform-to/zod";
-import { revalidateTag } from "next/cache";
-import { redirect } from "next/navigation";
-import { inputsSchema } from "./types";
-
-export const postCommentAction = async (
- _prevState: unknown,
- formData: FormData,
-): Promise> => {
- if ((await getSession()) == null) {
- redirect("/login");
- }
-
- const submission = parseWithZod(formData, { schema: inputsSchema });
-
- if (submission.status !== "success") {
- return submission.reply();
- }
-
- const { slug, body } = submission.value;
-
- const apiClient = createApiClient({
- path: "/articles/{slug}/comments",
- method: "post",
- params: {
- path: {
- slug,
- },
- body: {
- comment: {
- body,
- },
- },
- },
- });
-
- const response = await apiClient.sendRequest();
-
- if (response.result === "success") {
- revalidateTag("");
- return submission.reply();
- }
-
- switch (response.statusCode) {
- case 422:
- return submission.reply({
- formErrors: Object.values(response.error.errors).flat(),
- });
- default:
- throw new Error("api error");
- }
-};
diff --git a/src/app/article/[slug]/_components/commentForm/container.tsx b/src/app/article/[slug]/_components/commentForm/container.tsx
deleted file mode 100644
index 60d5f2b..0000000
--- a/src/app/article/[slug]/_components/commentForm/container.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-"use client";
-
-import { User } from "@/utils/types/models";
-import { use, useActionState } from "react";
-import { postCommentAction } from "./action";
-import { CommentForm as CommentFormPresentation } from "./presentation";
-
-type Props = {
- slug: string;
- currentUserPromise?: Promise;
-};
-
-export const CommentForm = ({ slug, currentUserPromise }: Props) => {
- const currentUser = currentUserPromise && use(currentUserPromise);
- const [state, action, isPending] = useActionState(postCommentAction, undefined);
-
- return (
-
- );
-};
diff --git a/src/app/article/[slug]/_components/commentForm/index.ts b/src/app/article/[slug]/_components/commentForm/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/article/[slug]/_components/commentForm/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/article/[slug]/_components/commentForm/presentation.tsx b/src/app/article/[slug]/_components/commentForm/presentation.tsx
deleted file mode 100644
index 3a4b99e..0000000
--- a/src/app/article/[slug]/_components/commentForm/presentation.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Button, Form } from "react-bootstrap";
-import Image from "next/image";
-import { ErrorMessage } from "@/modules/common/components/errorMessage";
-import { SubmissionResult, useForm } from "@conform-to/react";
-import { parseWithZod } from "@conform-to/zod";
-import { startTransition } from "react";
-import { inputsSchema } from "./types";
-
-type Props = {
- slug?: string;
- authorImage?: string;
- result?: SubmissionResult;
- postCommentAction?: (formData: FormData) => void;
- isPending?: boolean;
-};
-
-export const CommentForm = ({ slug, authorImage, result, postCommentAction, isPending }: Props) => {
- const [form, fields] = useForm({
- defaultValue: {
- slug,
- },
- lastResult: result,
- onValidate({ formData }) {
- return parseWithZod(formData, { schema: inputsSchema });
- },
- // onSubmit is defined to avoid resetting form after successful submission
- // see https://github.com/edmundhung/conform/discussions/606
- onSubmit(event, { formData }) {
- event.preventDefault();
- startTransition(() => {
- postCommentAction?.(formData);
- });
- },
- shouldRevalidate: "onBlur",
- });
-
- const errors = Object.values(form.allErrors).flat();
-
- return (
- <>
-
-
-
-
-
-
- {authorImage && }
-
-
-
- >
- );
-};
diff --git a/src/app/article/[slug]/_components/commentForm/types.ts b/src/app/article/[slug]/_components/commentForm/types.ts
deleted file mode 100644
index 2ea7e30..0000000
--- a/src/app/article/[slug]/_components/commentForm/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { z } from "zod";
-
-export const inputsSchema = z.object({
- slug: z.string().max(200),
- body: z.string().max(200),
-});
-
-export type Inputs = z.infer;
diff --git a/src/app/article/[slug]/_components/commentList/commentList.tsx b/src/app/article/[slug]/_components/commentList/commentList.tsx
deleted file mode 100644
index 722822b..0000000
--- a/src/app/article/[slug]/_components/commentList/commentList.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { fetchComments } from "@/modules/features/article/fetch/fetchComments";
-import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
-import { getSession } from "@/utils/auth/session";
-import { CommentCard } from "../commentCard";
-
-type Props = {
- slug: string;
-};
-
-export const CommentList = async ({ slug }: Props) => {
- const comments = await fetchComments(slug);
- const currentUserPromise = (await getSession()) ? fetchCurrentUser() : undefined;
-
- return (
- <>
- {comments.map((comment, index) => (
-
- ))}
- >
- );
-};
diff --git a/src/app/article/[slug]/_components/commentList/index.ts b/src/app/article/[slug]/_components/commentList/index.ts
deleted file mode 100644
index 5b60efa..0000000
--- a/src/app/article/[slug]/_components/commentList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./commentList";
diff --git a/src/app/article/[slug]/page.tsx b/src/app/article/[slug]/page.tsx
deleted file mode 100644
index 311d170..0000000
--- a/src/app/article/[slug]/page.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Col, Row } from "react-bootstrap";
-import { Suspense } from "react";
-import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
-import { getSession } from "@/utils/auth/session";
-import { ArticleArea } from "./_components/articleArea";
-import { CommentForm } from "./_components/commentForm";
-import { CommentList } from "./_components/commentList";
-
-type Params = Promise<{
- slug: string;
-}>;
-
-const Page = async (props: { params: Params }) => {
- const currentUserPromise = (await getSession()) ? fetchCurrentUser() : undefined;
- const params = await props.params;
-
- return (
-
-
-
-
- ⌛Loading comments...}>
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/articles/page.tsx b/src/app/articles/page.tsx
deleted file mode 100644
index dcff1fe..0000000
--- a/src/app/articles/page.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import { getSession } from "@/utils/auth/session";
-import { ExhaustiveError } from "@/utils/errors";
-import clsx from "clsx";
-import Link from "next/link";
-import { Suspense } from "react";
-import { FeedArticleList } from "../_components/feedArticleList";
-import { GlobalArticleList } from "../_components/globalArticleList";
-import { TagArticleList } from "../_components/tagArticleList";
-import { TagList } from "../_components/tagList";
-import { SearchParams } from "../_types";
-//import { ArticlesList } from "./_components/articlesList";
-
-const ArticleList = (searchParams: SearchParams) => {
- switch (searchParams.tab) {
- case "yours":
- return ;
- case "global":
- return ;
- case "tag":
- return ;
- default:
- throw new ExhaustiveError(searchParams.tab, "all tab cases are not covered");
- }
-};
-
-const Page = async (props: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) => {
- const session = await getSession();
- const searchParams = SearchParams.parse(await props.searchParams);
-
- return (
-
-
-
-
-
-
-
- {session && (
- -
-
- Your Feed
-
-
- )}
- -
-
- Global Feed
-
-
- {searchParams.tag && (
- -
-
- #{searchParams.tag}
-
-
- )}
-
-
- ⌛Chargement...}>
-
-
-
-
- ⌛Chargement...}>
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/editor/[slug]/page.tsx b/src/app/editor/[slug]/page.tsx
deleted file mode 100644
index b8da965..0000000
--- a/src/app/editor/[slug]/page.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import { UpdateArticleEditor } from "@/modules/features/article/components/articleEditor";
-import { fetchArticle } from "@/modules/features/article/fetch/fetchArticle";
-import { Suspense } from "react";
-
-type Props = {
- params: Promise<{
- slug: string;
- }>;
-};
-
-const Page = async ({ params }: Props) => {
- const article = fetchArticle((await params).slug);
-
- return (
-
-
-
-
- ⌛ Chargement...}>
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/editor/page.tsx b/src/app/editor/page.tsx
deleted file mode 100644
index f68f9d1..0000000
--- a/src/app/editor/page.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import { CreateArticleEditor } from "@/modules/features/article/components/articleEditor";
-
-const Page = () => (
-
-);
-
-export default Page;
diff --git a/src/app/error.tsx b/src/app/error.tsx
deleted file mode 100644
index 5926276..0000000
--- a/src/app/error.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-"use client";
-
-//import { Button } from "@/modules/common/components/button";
-import { Container, Button, Col, Row } from "react-bootstrap";
-import TimeClock from "./_components/timeClock/timeClock";
-
-const Error = ({
- reset,
-}: {
- error: Error & {
- digest?: string;
- };
- reset: () => void;
-}) => {
- return (
-
-
-
-
- ⚠️ Page introuvable!
- La page que vous vouliez consulter n'est pas d'isponible pour le moment.
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default Error;
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
deleted file mode 100644
index 2bd51b9..0000000
--- a/src/app/layout.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import { Footer } from "@/modules/common/components/footer";
-import { Header } from "@/modules/features/auth/components/header";
-//import "@/styles/font.css";
-import "@/styles/styles.scss";
-import "@/styles/icomoon.scss";
-//import "ionicons/css/ionicons.min.css";
-import type { Viewport } from "next";
-import { ReactNode } from "react";
-
-export const fetchCache = "default-no-store";
-
-export const viewport: Viewport = {
- width: 'device-width',
- initialScale: 1,
- maximumScale: 1,
- userScalable: false,
- themeColor: "#00a3ff",
-}
-
-export async function generateMetadata() {
- return {
- title: "Ad Astra",
- description: "Ad Astra, fleurs et résines de CBD et autre cannabinoïdes.",
- manifest: "/favicon/manifest.json",
- icons: {
- icon: [
- { url: '/favicon/android-icon-192x192.png', sizes: '192x192', type: 'image/png' },
- { url: '/favicon/favicon-16x16.png', sizes: '16x16', type: 'image/png' },
- { url: '/favicon/favicon-32x32.png', sizes: '32x32', type: 'image/png' },
- { url: '/favicon/favicon-96x96.png', sizes: '96x96', type: 'image/png' },
- ],
- shortcut: [
- { url: '/favicon/favicon.ico', type:'image/vnd.microsoft.icon'}
- ],
- apple: [
- { url: '/favicon/apple-icon-57x57.png', sizes: '57x57', type: 'image/png' },
- { url: '/favicon/apple-icon-60x60.png', sizes: '60x60', type: 'image/png' },
- { url: '/favicon/apple-icon-72x72.png', sizes: '72x72', type: 'image/png' },
- { url: '/favicon/apple-icon-76x76.png', sizes: '76x76', type: 'image/png' },
- { url: '/favicon/apple-icon-114x114.png', sizes: '114x114', type: 'image/png' },
- { url: '/favicon/apple-icon-120x120.png', sizes: '120x120', type: 'image/png' },
- { url: '/favicon/apple-icon-144x144.png', sizes: '144x144', type: 'image/png' },
- { url: '/favicon/apple-icon-180x180.png', sizes: '180x180', type: 'image/png' },
- ],
- },
- other: {
- 'msapplication-TileColor': '#da532c',
- 'msapplication-TileImage': `${'images/tileimage.jpg'}`,
- 'msapplication-config': '/favicon/browserconfig.xml',
- }
- }
-}
-
-const RootLayout = ({
- children,
-}: Readonly<{
- children: ReactNode;
-}>) => {
- return (
-
-
-
-
- {children}
-
-
-
-
- );
-};
-
-export default RootLayout;
diff --git a/src/app/login/_components/loginForm/action.ts b/src/app/login/_components/loginForm/action.ts
deleted file mode 100644
index 7d4f2bb..0000000
--- a/src/app/login/_components/loginForm/action.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-"use server";
-
-import { createApiClient } from "@/utils/api/apiClient";
-import { createSession } from "@/utils/auth/session";
-import { parseWithZod } from "@conform-to/zod";
-import { redirect } from "next/navigation";
-import { inputsSchema } from "./types";
-
-export const signInAction = async (_prevState: unknown, formData: FormData) => {
- const submission = parseWithZod(formData, {
- schema: inputsSchema,
- });
-
- if (submission.status !== "success") {
- return submission.reply();
- }
-
- const client = createApiClient({
- path: "/users/login",
- method: "post",
- params: {
- body: {
- user: submission.value,
- },
- },
- });
-
- const response = await client.sendRequest();
-
- if (response.result === "success") {
- await createSession(response.data.user.token);
- redirect("/");
- }
-
- switch (response.statusCode) {
- case 401:
- return submission.reply({
- formErrors: ["Login failed. The email or password is incorrect."],
- });
- case 422:
- return submission.reply({
- formErrors: Object.values(response.error.errors).flat(),
- });
- default:
- throw new Error("api error");
- }
-};
diff --git a/src/app/login/_components/loginForm/container.tsx b/src/app/login/_components/loginForm/container.tsx
deleted file mode 100644
index fd06009..0000000
--- a/src/app/login/_components/loginForm/container.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-"use client";
-
-import { LoginForm as LoginFormPresentation } from "./presentation";
-import { signInAction } from "./action";
-import { useActionState } from "react";
-
-export const LoginForm = () => {
- const [state, action, isPending] = useActionState(signInAction, undefined);
-
- return ;
-};
diff --git a/src/app/login/_components/loginForm/index.ts b/src/app/login/_components/loginForm/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/login/_components/loginForm/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/login/_components/loginForm/presentation.tsx b/src/app/login/_components/loginForm/presentation.tsx
deleted file mode 100644
index 0d76b8d..0000000
--- a/src/app/login/_components/loginForm/presentation.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { Button, Form } from "react-bootstrap";
-import { ErrorMessage } from "@/modules/common/components/errorMessage";
-import { SubmissionResult, useForm } from "@conform-to/react";
-import { parseWithZod } from "@conform-to/zod";
-import { startTransition } from "react";
-import { inputsSchema } from "./types";
-
-type Props = {
- action?: (formData: FormData) => void;
- isPending?: boolean;
- result?: SubmissionResult;
-};
-
-export const LoginForm = ({ result, action, isPending }: Props) => {
- const [form, fields] = useForm({
- lastResult: result,
- onValidate({ formData }) {
- return parseWithZod(formData, { schema: inputsSchema });
- },
- // onSubmit is defined to avoid resetting form after successful submission
- // see https://github.com/edmundhung/conform/discussions/606
- onSubmit(event, { formData }) {
- event.preventDefault();
- startTransition(() => {
- action?.(formData);
- });
- },
- shouldValidate: "onBlur",
- shouldRevalidate: "onBlur",
- });
-
- return (
- <>
-
-
- Adresse email
-
-
-
-
- Mot de passe
-
-
-
-
-
-
-
- >
- );
-};
diff --git a/src/app/login/_components/loginForm/types.ts b/src/app/login/_components/loginForm/types.ts
deleted file mode 100644
index 0025f3a..0000000
--- a/src/app/login/_components/loginForm/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { z } from "zod";
-
-export const inputsSchema = z.object({
- email: z.string().email(),
- password: z.string(),
-});
-
-export type Inputs = z.infer;
diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx
deleted file mode 100644
index fc584ee..0000000
--- a/src/app/login/page.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import Link from "next/link";
-import { LoginForm } from "./_components/loginForm";
-
-const Page = () => (
-
-
-
-
- Se connecter
-
- Pas encore de compte?
-
-
-
-
-
-
-);
-export default Page;
diff --git a/src/app/logout/route.tsx b/src/app/logout/route.tsx
deleted file mode 100644
index c2e0389..0000000
--- a/src/app/logout/route.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-"use server";
-
-import { deleteSession } from "@/utils/auth/session";
-import { redirect } from "next/navigation";
-
-export async function GET() {
- await deleteSession();
- redirect("/login");
-}
\ No newline at end of file
diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx
deleted file mode 100644
index 194acd5..0000000
--- a/src/app/not-found.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-
-import { Container, Button } from "react-bootstrap";
-const NotFound = () => {
- return (
-
-
- ⚠️ Cette page n'existe pas.
-
-
- );
-};
-
-export default NotFound;
diff --git a/src/app/page.tsx b/src/app/page.tsx
deleted file mode 100644
index 3b6f841..0000000
--- a/src/app/page.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import TimeClock from "./_components/timeClock/timeClock";
-
-
-const Page = async (props: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) => {
- return (
-
-
-
-
- Ad Astra, bientôt en ligne!
- Encore un peu de patience, notre site sera disponible d'ici peu.
-
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/profile/[username]/_components/myArticleList/index.ts b/src/app/profile/[username]/_components/myArticleList/index.ts
deleted file mode 100644
index a94367b..0000000
--- a/src/app/profile/[username]/_components/myArticleList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./myArticleList";
diff --git a/src/app/profile/[username]/_components/myArticleList/myArticleList.tsx b/src/app/profile/[username]/_components/myArticleList/myArticleList.tsx
deleted file mode 100644
index ad5123d..0000000
--- a/src/app/profile/[username]/_components/myArticleList/myArticleList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Pagination, PaginationItem } from "@/modules/common/components/pagination";
-import { calcTotalPageNumber } from "@/modules/common/functions/pagination";
-import { ArticleCard } from "@/modules/features/article/components/articleCard";
-import { fetchArticlesByAuthor } from "@/modules/features/article/fetch/fetchArticleList";
-
-const Pages = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => (
-
- {[...Array(totalPages)].map((_, index) => {
- const page = index + 1;
- const href = `/?tab=global&page=${page}`;
- return (
-
- {page}
-
- );
- })}
-
-);
-
-export const MyArticleList = async ({ username, currentPage }: { currentPage: number; username: string }) => {
- const { articles, articlesCount } = await fetchArticlesByAuthor(username, currentPage);
- const totalPages = calcTotalPageNumber(articlesCount, 10);
-
- return articles.length < 1 ? (
- No articles found.
- ) : (
- <>
- {articles.map((article, index) => (
-
- ))}
- {1 < totalPages && }
- >
- );
-};
diff --git a/src/app/profile/[username]/_functions/index.ts b/src/app/profile/[username]/_functions/index.ts
deleted file mode 100644
index 6d1fadf..0000000
--- a/src/app/profile/[username]/_functions/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { User } from "@/utils/types/models";
-
-export const showEditProfileSettingsButton = (profileUsername: string, currentUser: User | undefined) => {
- if (currentUser == null) {
- return false;
- }
-
- return profileUsername === currentUser.username;
-};
-
-export const showFollowButton = (profileUsername: string, currentUser: User | undefined) => {
- return profileUsername !== currentUser?.username;
-};
diff --git a/src/app/profile/[username]/_types/index.ts b/src/app/profile/[username]/_types/index.ts
deleted file mode 100644
index dc674c5..0000000
--- a/src/app/profile/[username]/_types/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { z } from "zod";
-
-export const searchParamsSchema = z.object({
- page: z.coerce.number().min(1).catch(1),
-});
-
-export type SearchParams = z.infer;
diff --git a/src/app/profile/[username]/favorites/_components/favoriteArticleList/favoriteArticleList.tsx b/src/app/profile/[username]/favorites/_components/favoriteArticleList/favoriteArticleList.tsx
deleted file mode 100644
index 24c120e..0000000
--- a/src/app/profile/[username]/favorites/_components/favoriteArticleList/favoriteArticleList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Pagination, PaginationItem } from "@/modules/common/components/pagination";
-import { calcTotalPageNumber } from "@/modules/common/functions/pagination";
-import { ArticleCard } from "@/modules/features/article/components/articleCard";
-import { fetchFavoriteArticles } from "@/modules/features/article/fetch/fetchArticleList";
-
-const Pages = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => (
-
- {[...Array(totalPages)].map((_, index) => {
- const page = index + 1;
- const href = `/?tab=global&page=${page}`;
- return (
-
- {page}
-
- );
- })}
-
-);
-
-export const FavoriteArticleList = async ({ username, currentPage }: { currentPage: number; username: string }) => {
- const { articles, articlesCount } = await fetchFavoriteArticles(username, currentPage);
- const totalPages = calcTotalPageNumber(articlesCount, 10);
-
- return articles.length < 1 ? (
- No articles found.
- ) : (
- <>
- {articles.map((article, index) => (
-
- ))}
- {1 < totalPages && }
- >
- );
-};
diff --git a/src/app/profile/[username]/favorites/_components/favoriteArticleList/index.ts b/src/app/profile/[username]/favorites/_components/favoriteArticleList/index.ts
deleted file mode 100644
index 6b6b503..0000000
--- a/src/app/profile/[username]/favorites/_components/favoriteArticleList/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./favoriteArticleList";
diff --git a/src/app/profile/[username]/favorites/_types/types.ts b/src/app/profile/[username]/favorites/_types/types.ts
deleted file mode 100644
index 95e2118..0000000
--- a/src/app/profile/[username]/favorites/_types/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { z } from "zod";
-
-export const SearchParams = z.object({
- page: z.coerce.number().min(1).catch(1),
-});
-
-export type SearchParams = z.infer;
diff --git a/src/app/profile/[username]/favorites/page.tsx b/src/app/profile/[username]/favorites/page.tsx
deleted file mode 100644
index 2b9b442..0000000
--- a/src/app/profile/[username]/favorites/page.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { decodePathParams } from "@/modules/common/functions/url";
-import Link from "next/link";
-import { Suspense } from "react";
-import { FavoriteArticleList } from "./_components/favoriteArticleList";
-import { SearchParams } from "./_types/types";
-
-const FavoritesPage = async (props: {
- params: Promise<{
- username: string;
- }>;
- searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
-}) => {
- const searchParams = SearchParams.parse(await props.searchParams);
- const pathParams = decodePathParams(await props.params);
-
- return (
- <>
-
-
- -
-
- My Articles
-
-
- -
-
- Favorited Articles
-
-
-
-
- ⌛Loading...}>
-
-
- >
- );
-};
-
-export default FavoritesPage;
diff --git a/src/app/profile/[username]/layout.tsx b/src/app/profile/[username]/layout.tsx
deleted file mode 100644
index c4a337b..0000000
--- a/src/app/profile/[username]/layout.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { ReactNode } from "react";
-import Image from "next/image";
-import { Button } from "@/modules/common/components/button";
-import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
-import { FollowButton } from "@/modules/features/profile/components/followButton";
-import { fetchProfile } from "@/modules/features/profile/fetch/fetchProfile";
-import { getSession } from "@/utils/auth/session";
-import { showEditProfileSettingsButton, showFollowButton } from "./_functions";
-
-type Props = {
- children: ReactNode;
- params: Promise<{
- username: string;
- }>;
-};
-
-const Layout = async ({ children, params }: Props) => {
- const profile = await fetchProfile((await params).username);
- const currentUser = (await getSession()) ? await fetchCurrentUser() : undefined;
-
- return (
-
-
-
-
-
- {profile.image &&
}
-
{profile.username}
- {profile.bio &&
{profile.bio}
}
- {showFollowButton(profile.username, currentUser) &&
}
- {showEditProfileSettingsButton(profile.username, currentUser) && (
-
- )}
-
-
-
-
-
-
-
- );
-};
-
-export default Layout;
diff --git a/src/app/profile/[username]/page.tsx b/src/app/profile/[username]/page.tsx
deleted file mode 100644
index a6fc57e..0000000
--- a/src/app/profile/[username]/page.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { decodePathParams } from "@/modules/common/functions/url";
-import Link from "next/link";
-import { Suspense } from "react";
-import { MyArticleList } from "./_components/myArticleList";
-import { searchParamsSchema } from "./_types";
-
-const ProfilePage = async (props: {
- params: Promise<{
- username: string;
- }>;
- searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
-}) => {
- const pathParams = decodePathParams(await props.params);
- const searchParams = searchParamsSchema.parse(await props.searchParams);
-
- return (
- <>
-
-
- -
-
- My Articles
-
-
- -
-
- Favorited Articles
-
-
-
-
- ⌛Loading...}>
-
-
- >
- );
-};
-
-export default ProfilePage;
diff --git a/src/app/register/_components/registrationForm/action.ts b/src/app/register/_components/registrationForm/action.ts
deleted file mode 100644
index 98b083d..0000000
--- a/src/app/register/_components/registrationForm/action.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-"use server";
-
-import { createApiClient } from "@/utils/api/apiClient";
-import { createSession } from "@/utils/auth/session";
-import { parseWithZod } from "@conform-to/zod";
-import { redirect } from "next/navigation";
-import { inputsSchema } from "./types";
-
-export const signUpAction = async (_prevState: unknown, formData: FormData) => {
- const submission = parseWithZod(formData, {
- schema: inputsSchema,
- });
-
- if (submission.status !== "success") {
- return submission.reply();
- }
-
- const client = createApiClient({
- path: "/users",
- method: "post",
- params: {
- body: {
- user: submission.value,
- },
- },
- });
-
- const response = await client.sendRequest();
-
- if (response.result === "success") {
- createSession(response.data.user.token);
- redirect("/");
- }
-
- switch (response.statusCode) {
- case 422:
- return submission.reply({
- formErrors: Object.values(response.error.errors).flat(),
- });
- default:
- throw new Error("api error");
- }
-};
diff --git a/src/app/register/_components/registrationForm/container.tsx b/src/app/register/_components/registrationForm/container.tsx
deleted file mode 100644
index ddb38a6..0000000
--- a/src/app/register/_components/registrationForm/container.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-"use client";
-
-import { useActionState } from "react";
-import { signUpAction } from "./action";
-import { RegistrationForm as RegistrationFormPresentation } from "./presentation";
-
-export const RegistrationForm = () => {
- const [state, dispatch, isPending] = useActionState(signUpAction, undefined);
-
- return ;
-};
diff --git a/src/app/register/_components/registrationForm/index.ts b/src/app/register/_components/registrationForm/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/register/_components/registrationForm/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/register/_components/registrationForm/presentation.tsx b/src/app/register/_components/registrationForm/presentation.tsx
deleted file mode 100644
index 57792f3..0000000
--- a/src/app/register/_components/registrationForm/presentation.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import { Button, Form } from "react-bootstrap";
-//import { Button } from "@/modules/common/components/button";
-import { ErrorMessage } from "@/modules/common/components/errorMessage";
-import { SubmissionResult, useForm } from "@conform-to/react";
-import { parseWithZod } from "@conform-to/zod";
-import { startTransition } from "react";
-import { inputsSchema } from "./types";
-
-type Props = {
- action?: (formData: FormData) => void;
- isPending?: boolean;
- result?: SubmissionResult;
-};
-
-export const RegistrationForm = ({ result, action, isPending }: Props) => {
- const [form, fields] = useForm({
- lastResult: result,
- onValidate({ formData }) {
- return parseWithZod(formData, { schema: inputsSchema });
- },
- // onSubmit is defined to avoid resetting form after successful submission
- // see https://github.com/edmundhung/conform/discussions/606
- onSubmit(event, { formData }) {
- event.preventDefault();
- startTransition(() => {
- action?.(formData);
- });
- },
- shouldValidate: "onBlur",
- shouldRevalidate: "onBlur",
- });
-
- return (
- <>
-
-
- Prénom
-
-
-
-
- Nom
-
-
-
-
- Pseudo
-
-
-
-
- Adresse email
-
-
-
-
- Mot de passe
-
-
-
-
-
-
-
- >
- );
-};
diff --git a/src/app/register/_components/registrationForm/types.ts b/src/app/register/_components/registrationForm/types.ts
deleted file mode 100644
index 86745f5..0000000
--- a/src/app/register/_components/registrationForm/types.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { z } from "zod";
-
-export const inputsSchema = z.object({
- username: z.string().max(200),
- firstname: z.string().max(200),
- lastname: z.string().max(200),
- email: z.string().email(),
- password: z.string().min(4).max(200),
-});
-
-export type Inputs = z.infer;
diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx
deleted file mode 100644
index b94fc3e..0000000
--- a/src/app/register/page.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import Link from "next/link";
-import { RegistrationForm } from "./_components/registrationForm";
-
-const Page = () => (
-
-
-
-
- Créer un compte
-
- Déjà un compte?
-
-
-
-
-
-
-);
-
-export default Page;
diff --git a/src/app/settings/_components/action.ts b/src/app/settings/_components/action.ts
deleted file mode 100644
index 75ae266..0000000
--- a/src/app/settings/_components/action.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-"use server";
-
-import { createApiClient } from "@/utils/api/apiClient";
-import { redirect } from "next/navigation";
-import { inputsSchema } from "./types";
-import { createSession } from "@/utils/auth/session";
-import { parseWithZod } from "@conform-to/zod";
-import { SubmissionResult } from "@conform-to/react";
-
-export const updateSettingsAction = async (_prevState: SubmissionResult | undefined, formData: FormData) => {
- const submission = parseWithZod(formData, {
- schema: inputsSchema,
- });
-
- if (submission.status !== "success") {
- return submission.reply();
- }
-
- const client = createApiClient({
- path: "/user",
- method: "put",
- params: {
- body: {
- user: submission.value,
- },
- },
- });
-
- const response = await client.sendRequest();
-
- if (response.result === "success") {
- const user = response.data.user;
- await createSession(user.token);
- redirect(`/profile/${user.username}`);
- }
-
- switch (response.statusCode) {
- case 422:
- return submission.reply({
- formErrors: Object.values(response.error.errors).flat(),
- });
- default:
- throw new Error("api error");
- }
-};
diff --git a/src/app/settings/_components/container.tsx b/src/app/settings/_components/container.tsx
deleted file mode 100644
index 217d00c..0000000
--- a/src/app/settings/_components/container.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-"use client";
-
-import { use, useActionState } from "react";
-import { SettingsForm as SettingsFormPresentation } from "./presentation";
-import { updateSettingsAction } from "./action";
-import { User } from "@/utils/types/models";
-
-export const SettingsForm = ({ user }: { user: Promise }) => {
- const [state, action, isPending] = useActionState(updateSettingsAction, undefined);
-
- return ;
-};
diff --git a/src/app/settings/_components/index.ts b/src/app/settings/_components/index.ts
deleted file mode 100644
index c5b5e8f..0000000
--- a/src/app/settings/_components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./container";
diff --git a/src/app/settings/_components/presentation.tsx b/src/app/settings/_components/presentation.tsx
deleted file mode 100644
index a12276f..0000000
--- a/src/app/settings/_components/presentation.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-import { Button, Form } from "react-bootstrap";
-import { ErrorMessage } from "@/modules/common/components/errorMessage";
-import { User } from "@/utils/types/models";
-import { SubmissionResult, useForm } from "@conform-to/react";
-import { parseWithZod } from "@conform-to/zod";
-import { startTransition } from "react";
-import { inputsSchema } from "./types";
-
-type Props = {
- user?: User;
- action?: (formData: FormData) => void;
- isPending?: boolean;
- result?: SubmissionResult;
-};
-
-export const SettingsForm = ({ user, action, isPending, result }: Props) => {
- const [form, fields] = useForm({
- lastResult: result,
- onValidate({ formData }) {
- return parseWithZod(formData, { schema: inputsSchema });
- },
- // onSubmit is defined to avoid resetting form after successful submission
- // see https://github.com/edmundhung/conform/discussions/606
- onSubmit(event, { formData }) {
- event.preventDefault();
- startTransition(() => {
- action?.(formData);
- });
- },
- defaultValue: { ...user },
- shouldValidate: "onBlur",
- shouldRevalidate: "onBlur",
- });
-
- return (
- <>
-
-
- Pseudo
-
-
-
-
- Adresse email
-
-
-
-
- Prénom
-
-
-
-
- Nom
-
-
-
-
- Mot de passe
-
-
-
-
- Bio
-
-
-
-
- Image
-
-
-
-
-
-
-
- >
- );
-};
diff --git a/src/app/settings/_components/types.ts b/src/app/settings/_components/types.ts
deleted file mode 100644
index 741ae39..0000000
--- a/src/app/settings/_components/types.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { z } from "zod";
-
-export const inputsSchema = z.object({
- username: z.string().max(200),
- email: z.string().max(200).email(),
- firstname: z.string().max(200),
- lastname: z.string().max(200),
- bio: z.string().max(200).optional(),
- image: z.string().max(200).optional(),
- password: z.string().min(4).max(200).optional(),
-});
-
-export type Inputs = z.infer;
diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx
deleted file mode 100644
index e4d7b6a..0000000
--- a/src/app/settings/page.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Container, Col, Row } from "react-bootstrap";
-import { LogoutButton } from "@/modules/features/auth/components/logoutButton";
-import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
-import { Suspense } from "react";
-import { SettingsForm } from "./_components";
-
-const Page = async () => {
- const user = fetchCurrentUser();
-
- return (
-
-
-
-
- Vos paramètres
- ⌛ Chargement...}>
-
-
-
-
-
-
-
-
- );
-};
-
-export default Page;