From 8c3383fa82d22a79fa1f5d2460bed7e6360babea Mon Sep 17 00:00:00 2001 From: Kayra Date: Thu, 1 Aug 2024 21:05:38 +0300 Subject: [PATCH] feat: users table (#48) Co-authored-by: Guillaume Belanger --- ui/src/app/aside.tsx | 93 ++------- ui/src/app/certificate_requests/asideForm.tsx | 80 ++++++++ ui/src/app/certificate_requests/row.tsx | 8 +- ui/src/app/change_password/page.tsx | 100 ---------- ui/src/app/login.tsx | 9 +- ui/src/app/nav.test.tsx | 6 + ui/src/app/nav.tsx | 57 ++++-- ui/src/app/queries.ts | 69 ++++++- ui/src/app/types.ts | 5 + ui/src/app/users/asideForm.tsx | 181 ++++++++++++++++++ ui/src/app/users/components.tsx | 133 +++++++++++++ ui/src/app/users/page.tsx | 64 +++++++ ui/src/app/users/row.tsx | 75 ++++++++ ui/src/app/users/table.tsx | 43 +++++ ui/src/app/utils.ts | 1 - 15 files changed, 716 insertions(+), 208 deletions(-) create mode 100644 ui/src/app/certificate_requests/asideForm.tsx delete mode 100644 ui/src/app/change_password/page.tsx create mode 100644 ui/src/app/users/asideForm.tsx create mode 100644 ui/src/app/users/components.tsx create mode 100644 ui/src/app/users/page.tsx create mode 100644 ui/src/app/users/row.tsx create mode 100644 ui/src/app/users/table.tsx diff --git a/ui/src/app/aside.tsx b/ui/src/app/aside.tsx index 161a109..59f95a6 100644 --- a/ui/src/app/aside.tsx +++ b/ui/src/app/aside.tsx @@ -1,85 +1,28 @@ -import { SetStateAction, Dispatch, useState, createContext, ChangeEvent } from "react" -import { useMutation, useQueryClient } from "react-query"; -import { postCSR } from "./queries"; -import { extractCSR } from "./utils"; -import { useCookies } from "react-cookie"; +import { SetStateAction, Dispatch, createContext, useContext, ComponentType } from "react" +import { useAuth } from "./auth/authContext" type AsideContextType = { isOpen: boolean, setIsOpen: Dispatch> -} -export const AsideContext = createContext({ isOpen: false, setIsOpen: () => { } }); -export function Aside({ isOpen, setIsOpen }: { isOpen: boolean, setIsOpen: Dispatch> }) { - const [cookies, setCookie, removeCookie] = useCookies(['user_token']); - const queryClient = useQueryClient() - const mutation = useMutation(postCSR, { - onSuccess: () => { - queryClient.invalidateQueries('csrs') - }, - }) - const [CSRPEMString, setCSRPEMString] = useState("") - const handleTextChange = (event: ChangeEvent) => { - setCSRPEMString(event.target.value); - } - const handleFileChange = (event: ChangeEvent) => { - const file = event.target.files?.[0] - if (file) { - const reader = new FileReader(); - reader.onload = (e: ProgressEvent) => { - if (e.target) { - if (e.target.result) { - setCSRPEMString(e.target.result.toString()); - } - } - }; - reader.readAsText(file); - } - }; - return ( -