P1 flow fix: register makes a solo user by default, collective creation is an opt-in flag, post-login menu for collective-less accounts
This commit is contained in:
parent
2665f43cc4
commit
2a3a1d79a1
15 changed files with 614 additions and 24 deletions
|
|
@ -265,6 +265,24 @@ export class CollectivesService {
|
|||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root-collective count + the workspace's tenancy kind, for the post-login
|
||||
* home decision (operator flow reorder #3). A personal workspace reports zero
|
||||
* by construction — it never contains collective rows — but the kind is
|
||||
* returned anyway so the client can label the menu honestly ("solo account")
|
||||
* without a second round-trip.
|
||||
*/
|
||||
async myCollectiveCount(workspaceId: string): Promise<{ collectives: number; workspaceKind: "shared" | "personal" }> {
|
||||
return withTenant(workspaceId, async (client) => {
|
||||
const rows = await client.query<{ n: string }>(
|
||||
"SELECT count(*)::text AS n FROM groups WHERE workspace_id = $1 AND kind = 'collective'",
|
||||
[workspaceId],
|
||||
);
|
||||
const kind = await client.query<{ kind: "shared" | "personal" }>("SELECT kind FROM workspaces WHERE id = $1", [workspaceId]);
|
||||
return { collectives: Number(rows.rows[0]?.n ?? 0), workspaceKind: kind.rows[0]?.kind ?? "shared" };
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The collective tree for the workspace: collectives as roots, subcollectives
|
||||
* nested, every node carrying its room set. 'plain' groups are sharing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue