Skip to content

Commit

Permalink
fix: [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Security2431 committed Mar 20, 2024
1 parent bd2f4b0 commit befdb63
Show file tree
Hide file tree
Showing 121 changed files with 3,157 additions and 2,274 deletions.
2 changes: 0 additions & 2 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@trpc/client": "11.0.0-next-beta.294",
"@trpc/react-query": "11.0.0-next-beta.294",
"@trpc/server": "11.0.0-next-beta.294",
"clsx": "^2.1.0",
"date-fns": "^2.30.0",
"emoji-picker-react": "^4.5.7",
"framer-motion": "^10.16.4",
Expand All @@ -41,7 +40,6 @@
"remark-gfm": "^4.0.0",
"sass": "^1.71.0",
"superjson": "2.2.1",
"tailwind-merge": "^2.2.1",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { OAuthProviders } from "@acme/auth";
import { auth } from "@acme/auth";

import { SignIn, SignOut } from "~/components/auth";
import { SignIn, SignOut } from "~/_components/auth";

interface Props {
provider: OAuthProviders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function SignIn({
return (
<form>
<Button
variant="outline"
size="lg"
type="submit"
className="w-full"
Expand All @@ -30,7 +31,8 @@ export function SignOut(props: { children: React.ReactNode }) {
return (
<form>
<Button
size="lg"
className="h-auto w-full p-0"
variant="ghost"
type="submit"
formAction={async () => {
"use server";
Expand Down
File renamed without changes.
65 changes: 65 additions & 0 deletions apps/nextjs/src/_components/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Link from "next/link";

import { auth } from "@acme/auth";
import { Avatar, AvatarFallback, AvatarImage } from "@acme/ui/avatar";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@acme/ui/dropdown-menu";

import { SignOut } from "~/_components/auth";
import { getAvatarFallback } from "~/_utils/common";
import routes from "~/_utils/routes";
import Logo from "./logo";

/* <Header />
============================================================================= */
const Header = async () => {
const session = await auth();

return (
<header className="mb-4 shadow-md">
<div className="container flex items-center justify-between py-4">
<Link href={routes.home}>
<Logo />
</Link>
{session && (
<div className="flex items-center gap-3">
<DropdownMenu>
<DropdownMenuTrigger>
<Avatar>
<AvatarImage src={session.user.image ?? ""} />
<AvatarFallback>
{getAvatarFallback(session.user.name ?? "")}
</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>{session.user.name}</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>Profile</DropdownMenuItem>
<DropdownMenuItem>Billing</DropdownMenuItem>
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>New Team</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />

<DropdownMenuItem asChild>
<SignOut>Log out</SignOut>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</div>
</header>
);
};

export default Header;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clsx from "clsx";
import { cn } from "@acme/ui";

export const Meteors = ({ number }: { number?: number }) => {
const meteors = new Array(number ?? 20).fill(true);
Expand All @@ -7,8 +7,8 @@ export const Meteors = ({ number }: { number?: number }) => {
{meteors.map((el, idx) => (
<span
key={"meteor" + idx}
className={clsx(
"animate-meteor-effect absolute left-1/2 top-1/2 h-0.5 w-0.5 rotate-[215deg] rounded-[9999px] bg-slate-500 shadow-[0_0_0_1px_#ffffff10]",
className={cn(
"absolute left-1/2 top-1/2 h-0.5 w-0.5 rotate-[215deg] animate-meteor-effect rounded-[9999px] bg-slate-500 shadow-[0_0_0_1px_#ffffff10]",
"before:absolute before:top-1/2 before:h-[1px] before:w-[50px] before:-translate-y-[50%] before:transform before:bg-gradient-to-r before:from-[#64748b] before:to-transparent before:content-['']",
)}
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"use client";

import React from "react";

import { cn } from "@acme/ui";
import { Button } from "@acme/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@acme/ui/dialog";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
useForm,
} from "@acme/ui/form";
import { Icons } from "@acme/ui/icons";
import { Input } from "@acme/ui/input";
import { toast } from "@acme/ui/toast";
import { CreateWorkspaceSchema } from "@acme/validators";

import { ACCEPTED_MIME_TYPES, MAX_FILE_SIZE } from "~/_utils/constants";
import { api } from "~/trpc/react";

/* Props - <CreateWorkspacesModal />
============================================================================= */
interface Props {
className?: string;
}

/* <CreateWorkspacesModal />
============================================================================= */
export function CreateWorkspacesModal({ className }: Props) {
const form = useForm({
schema: CreateWorkspaceSchema,
defaultValues: {
name: "",
image: undefined,
},
});

const utils = api.useUtils();
const createWorkspace = api.workspace.create.useMutation({
async onSuccess() {
toast.success("Your workspace has been created!");

await utils.workspace.invalidate();
},
onError: (err) => {
toast.error(
err?.data?.code === "UNAUTHORIZED"
? "You must be logged in to create workspace"
: "Failed to create workspace",
);
},
});

return (
<Dialog>
<DialogTrigger asChild>
<Button className={cn(className)}>
<Icons.Plus size={16} className="mr-2" /> Add new workspace
</Button>
</DialogTrigger>

<DialogContent>
<DialogHeader>
<DialogTitle>Create new workspace</DialogTitle>
</DialogHeader>
<Form {...form}>
<form
className="flex w-full max-w-md flex-col gap-4"
onSubmit={form.handleSubmit(async (data) => {
createWorkspace.mutate(data);
})}
>
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name:</FormLabel>
<FormControl>
<Input {...field} placeholder="Name" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Picture:</FormLabel>
<FormControl>
<Input
type="file"
size={MAX_FILE_SIZE}
accept={ACCEPTED_MIME_TYPES.join(",")}
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<DialogFooter className="sm:justify-start">
<Button type="submit" disabled={createWorkspace.isPending}>
Create workspace
</Button>
</DialogFooter>
</form>
</Form>
</DialogContent>
</Dialog>
);
}
Loading

0 comments on commit befdb63

Please sign in to comment.