-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anthony Cueva
committed
Jan 13, 2024
1 parent
9681ca4
commit 275ef94
Showing
24 changed files
with
918 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
NEXT_PUBLIC_URL=https://app.com | ||
|
||
XATA_BRANCH=main | ||
XATA_API_KEY=xau_3jy9x04JI305oa6nJd6EcFGYwOSvd95f0 | ||
NEXT_PUBLIC_URL=https://useretest.vercel.app | ||
XATA_API_KEY=xau_1234567890 | ||
|
||
AUTH_SECRET="1234567890" | ||
|
||
GOOGLE_CLIENT_ID="123-456-789-0" | ||
GOOGLE_CLIENT_SECRET="GO-1234567890" | ||
|
||
EMAIL_SERVER_USER=resend | ||
EMAIL_SERVER_PASSWORD=YOUR_RESEND_API_KEY | ||
EMAIL_SERVER_HOST=smtp.resend.com | ||
EMAIL_SERVER_PORT=465 | ||
EMAIL_FROM=[email protected] |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export { GET, POST } from "@/auth"; | ||
export const runtime = "edge"; | ||
export { GET, POST } from "@/auth"; |
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,98 @@ | ||
"use client"; | ||
|
||
import { trpc } from "@/lib/trpc"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@retestlabs/ui/table"; | ||
import { useParams } from "next/navigation"; | ||
import { useQueryClient } from "@tanstack/react-query"; | ||
import { getQueryKey } from "@trpc/react-query"; | ||
|
||
import { Input } from "@retestlabs/ui/input"; | ||
import { Button } from "@retestlabs/ui/button"; | ||
import { Title } from "@/components/title"; | ||
|
||
export const Invitations = () => { | ||
const params = useParams<{ workspace: string }>(); | ||
let queryClient = useQueryClient(); | ||
|
||
let listWorkspaceInvites = trpc.listWorkspaceInvites.useQuery({ | ||
workspaceHandle: params.workspace, | ||
}); | ||
|
||
let listWorkspaceInvitesKeys = getQueryKey( | ||
trpc.listWorkspaceInvites, | ||
{ | ||
workspaceHandle: params.workspace, | ||
}, | ||
"query", | ||
); | ||
|
||
let inviteUserToWorkspace = trpc.inviteUserToWorkspace.useMutation({ | ||
onSuccess: () => { | ||
console.log("success"); | ||
queryClient.invalidateQueries(listWorkspaceInvitesKeys); | ||
}, | ||
}); | ||
|
||
return ( | ||
<> | ||
<Title>Invitations</Title> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>From</TableHead> | ||
<TableHead>To</TableHead> | ||
<TableHead>Send</TableHead> | ||
<TableHead>-</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{listWorkspaceInvites.data?.map((invite) => ( | ||
<TableRow key={invite.id}> | ||
<TableCell className="font-medium"> | ||
<div> | ||
<p className="font-bold">{invite.owner?.name}</p> | ||
<p className="text-muted-foreground">{invite.owner?.email}</p> | ||
</div> | ||
</TableCell> | ||
<TableCell>{invite.email}</TableCell> | ||
<TableCell> | ||
{invite.xata.updatedAt.toLocaleDateString()} | ||
</TableCell> | ||
<TableCell></TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
|
||
<form | ||
className="flex space-x-4 w-max mx-auto mt-4" | ||
onSubmit={(event) => { | ||
event.preventDefault(); | ||
let formData = new FormData(event.currentTarget); | ||
let email = formData.get("email") as string; | ||
inviteUserToWorkspace.mutate({ | ||
workspaceHandle: params.workspace, | ||
email, | ||
}); | ||
}} | ||
> | ||
<Input | ||
required | ||
name="email" | ||
type="email" | ||
placeholder="[email protected]" | ||
/> | ||
<Button type="submit" disabled={inviteUserToWorkspace.isLoading}> | ||
Invite | ||
</Button> | ||
</form> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"use client"; | ||
|
||
import { trpc } from "@/lib/trpc"; | ||
import { | ||
Table, | ||
TableBody, | ||
|
@@ -8,52 +9,53 @@ import { | |
TableHeader, | ||
TableRow, | ||
} from "@retestlabs/ui/table"; | ||
import { useParams } from "next/navigation"; | ||
|
||
import { Title } from "@/components/title"; | ||
import { Invitations } from "./invitations"; | ||
import { useUser } from "@/hooks/use-user"; | ||
|
||
const users = [ | ||
{ | ||
name: "Anthony Cueva", | ||
email: "[email protected]", | ||
role: "admin", | ||
}, | ||
{ | ||
name: "Railly Hugo", | ||
email: "[email protected]", | ||
role: "admin", | ||
}, | ||
]; | ||
|
||
function TableDemo() { | ||
return ( | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>User</TableHead> | ||
<TableHead>Role</TableHead> | ||
<TableHead>_</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{users.map((user) => ( | ||
<TableRow key={user.email}> | ||
<TableCell className="font-medium"> | ||
<div> | ||
<p className="font-bold">{user.name}</p> | ||
<p className="text-muted-foreground">{user.email}</p> | ||
</div> | ||
</TableCell> | ||
<TableCell>{user.role}</TableCell> | ||
<TableCell></TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
} | ||
const MembersPage = () => { | ||
const params = useParams<{ workspace: string }>(); | ||
|
||
let listWorspaceUsers = trpc.listWorspaceUsers.useQuery({ | ||
workspaceHandle: params.workspace, | ||
}); | ||
|
||
let { user } = useUser(); | ||
|
||
let isOwner = | ||
listWorspaceUsers.data?.find((u) => u.email === user?.email)?.role === | ||
"owner"; | ||
|
||
return ( | ||
<div> | ||
<h2 className="text-xl font-bold">Members</h2> | ||
<TableDemo /> | ||
<Title>Members</Title> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>User</TableHead> | ||
<TableHead>Role</TableHead> | ||
<TableHead>_</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{listWorspaceUsers.data?.map((user) => ( | ||
<TableRow key={user.email}> | ||
<TableCell className="font-medium"> | ||
<div> | ||
<p className="font-bold">{user.name}</p> | ||
<p className="text-muted-foreground">{user.email}</p> | ||
</div> | ||
</TableCell> | ||
<TableCell>{user.role}</TableCell> | ||
<TableCell></TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
|
||
{isOwner && <Invitations />} | ||
</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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { Title } from "@/components/title"; | ||
|
||
const Page = () => { | ||
return <div>Page</div>; | ||
return ( | ||
<div> | ||
<Title>Hello</Title> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Page; |
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
Oops, something went wrong.