-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Amaxa-Impact/feat/permissions
Permissions System
- Loading branch information
Showing
44 changed files
with
2,003 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import Link from "next/link"; | ||
|
||
import { signIn } from "@amaxa/auth"; | ||
import { Button } from "@amaxa/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@amaxa/ui/card"; | ||
import { Input } from "@amaxa/ui/input"; | ||
import { Label } from "@amaxa/ui/label"; | ||
|
||
import { env } from "~/env"; | ||
|
||
export default function LoginForm() { | ||
return ( | ||
<div className="flex h-screen flex-col items-center justify-center"> | ||
<Card className="mx-auto max-w-sm"> | ||
<CardHeader> | ||
<CardTitle className="text-2xl">Login</CardTitle> | ||
<CardDescription> | ||
Enter your email below to login to your account | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="grid gap-4"> | ||
{env.NODE_ENV === "development" ? ( | ||
<> | ||
<form | ||
action={async (data) => { | ||
"use server"; | ||
await signIn("email", { | ||
password: data.get("password"), | ||
redirectTo: "/", | ||
}); | ||
}} | ||
> | ||
<div className="flex flex-col gap-4"> | ||
<Label htmlFor="password"> Password</Label> | ||
<Input id="password" type="password" required /> | ||
</div> | ||
<Button type="submit" className="w-full"> | ||
Login | ||
</Button> | ||
</form> | ||
</> | ||
) : null} | ||
|
||
<form | ||
action={async () => { | ||
"use server"; | ||
await signIn("google", { redirectTo: "/" }); | ||
}} | ||
> | ||
<Button variant="outline" className="w-full" type="submit"> | ||
Login with Google | ||
</Button> | ||
</form> | ||
</div> | ||
<div className="mt-4 text-center text-sm"> | ||
Have question's about how we use your data?{" "} | ||
<Link href="/data-privacy" className="underline"> | ||
Read our privacy statement here | ||
</Link> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from "react"; | ||
import Link from "next/link"; | ||
|
||
import { signIn } from "@amaxa/auth"; | ||
import { Button } from "@amaxa/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@amaxa/ui/card"; | ||
import { Input } from "@amaxa/ui/input"; | ||
import { Label } from "@amaxa/ui/label"; | ||
|
||
import { env } from "~/env"; | ||
|
||
export default function LoginForm() { | ||
return ( | ||
<div className="flex h-screen flex-col items-center justify-center"> | ||
<Card className="mx-auto max-w-sm"> | ||
<CardHeader> | ||
<CardTitle className="text-2xl">Login</CardTitle> | ||
<CardDescription> | ||
Enter your email below to login to your account | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="grid gap-4"> | ||
{env.NODE_ENV === "development" ? ( | ||
<> | ||
<form | ||
action={async (data) => { | ||
"use server"; | ||
await signIn("email", { | ||
password: data.get("password"), | ||
redirectTo: "/", | ||
}); | ||
}} | ||
> | ||
<div className="flex flex-col gap-4"> | ||
<Label htmlFor="password"> Password</Label> | ||
<Input id="password" type="password" required /> | ||
</div> | ||
<Button type="submit" className="w-full"> | ||
Login | ||
</Button> | ||
</form> | ||
</> | ||
) : null} | ||
|
||
<form | ||
action={async () => { | ||
"use server"; | ||
await signIn("google", { redirectTo: "/" }); | ||
}} | ||
> | ||
<Button variant="outline" className="w-full" type="submit"> | ||
Login with Google | ||
</Button> | ||
</form> | ||
</div> | ||
<div className="mt-4 text-center text-sm"> | ||
Have question's about how we use your data?{" "} | ||
<Link href="/data-privacy" className="underline"> | ||
Read our privacy statement here | ||
</Link> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
); | ||
} |
10 changes: 9 additions & 1 deletion
10
apps/nextjs/src/app/(dashboard)/project/[id]/(root)/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../nextjs/src/app/(dashboard)/project/[id]/(root)/permissions/_components/add-user-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useForm } from "react-hook-form"; | ||
import { z } from "zod"; | ||
|
||
import { Button } from "@amaxa/ui/button"; | ||
import { Combobox } from "@amaxa/ui/combobox"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@amaxa/ui/dialog"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@amaxa/ui/form"; | ||
|
||
const addUserSchema = z.object({ | ||
userId: z.string(), | ||
permissions: z.array(z.string()), | ||
}); | ||
|
||
type AddUserForm = z.infer<typeof addUserSchema>; | ||
|
||
export default function AddUserForm({ | ||
userMap, | ||
}: { | ||
userMap: { | ||
value: string; | ||
label: string; | ||
}[]; | ||
}) { | ||
const form = useForm<AddUserForm>({ | ||
resolver: zodResolver(addUserSchema), | ||
}); | ||
|
||
function onSubmit(data: AddUserForm) { | ||
console.log(data); | ||
} | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button>Invite User</Button> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Add A User</DialogTitle> | ||
</DialogHeader> | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="userId" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>User</FormLabel> | ||
<FormControl> | ||
<Combobox {...field} options={userMap} /> | ||
</FormControl> | ||
<FormDescription> | ||
Select a user to add to the project | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Add User</Button> | ||
</form> | ||
</Form> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/nextjs/src/app/(dashboard)/project/[id]/(root)/permissions/_components/add-user.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { api } from "~/trpc/server"; | ||
import AddUserForm from "./add-user-form"; | ||
|
||
export async function AddUser() { | ||
const data = await api.users.usersNotInProject(); | ||
|
||
const userMap = data.map((user) => { | ||
return { | ||
value: user.id, | ||
label: user.name ?? "No Name User", | ||
}; | ||
}); | ||
|
||
return ( | ||
<div> | ||
<AddUserForm userMap={userMap} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react"; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return <div>{children}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
|
||
import "react-notion/src/styles.css"; | ||
|
||
import type { BlockMapType } from "react-notion"; | ||
import { NotionRenderer } from "react-notion"; | ||
|
||
import { Card, CardContent, CardHeader, CardTitle } from "@amaxa/ui/card"; | ||
|
||
export const Com = async (props: { id: string }) => { | ||
const data = (await fetch( | ||
`https://notion-api.splitbee.io/v1/page/${props.id}`, | ||
).then((res) => res.json())) as BlockMapType; | ||
|
||
return ( | ||
<Card className="container mx-auto my-8 h-[750px] w-[1000px] items-start overflow-y-scroll px-4 md:px-6 lg:px-8"> | ||
<CardHeader> | ||
<CardTitle className="text-3xl">Action Guide</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<NotionRenderer blockMap={data} /> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; |
20 changes: 20 additions & 0 deletions
20
apps/nextjs/src/app/(home)/@modal/(...)guide/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from "react"; | ||
|
||
import Modal from "@amaxa/ui/modal"; | ||
|
||
import { Com } from "./com"; | ||
|
||
export default function Page(props: { | ||
params: { | ||
id: string; | ||
}; | ||
}) { | ||
const { id } = props.params; | ||
console.log(id); | ||
|
||
return ( | ||
<Modal> | ||
<Com id={id} /> | ||
</Modal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Default() { | ||
return null; | ||
} |
Oops, something went wrong.