diff --git a/src/components/layouts/HomeLayout.tsx b/src/components/layouts/HomeLayout.tsx index 2957af2..9527971 100644 --- a/src/components/layouts/HomeLayout.tsx +++ b/src/components/layouts/HomeLayout.tsx @@ -2,7 +2,8 @@ import type { Children } from "@utils/types/props"; import { useState, useEffect } from "react"; import { cva, cx } from "class-variance-authority"; import { Button } from "@components/Button"; -import { signIn } from "next-auth/react"; +import { signIn, useSession } from "next-auth/react"; +import { useRouter } from "next/router"; export const HomeLayout: React.FC = ({ children }) => { return ( @@ -33,7 +34,7 @@ const Header: React.FC = () => { // Scroll Listener useEffect(() => { - const listenScrollEvent = () => { + const listenScrollEvent: () => void = () => { const threshold = 25; setIsLargeBar( document.body.scrollTop < threshold && @@ -47,18 +48,6 @@ const Header: React.FC = () => { }; }); - const FlexDivider = () => ||; - - const Background = () => ( -
- ); - return (
{ Premium
- + ); }; +const FlexDivider: React.FC = () => ( + || +); + +const Background: React.FC = () => ( +
+); + +const CTAButton: React.FC = () => { + const session = useSession(); + const router = useRouter(); + + if (session.status === "authenticated") { + const username = session.data.user.username ?? ""; + + return ( + + ); + } + + return ( + + ); +}; + // === Footer ================================================================= const Footer: React.FC = () => { diff --git a/src/components/layouts/MainLayout.tsx b/src/components/layouts/MainLayout.tsx index 24c9c16..4a9be98 100644 --- a/src/components/layouts/MainLayout.tsx +++ b/src/components/layouts/MainLayout.tsx @@ -10,6 +10,7 @@ import { FiUser, FiLogOut, FiSettings, + FiExternalLink, } from "react-icons/fi"; import type { IconType } from "react-icons/lib"; import { Button } from "@components/Button"; @@ -220,6 +221,7 @@ const MoreMenu: React.FC = () => { className="min-w-[250px] rounded-md bg-bg-700 p-3 data-[side=top]:animate-slideUpAndFade" sideOffset={10} > + {/* Settings */} { + + {/* Landing page */} + + +

Parallel Homepage

+ + +
+ + {/* Sign out */} + +
+ + )} ); }; diff --git a/src/server/api/routers/projects.ts b/src/server/api/routers/projects.ts index 9b47446..16698ed 100644 --- a/src/server/api/routers/projects.ts +++ b/src/server/api/routers/projects.ts @@ -40,6 +40,7 @@ export const projectsRouter = createTRPCRouter({ const projects = await ctx.prisma.project.findMany({ where: { state: input.state }, select: { + id: true, author: true, members: true, bannerImageUrl: true, @@ -51,11 +52,15 @@ export const projectsRouter = createTRPCRouter({ take: 100, orderBy: [{ createdAt: "desc" }], }); - projects.map((p) => ({ + + return projects.map((p) => ({ members: (() => { p.members.push(p.author); - return p.members.map((m) => m.username); + return p.members + .map((m) => m.username) + .filter((username) => !!username) as string[]; })(), + id: p.id, createdAt: p.createdAt, title: p.title, description: p.description, @@ -85,4 +90,18 @@ export const projectsRouter = createTRPCRouter({ return proposal; }), + updateState: protectedProcedure + .input( + z.object({ + state: z.nativeEnum(ProjectLifecycle), + projectId: z.string(), + }) + ) + .mutation(async ({ ctx, input }) => { + const { projectId, state } = input; + await ctx.prisma.project.update({ + where: { id: projectId }, + data: { state }, + }); + }), });