-
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.
use server components for settings and members
- Loading branch information
1 parent
449b0ce
commit e02b25c
Showing
13 changed files
with
163 additions
and
152 deletions.
There are no files selected for viewing
File renamed without changes.
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
14 changes: 14 additions & 0 deletions
14
src/app/(dashboard)/[organizationId]/dashboard/organization/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,14 @@ | ||
import Members from "./members"; | ||
import Settings from "./settings"; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { params: { organizationId: string } }) { | ||
return ( | ||
<div className="max-w-screen-2xl m-auto space-y-12"> | ||
<h2 className="text-3xl font-bold">Organizations</h2> | ||
<Members selectedOrganizationSlug={params.organizationId} /> | ||
<Settings selectedOrganizationSlug={params.organizationId} /> | ||
</div> | ||
); | ||
} |
File renamed without changes.
57 changes: 57 additions & 0 deletions
57
src/app/(dashboard)/[organizationId]/dashboard/organization/settings.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,57 @@ | ||
import db from "@/lib/db"; | ||
import { organizations, usersToOrganizations } from "@/lib/schema/orgaizations"; | ||
import { Button } from "@/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/ui/card"; | ||
import { and, eq } from "drizzle-orm"; | ||
import { redirect } from "next/navigation"; | ||
import { auth } from "../../../../../../auth"; | ||
|
||
export default function Settings({ | ||
selectedOrganizationSlug, | ||
}: { selectedOrganizationSlug: string }) { | ||
async function callAction() { | ||
"use server"; | ||
const session = await auth(); | ||
if (!session) return; | ||
await db | ||
.delete(organizations) | ||
.where( | ||
and( | ||
eq(organizations.slug, selectedOrganizationSlug), | ||
eq(organizations.admin, session.user.id) | ||
) | ||
) | ||
.then( | ||
async () => | ||
await db | ||
.delete(usersToOrganizations) | ||
.where( | ||
eq(usersToOrganizations.organizationId, selectedOrganizationSlug) | ||
) | ||
); | ||
redirect("/dashboard"); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle className="text-2xl font-bold">Settings</CardTitle> | ||
<CardDescription>Adjust your organization's settings.</CardDescription> | ||
</CardHeader> | ||
<CardContent className="grid gap-6"> | ||
{selectedOrganizationSlug ?? "no org"} | ||
<form> | ||
<Button variant="destructive" formAction={callAction}> | ||
Delete | ||
</Button> | ||
</form> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
import OrganizationSwitcher from "@/components/dashboard/organization-switcher"; | ||
import db from "@/lib/db"; | ||
import { organizations } from "@/lib/schema/orgaizations"; | ||
import { auth } from "auth"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
export default async function Page() { | ||
const session = await auth(); | ||
|
||
const memberOrganizations = await db.query.organizations.findMany({ | ||
where: eq(organizations.admin, session?.user.id ?? ""), | ||
}); | ||
return <OrganizationSwitcher memberOrganizations={memberOrganizations} />; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
e02b25c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hubone – ./
hubone-ihsen.vercel.app
hubone.vercel.app
*.huboneapp.com
hubone-git-main-ihsen.vercel.app
huboneapp.com