Fixed a number of issues
This commit is contained in:
@@ -11,18 +11,22 @@ if (!user) return Astro.redirect('/login');
|
||||
// Get current team from cookie
|
||||
const currentTeamId = Astro.cookies.get('currentTeamId')?.value;
|
||||
|
||||
const userMembership = await db.select()
|
||||
const userMemberships = await db.select()
|
||||
.from(members)
|
||||
.where(eq(members.userId, user.id))
|
||||
.get();
|
||||
.all();
|
||||
|
||||
if (!userMembership) return Astro.redirect('/dashboard');
|
||||
if (userMemberships.length === 0) return Astro.redirect('/dashboard');
|
||||
|
||||
// Use current team or fallback to first membership
|
||||
const userMembership = currentTeamId
|
||||
? userMemberships.find(m => m.organizationId === currentTeamId) || userMemberships[0]
|
||||
: userMemberships[0];
|
||||
|
||||
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 orgId = userMembership.organizationId;
|
||||
|
||||
const organization = await db.select()
|
||||
.from(organizations)
|
||||
@@ -55,34 +59,34 @@ const successType = url.searchParams.get('success');
|
||||
<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"
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
value={organization.name}
|
||||
placeholder="Organization name"
|
||||
class="input input-bordered w-full"
|
||||
required
|
||||
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" />
|
||||
@@ -106,7 +110,7 @@ const successType = url.searchParams.get('success');
|
||||
Add Category
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="text-base-content/70 mb-4">
|
||||
Categories help organize time tracking by type of work. All team members use the same categories.
|
||||
</p>
|
||||
@@ -126,16 +130,16 @@ const successType = url.searchParams.get('success');
|
||||
<div class="card-body p-4">
|
||||
<div class="flex items-center gap-3">
|
||||
{category.color && (
|
||||
<span class="w-4 h-4 rounded-full flex-shrink-0" style={`background-color: ${category.color}`}></span>
|
||||
<span class="w-4 h-4 rounded-full shrink-0" style={`background-color: ${category.color}`}></span>
|
||||
)}
|
||||
<div class="flex-grow min-w-0">
|
||||
<div class="grow min-w-0">
|
||||
<h3 class="font-semibold truncate">{category.name}</h3>
|
||||
<p class="text-xs text-base-content/60">
|
||||
Created {category.createdAt?.toLocaleDateString() ?? 'N/A'}
|
||||
</p>
|
||||
</div>
|
||||
<a
|
||||
href={`/dashboard/team/settings/categories/${category.id}/edit`}
|
||||
<a
|
||||
href={`/dashboard/team/settings/categories/${category.id}/edit`}
|
||||
class="btn btn-ghost btn-xs"
|
||||
>
|
||||
<Icon name="heroicons:pencil" class="w-4 h-4" />
|
||||
|
||||
Reference in New Issue
Block a user