Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/lib/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export interface OrgDetails {
created_at: number;
role: "owner" | "member";
logo_url: string | null;
link_count: number;
};
members: OrgMember[];
pending_invitations: OrgInvitation[];
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/routes/dashboard/org/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,14 @@
let canDelete = $state(false);

async function checkCanDelete() {
if (!orgDetails) return;
try {
const orgsRes = await orgsApi.listMyOrgs();
const ownedOrgs = orgsRes.orgs.filter((o) => o.role === "owner");
userOrgs = ownedOrgs.filter((o) => o.id !== orgDetails!.org.id);
canDelete = ownedOrgs.length > 1;

// Get link count from usage API
const usage = await orgsApi.getUsage();
linkCount = usage.usage?.links_created_this_month || 0;
// Get link count from org details (actual links in this org, not billing account level)
linkCount = orgDetails?.org.link_count || 0;
} catch {
canDelete = false;
}
Expand All @@ -378,6 +376,14 @@
setTimeout(() => (actionError = ""), 3000);
return;
}

// If org has no links, delete directly without showing modal
if (linkCount === 0) {
deleteAction = "delete";
await handleDeleteOrg();
return;
}

showDeleteModal = true;
deleteError = "";
deleteAction = "delete";
Expand Down
10 changes: 2 additions & 8 deletions scripts/start-local-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,8 @@ fi
echo "🔨 Building worker..."
worker-build --release --quiet

# Create R2 bucket for logos (if it doesn't exist)
echo "🪣 Setting up R2 assets bucket..."
if ! wrangler r2 bucket list | grep -q "rushomon-assets"; then
echo "Creating R2 bucket: rushomon-assets"
wrangler r2 bucket create rushomon-assets
else
echo "R2 bucket 'rushomon-assets' already exists"
fi
# Note: R2 bucket is created automatically by wrangler dev --local
# Remote bucket creation is skipped for local development

# Apply migrations (passing environment if specified)
echo "🔨 Applying migrations..."
Expand Down
2 changes: 2 additions & 0 deletions src/api/orgs/crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async fn inner_get_org(req: Request, ctx: RouteContext<()>) -> Result<Response,
};

let logo_url = repo.get_logo_url(&db, &org_id).await.unwrap_or(None);
let link_count = repo.count_links(&db, &org_id).await.unwrap_or(0);

Ok(Response::from_json(&serde_json::json!({
"org": {
Expand All @@ -157,6 +158,7 @@ async fn inner_get_org(req: Request, ctx: RouteContext<()>) -> Result<Response,
"created_at": org.created_at,
"role": member.role,
"logo_url": logo_url,
"link_count": link_count,
},
"members": members,
"pending_invitations": pending_invitations,
Expand Down
Loading