diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx index c3ffd4f..e4e34ec 100644 --- a/src/app/admin/layout.tsx +++ b/src/app/admin/layout.tsx @@ -26,7 +26,7 @@ export default function Dashboard({ children }: { children: ReactNode }) {
-
+
{children}
diff --git a/src/app/admin/organizations/[id]/page.tsx b/src/app/admin/organizations/[id]/page.tsx new file mode 100644 index 0000000..59de245 --- /dev/null +++ b/src/app/admin/organizations/[id]/page.tsx @@ -0,0 +1,164 @@ +"use client" +import { icons } from "#/assets/icons" +import Image from "next/image" +import axios from "axios"; +import { useSession } from "next-auth/react"; +import { useQuery } from "@tanstack/react-query"; +import { Company, CompanyById, Owner } from "#/types"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; + + +export default function Profile() { + + const pathname = usePathname(); + + const segments = pathname.split("/"); + const uid = segments[segments.length - 1]; + + + const { data: session, status } = useSession(); + + const { data: companyInfos, isLoading } = useQuery({ + enabled: status === 'authenticated', + queryKey: ["companyStats", session?.user.access_token], + queryFn: async () => { + try { + const response = await axios.get( + `https://private-docs-api.intside.co/companies/${uid}`, { + headers: { + 'Authorization': `Bearer ${session?.user.access_token}` + }, + params: { + details: true + } + } + ); + + if (response.data) { + return response.data as CompanyById; + } + } catch (error: any) { + console.error(error); + } + } + }); + + /* + const adminId = companyInfos?.owner; + console.log('will run the admin request'); + + const { data: adminInfos } = useQuery({ + enabled: !!adminId && status === 'authenticated', // Only run when adminId is available + queryKey: ["admin", adminId], // Ensure adminId is used in the query key + queryFn: async () => { + console.log('running the admin request'); + //console.log('url :', `https://private-docs-api.intside.co/users/${adminId}`); + + try { + const response = await axios.get( + `https://private-docs-api.intside.co/users/${adminId}`, { // Use adminId instead of companyInfos + headers: { + 'Authorization': `Bearer ${session?.user.access_token}` + } + } + ); + + if (response.data) { + return response.data as Owner; + } + } catch (error) { + console.error(error); + } + } + + }); +*/ + + return ( + <> + {/* {companyInfos[0]?.id} */} +
+
+
+
+

{companyInfos?.name || "Pentatonic"}

+ + Modifier + +
+
+

Détails de l'admin

+
+
+
+ E-mail +
+
+

Adresse e-mail

+

{companyInfos?.owner?.email || "email"}

+
+
+
+
+ E-mail +
+
+
+

Prénom

+

{companyInfos?.owner?.first_name || "nom"}

+
+
+

Nom

+

{companyInfos?.owner?.last_name || "nom"}

+
+
+
+
+
+
+
+
+
+
+ Documents +
+
+

Documents

+

{companyInfos?.total_documents || "0"}

+
+
+
+
+ Documents +
+
+

Utilisateurs

+

{companyInfos?.total_users || "0"}

+
+
+
+
+ Fichiers +
+
+

Taille des fichiers

+

{companyInfos?.total_documents_sizes + " "}GB

+
+
+
+
+ Horlorge +
+
+

Dernière utilisation

+

{companyInfos?.last_use || "-"}

+
+
+
+
+
+
+ + ) +} \ No newline at end of file diff --git a/src/app/admin/organizations/[id]/update/page.tsx b/src/app/admin/organizations/[id]/update/page.tsx new file mode 100644 index 0000000..d7e2e60 --- /dev/null +++ b/src/app/admin/organizations/[id]/update/page.tsx @@ -0,0 +1,147 @@ +"use client" +import { icons } from "#/assets/icons" +import Image from "next/image" +import axios from "axios"; +import { useSession } from "next-auth/react"; +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { Company, CompanyById } from "#/types"; +import FloatingLabelInput from "#/components/floatingLabelInput"; +import { usePathname } from "next/navigation"; +import Link from "next/link"; +import Form from "#/components/form/form"; +import { adminSchema } from "#/schema/loginSchema"; + +export default function Update() { + + const pathname = usePathname(); + + const segments = pathname.split("/"); + const uid = segments[segments.length - 2]; + const queryClient = useQueryClient() + + + const { data: session, status } = useSession(); + + const { data: companyInfos, refetch, isLoading } = useQuery({ + enabled: status === 'authenticated', + queryKey: ["companyStats", session?.user.access_token], + queryFn: async () => { + try { + const response = await axios.get( + `https://private-docs-api.intside.co/users/${uid}`, { + headers: { + 'Authorization': `Bearer ${session?.user.access_token}` + }, + params: { + details: true + } + } + ); + + if (response.data) { + return response.data as CompanyById; + } + } catch (error: any) { + console.error(error); + } + } + }); + + const { mutate, isPending } = useMutation({ + mutationFn: async (id: string) => { + try { + const response = await axios.delete( + `https://private-docs-api.intside.co/companies/${id}/`, { + headers: { + 'Authorization': `Bearer ${session?.user.access_token}` + } + } + ) + + if (response.status === 200 || response.status === 201) { + console.log('Suppresion réussie !') + } + } catch (error) { + console.error(error) + } + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["companies"] }) + + refetch() + } + }) + + + return ( + <> + {/* { company.map() } */} + + + {/*
Connexion} + /> */} + + +
+
+
+
+

{companyInfos?.name || "Pentatonic"}

+ + Annuler + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + + +
+
+
+
+ + ) +} \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css index 87fa3c8..018286c 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -14,6 +14,8 @@ --secondary: #9FA8BC; --danger: #F33F19; --cinder: #E7E5E4; + --bluegray: #E9F0FF; + --gray: #E7EBF3; } [ data-theme="dark"] { @@ -98,6 +100,72 @@ body { transition: width 0.2s, height 0.2s; } +.cta{ + padding: 10px 24px; + color: white; + background-color: var(--primary); + font-size: 14px; + font-weight: 600; + border: 1px solid var(--primary); + border-radius: 100px; + cursor: pointer; +} + +.cta.cancel{ + color: var(--secondary); + border: 1px solid var(--gray); + background-color: var(--gray); +} + +.cta.info{ + color: var(--primary); + background-color: var(--background); +} + +.cta.danger{ + border: 1px solid var(--danger); + background-color: var(--danger); +} + + +.bg-bluegray{ + background-color: var(--bluegray); +} +.bg-gray{ + background-color: var(--gray); +} +hr{ + color: var(--gray); +} + + + +/* Scroll Bar */ + +::-webkit-scrollbar { + width: 4px; + padding: 0; + margin: 0; +} + +::-webkit-scrollbar-track { + background: var(--background); +} + +::-webkit-scrollbar-thumb { + background: var(--primary); + border-radius: 6px; +} + +::-webkit-scrollbar-track:hover { + background: var(--background); +} + +::-webkit-scrollbar-thumb:hover { + background: var(--primary); +} + + @media (max-width: 768px) { .responsive-icon { width: 20px; diff --git a/src/assets/css/admin.css b/src/assets/css/admin.css index 2b04377..e08f76e 100644 --- a/src/assets/css/admin.css +++ b/src/assets/css/admin.css @@ -1,53 +1,108 @@ -.sidebar{ +/* Sidebar */ + +.sidebar { border-right: 1px solid var(--cinder); + position: fixed; } -.nav-item .nav-home{ +.nav-item .nav-home { margin-bottom: -10px; } -.nav-item{ +.nav-item { width: 100%; height: max-content; } -.nav-item.active{ +.nav-item.active { border-right: 2px solid var(--primary); } -.nav-item svg{ - color: var(--primary)!important; - background-color: var(--primary)!important; - fill: var(--primary)!important; - stroke: var(--primary)!important +.nav-item svg { + color: var(--primary) !important; + background-color: var(--primary) !important; + fill: var(--primary) !important; + stroke: var(--primary) !important } -.nav-home{ +.nav-home { margin-top: -11px; margin-bottom: -11px; } -.icon-border{ +/* Border */ +.icon-border { border: 1px solid var(--cinder); padding: 8px; border-radius: 12px; cursor: pointer; } -.dropdown-menu{ +.dropdown-menu { width: max-content; background-color: var(--background); border-radius: 8px; box-shadow: 0 0 24px #0000001A; } -.dropdown-item{ - -} -.dropdown-item a{ + +.dropdown-item a { width: max-content; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; gap: 10px; +} + +/* Main */ + +.p-container { + height: 100vh; + border: 1px solid var(--gray); + overflow: hidden; +} + +.icon-rounded { + width: max-content; + height: max-content; + padding: 8px; + display: flex; + justify-content: center; + align-items: center; + background-color: var(--bluegray); + border-radius: 100px; +} + +.labels-container { + min-width: 100%; + display: flex; + flex-wrap: wrap; + gap: 24px; +} + +.labels-container .label-container { + width: 40%; +} + +.labels-container .floating-label div.relative { + width: 100%; +} + +.admin-infos { + gap: 12px; +} +.admin-card { + width: 284px; +} + + + +@media (max-width: 1024px) { + .admin-infos { + /* justify-content: space-between; */ + /* gap: 30px; */ + } + .admin-card { + /* max-width: 100%; */ + } } \ No newline at end of file diff --git a/src/assets/css/ruben-ui.css b/src/assets/css/ruben-ui.css index 6a04580..2085fbb 100644 --- a/src/assets/css/ruben-ui.css +++ b/src/assets/css/ruben-ui.css @@ -119,6 +119,9 @@ .r-gap-70{ gap: 70px; } +.r-r-gap-12{ + row-gap: 12px; +} /* Small (SM) */ @media (min-width: 640px) { /* Styles for small devices and up */ diff --git a/src/assets/icons/index.ts b/src/assets/icons/index.ts index 9120b8b..6d9b354 100644 --- a/src/assets/icons/index.ts +++ b/src/assets/icons/index.ts @@ -40,6 +40,8 @@ import arrowUp from "./Vector.svg" import sunIcon from "./sun.svg" import moonIcon from "./moon.svg" import trash from "./trash.svg" +import mailIcon from "./sms.svg" +import personalCard from "./personalcard.svg" export const icons = { @@ -83,8 +85,10 @@ export const icons = { starIcon, arrowUp, sunIcon, - moonIcon , - trash + moonIcon, + trash, + mailIcon, + personalCard } diff --git a/src/assets/icons/personalcard.svg b/src/assets/icons/personalcard.svg new file mode 100644 index 0000000..c35fe25 --- /dev/null +++ b/src/assets/icons/personalcard.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/assets/icons/sms.svg b/src/assets/icons/sms.svg new file mode 100644 index 0000000..b961331 --- /dev/null +++ b/src/assets/icons/sms.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/admin/adminHeader.tsx b/src/components/admin/adminHeader.tsx index 5ec7ba0..8ed7042 100644 --- a/src/components/admin/adminHeader.tsx +++ b/src/components/admin/adminHeader.tsx @@ -14,7 +14,7 @@ export default function AdminHeader() { return ( <>