From 202b7ed134b4252ce252b66a3cc9789945e8c498 Mon Sep 17 00:00:00 2001 From: jonassimoen Date: Thu, 30 Nov 2023 18:02:02 +0100 Subject: [PATCH] feat(FT-25): pages * feat(pages): add rules page * feat(pages): add page management --- src/locales/nl.json | 17 +- src/pages/Admin.tsx | 16 +- src/pages/PageManagement/PageManagement.tsx | 200 ++++++++++ .../PageManagement/PlayerManagementStyle.ts | 10 + .../PlayerManagement/PlayerManagement.tsx | 356 +++++++++--------- src/pages/Rules/Rules.tsx | 37 +- src/reducers/index.tsx | 3 + src/routes.tsx | 8 +- src/services/pagesApi.ts | 57 +++ src/types/index.tsx | 22 +- 10 files changed, 528 insertions(+), 198 deletions(-) create mode 100644 src/pages/PageManagement/PageManagement.tsx create mode 100644 src/pages/PageManagement/PlayerManagementStyle.ts create mode 100644 src/services/pagesApi.ts diff --git a/src/locales/nl.json b/src/locales/nl.json index f5e6a9a..6380d11 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -85,6 +85,13 @@ "portraitUrl": { "required": "Portret afbeelding vereist" } + }, + "page": { + "translation": { + "langCode": "Taalcode", + "body": "Tekst" + }, + "slug": "Afkorting" } }, "form": { @@ -121,6 +128,13 @@ }, "week": { "add": "Voeg matchweek toe" + }, + "page": { + "add": "Voeg pagina toe", + "translation": { + "add": "Voeg vertaling toe" + }, + "remove": "Verwijder" } }, "modal": { @@ -178,5 +192,6 @@ "weekWinnerPoints": "winnaar", "statsBlockTitle": "Statistieken", "overviewBlockTitle": "Overzicht" - } + }, + "pageTitle": "Pagina" } diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index d2b9a61..65db92a 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -1,9 +1,8 @@ -import { useAuth } from "@/lib/stores/AuthContext"; import { useAppSelector } from "@/reducers"; -import { CalendarOutlined, HomeOutlined, SkinOutlined, StarOutlined, UserOutlined } from "@ant-design/icons"; +import { CalendarOutlined, CopyOutlined, HomeOutlined, SkinOutlined, StarOutlined, UserOutlined } from "@ant-design/icons"; import { Menu, MenuProps } from "antd"; import Title from "antd/es/typography/Title"; -import { useContext, useState } from "react"; +import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link, Navigate, Outlet, useLocation } from "react-router-dom"; import secureLocalStorage from "react-secure-storage"; @@ -14,6 +13,11 @@ const items: MenuProps["items"] = [ key: "admin", icon: , }, + { + label: (Pages), + key: "pages", + icon: , + }, { label: (Players), key: "players", @@ -44,9 +48,9 @@ const items: MenuProps["items"] = [ export const Admin = (props: { redirectPath: string }) => { const location = useLocation(); - + const user = useAppSelector((state) => state.userState.user); - + const { t } = useTranslation(); const [current, setCurrent] = useState(location.pathname.split("/").pop() || "admin"); const onClick: MenuProps["onClick"] = (e) => { @@ -64,7 +68,7 @@ export const Admin = (props: { redirectPath: string }) => { return ( <> {t("admin.welcome", { name: user?.firstName })} - + ); diff --git a/src/pages/PageManagement/PageManagement.tsx b/src/pages/PageManagement/PageManagement.tsx new file mode 100644 index 0000000..db6b09f --- /dev/null +++ b/src/pages/PageManagement/PageManagement.tsx @@ -0,0 +1,200 @@ +import { CreateModal } from "@/components/CreateModal"; +import { EditModal } from "@/components/EditModal"; +import { Button } from "@/components/UI/Button/Button"; +import { FormItem } from "@/components/UI/Form/Form"; +import { Col, Row } from "@/components/UI/Grid/Grid"; +import { InputNumber } from "@/components/UI/InputNumber/InputNumber"; +import { useCreatePageMutation, useDeletePageMutation, useGetPagesQuery, useUpdatePageMutation } from "@/services/pagesApi"; +import { theme } from "@/styles/theme"; +import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons"; +import { Divider, Form, Input, Table } from "antd"; +import TextArea from "antd/lib/input/TextArea"; +import Title from "antd/lib/typography/Title"; +import React from "react"; +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { TranslationStyle } from "./PlayerManagementStyle"; + +declare type PageManagementState = { + openEditModal: boolean + openCreateModal: boolean + editObject?: Page +} + +export const PageManagement = () => { + const { data: pages, isLoading: pagesLoading, isError: pagesError, isSuccess: pagesSucces } = useGetPagesQuery(); + const [updatePage] = useUpdatePageMutation(); + const [createPage] = useCreatePageMutation(); + const [deletePage] = useDeletePageMutation(); + + const [state, setState] = useState({ + openEditModal: false, + openCreateModal: false, + }); + + const { t } = useTranslation(); + + const PageForm = + <> + + + + + + + + + {(fields, { add, remove }) => ( + <> + { + fields.map((field) => ( + + + + + + + + + + + +