From 0601fb24a7ab3d2b314359dbba774e1624208e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20B=C3=B6ckmann?= Date: Thu, 2 May 2024 13:09:24 +0200 Subject: [PATCH] feat: design implemented; no functionality; waiting for backend --- next.config.js | 2 +- src/app/dashboard/company/[id]/page.tsx | 134 +++++++++++++++++++++++- src/app/dashboard/layout.tsx | 1 + 3 files changed, 135 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index f765359..d4a2c84 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { images: { - domains: ["assets-global.website-files.com"] + domains: ["assets-global.website-files.com", "files.readme.io", "github.githubassets.com"] }, async rewrites() { return [ diff --git a/src/app/dashboard/company/[id]/page.tsx b/src/app/dashboard/company/[id]/page.tsx index 4cac415..a8561b9 100644 --- a/src/app/dashboard/company/[id]/page.tsx +++ b/src/app/dashboard/company/[id]/page.tsx @@ -1,3 +1,135 @@ +"use client"; +import { Input } from "@/components/ui/input"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger +} from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { extractNameInitials } from "@/lib/utils"; +import React, { useEffect, useState } from "react"; +import type { User } from "@/types"; +import { useRouter } from "next/navigation"; +import { deleteToken, getAccessToken, getUser } from "@/lib/actions"; +import Image from "next/image"; + export default function Page({ params }: { params: { id: string } }) { - return
Company Index: {params.id}
; + const [user, setUser] = useState(); + const [loading, setLoading] = useState(true); + + const router = useRouter(); + + useEffect(() => { + const fetchUser = async () => { + setLoading(true); + try { + const accessToken = await getAccessToken(); + setUser(await getUser(accessToken)); + setLoading(false); + } catch (error) { + console.error("Failed to fetch user", error); + setLoading(false); + } + }; + fetchUser().catch(console.error); + }, []); + + const logout = async () => { + try { + await deleteToken(); + window.location.reload(); + } catch (error) { + console.error("Logout failed", error); + throw error; + } + }; + if (loading) + return ( +
+
+ {""} +
+ ); + else + return ( +
+
+

GitHub (ID: {params.id})

+
+ + + + + + + +
+

{user?.name}

+

{user?.email}

+
+
+ + { + router.push("/dashboard/settings"); + }}> + Settings + + + + Log out + +
+
+
+
+ + {""} + +
+
+
+ {""} +
+

GitHub

+

+ GitHub is a code hosting platform for version control and collaboration. It lets you and others work + together on projects from anywhere. +

+
+
+ +
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat + nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit + anim id est laborum. +

+
+
+ ); } diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx index 45621a6..5624e96 100644 --- a/src/app/dashboard/layout.tsx +++ b/src/app/dashboard/layout.tsx @@ -24,6 +24,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod useEffect(() => { const fetchUser = async () => { try { + console.log("fetching user"); const accessToken = await getAccessToken(); setUser(await getUser(accessToken)); } catch (error) {