Updated
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
import DashboardLayout from '../../../layouts/DashboardLayout.astro';
|
||||
import { Icon } from 'astro-icon/components';
|
||||
import { db } from '../../../db';
|
||||
import { categories, members } from '../../../db/schema';
|
||||
import { categories, members, organizations } from '../../../db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
const user = Astro.locals.user;
|
||||
if (!user) return Astro.redirect('/login');
|
||||
|
||||
// Get current team from cookie
|
||||
const currentTeamId = Astro.cookies.get('currentTeamId')?.value;
|
||||
|
||||
const userMembership = await db.select()
|
||||
.from(members)
|
||||
.where(eq(members.userId, user.id))
|
||||
@@ -18,13 +21,26 @@ if (!userMembership) return Astro.redirect('/dashboard');
|
||||
const isAdmin = userMembership.role === 'owner' || userMembership.role === 'admin';
|
||||
if (!isAdmin) return Astro.redirect('/dashboard/team');
|
||||
|
||||
// Use current team or fallback to membership org
|
||||
const orgId = currentTeamId || userMembership.organizationId;
|
||||
|
||||
const organization = await db.select()
|
||||
.from(organizations)
|
||||
.where(eq(organizations.id, orgId))
|
||||
.get();
|
||||
|
||||
if (!organization) return Astro.redirect('/dashboard');
|
||||
|
||||
const allCategories = await db.select()
|
||||
.from(categories)
|
||||
.where(eq(categories.organizationId, userMembership.organizationId))
|
||||
.where(eq(categories.organizationId, orgId))
|
||||
.all();
|
||||
|
||||
const url = new URL(Astro.request.url);
|
||||
const successType = url.searchParams.get('success');
|
||||
---
|
||||
|
||||
<DashboardLayout title="Team Settings - Zamaan">
|
||||
<DashboardLayout title="Team Settings - Chronus">
|
||||
<div class="flex items-center gap-3 mb-6">
|
||||
<a href="/dashboard/team" class="btn btn-ghost btn-sm">
|
||||
<Icon name="heroicons:arrow-left" class="w-5 h-5" />
|
||||
@@ -32,6 +48,51 @@ const allCategories = await db.select()
|
||||
<h1 class="text-3xl font-bold">Team Settings</h1>
|
||||
</div>
|
||||
|
||||
<!-- Team Settings -->
|
||||
<div class="card bg-base-100 shadow-xl border border-base-200 mb-6">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title mb-4">
|
||||
<Icon name="heroicons:building-office-2" class="w-6 h-6" />
|
||||
Team Settings
|
||||
</h2>
|
||||
|
||||
{successType === 'org-name' && (
|
||||
<div class="alert alert-success mb-4">
|
||||
<Icon name="heroicons:check-circle" class="w-6 h-6" />
|
||||
<span>Team name updated successfully!</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form action="/api/organizations/update-name" method="POST" class="space-y-4">
|
||||
<input type="hidden" name="organizationId" value={organization.id} />
|
||||
|
||||
<label class="form-control">
|
||||
<div class="label">
|
||||
<span class="label-text font-medium">Team Name</span>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
value={organization.name}
|
||||
placeholder="Organization name"
|
||||
class="input input-bordered w-full"
|
||||
required
|
||||
/>
|
||||
<div class="label">
|
||||
<span class="label-text-alt text-base-content/60">This name is visible to all team members</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<Icon name="heroicons:check" class="w-5 h-5" />
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Categories Section -->
|
||||
<div class="card bg-base-100 shadow-xl border border-base-200 mb-6">
|
||||
<div class="card-body">
|
||||
@@ -88,16 +149,4 @@ const allCategories = await db.select()
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Future Settings Sections -->
|
||||
<div class="card bg-base-100 shadow-xl border border-base-200">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">
|
||||
<Icon name="heroicons:cog-6-tooth" class="w-6 h-6" />
|
||||
Organization Settings
|
||||
</h2>
|
||||
<p class="text-base-content/70">
|
||||
Additional organization settings coming soon...
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</DashboardLayout>
|
||||
|
||||
Reference in New Issue
Block a user