* Fix BetterAuth field mapping and add owner-prefixed team names - Fix auth.server.ts: use camelCase Drizzle field names for BetterAuth adapter (was snake_case, causing user inserts to fail); add generateId: "uuid" so PostgreSQL UUID columns accept generated IDs - Add prependOwnerToTeamName / stripOwnerFromTeamName utilities - Invite join, league creation, and settings assign/remove all now manage the owner-prefix on team names atomically Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Complete BetterAuth migration: auth flows, rename, and cleanup - Add /forgot-password and /reset-password pages (full password reset flow) - Add 'Forgot password?' link on login page - Fix register.tsx: add explicit window.location fallback after signUp - Rename commissionerAuditLog.actorClerkId → actorUserId (migration 0084) and update all references in model, routes, components, and tests - Rewrite docs/agents/auth.md to document BetterAuth (removes all Clerk refs) - Update test fixtures and schema comments to remove Clerk ID references; use UUID-format IDs throughout test data - Update docs/agents/domain-models.md ownerId description Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix BetterAuth ID generation, clean up review issues - Set generateId: false so BetterAuth omits id from inserts; add $defaultFn(crypto.randomUUID) to accounts/sessions/verifications so Drizzle fills it in (fixes null id constraint violation on signup) - Move renameTeam to static import; rename before removeTeamOwner so a failed rename leaves owner intact rather than leaving a stale prefix - Clarify stripOwnerFromTeamName toTitleCase assumption in comment - Annotate reset-password token fallback to explain loader guarantee Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
172 lines
4.4 KiB
TypeScript
172 lines
4.4 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
import { CommissionersPanel } from "./CommissionersPanel";
|
|
import type { AuditLogEntry } from "~/models/audit-log";
|
|
|
|
const meta: Meta<typeof CommissionersPanel> = {
|
|
title: "League/CommissionersPanel",
|
|
component: CommissionersPanel,
|
|
parameters: {
|
|
layout: "padded",
|
|
},
|
|
args: {
|
|
auditLogUrl: "/leagues/league-abc-123/audit-log",
|
|
currentUserId: "user-alice",
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof CommissionersPanel>;
|
|
|
|
// ─── Fixtures ─────────────────────────────────────────────────────────────────
|
|
|
|
const commissioners = [
|
|
{ id: "c1", userId: "user-alice" },
|
|
{ id: "c2", userId: "user-bob" },
|
|
];
|
|
|
|
const commissionerMap: Record<string, string> = {
|
|
"user-alice": "Alice Johnson",
|
|
"user-bob": "Bob Smith",
|
|
};
|
|
|
|
const teams = [
|
|
{ id: "t1", ownerId: "user-alice" },
|
|
{ id: "t2", ownerId: "user-bob" },
|
|
{ id: "t3", ownerId: "user-carol" },
|
|
{ id: "t4", ownerId: null },
|
|
];
|
|
|
|
const activityEntries: AuditLogEntry[] = [
|
|
{
|
|
id: "log-1",
|
|
seasonId: "season-1",
|
|
leagueId: "league-abc-123",
|
|
actorUserId: "user-alice",
|
|
actorDisplayName: "Alice Johnson",
|
|
action: "draft_order_randomized",
|
|
affectedTeamIds: null,
|
|
details: null,
|
|
createdAt: new Date("2026-04-13T10:30:00Z"),
|
|
},
|
|
{
|
|
id: "log-2",
|
|
seasonId: "season-1",
|
|
leagueId: "league-abc-123",
|
|
actorUserId: "user-alice",
|
|
actorDisplayName: "Alice Johnson",
|
|
action: "draft_settings_changed",
|
|
affectedTeamIds: null,
|
|
details: { changedFields: ["draftRounds", "draftTimerMode"] },
|
|
createdAt: new Date("2026-04-12T18:15:00Z"),
|
|
},
|
|
{
|
|
id: "log-3",
|
|
seasonId: "season-1",
|
|
leagueId: "league-abc-123",
|
|
actorUserId: "user-bob",
|
|
actorDisplayName: "Bob Smith",
|
|
action: "league_settings_changed",
|
|
affectedTeamIds: null,
|
|
details: { changedFields: ["name"] },
|
|
createdAt: new Date("2026-04-11T09:00:00Z"),
|
|
},
|
|
];
|
|
|
|
// ─── Stories ──────────────────────────────────────────────────────────────────
|
|
|
|
export const Default: Story = {
|
|
args: {
|
|
commissioners,
|
|
commissionerMap,
|
|
teams,
|
|
activityEntries,
|
|
},
|
|
};
|
|
|
|
export const NoActivity: Story = {
|
|
name: "No Recent Activity",
|
|
args: {
|
|
commissioners,
|
|
commissionerMap,
|
|
teams,
|
|
activityEntries: [],
|
|
},
|
|
};
|
|
|
|
export const SingleCommissioner: Story = {
|
|
name: "Single Commissioner (is self, has team)",
|
|
args: {
|
|
commissioners: [{ id: "c1", userId: "user-alice" }],
|
|
commissionerMap: { "user-alice": "Alice Johnson" },
|
|
teams,
|
|
activityEntries,
|
|
},
|
|
};
|
|
|
|
export const CommissionerWithoutTeam: Story = {
|
|
name: "Commissioner Without a Team",
|
|
args: {
|
|
commissioners: [
|
|
{ id: "c1", userId: "user-alice" },
|
|
{ id: "c2", userId: "user-nomatch" },
|
|
],
|
|
commissionerMap: {
|
|
"user-alice": "Alice Johnson",
|
|
"user-nomatch": "Charlie (no team)",
|
|
},
|
|
teams,
|
|
activityEntries: [],
|
|
},
|
|
};
|
|
|
|
export const LongNames: Story = {
|
|
name: "Long Commissioner Names (overflow test)",
|
|
args: {
|
|
commissioners: [
|
|
{ id: "c1", userId: "user-alice" },
|
|
{ id: "c2", userId: "user-long" },
|
|
],
|
|
commissionerMap: {
|
|
"user-alice": "Alice Johnson-Bartholomew-Richardson",
|
|
"user-long": "Bartholomew Christopherson-Nightingale III",
|
|
},
|
|
teams,
|
|
activityEntries,
|
|
},
|
|
};
|
|
|
|
export const ManyCommissioners: Story = {
|
|
name: "Many Commissioners",
|
|
args: {
|
|
commissioners: [
|
|
{ id: "c1", userId: "user-alice" },
|
|
{ id: "c2", userId: "user-bob" },
|
|
{ id: "c3", userId: "user-carol" },
|
|
{ id: "c4", userId: "user-dave" },
|
|
],
|
|
commissionerMap: {
|
|
"user-alice": "Alice Johnson",
|
|
"user-bob": "Bob Smith",
|
|
"user-carol": "Carol Williams",
|
|
"user-dave": "Dave Martinez",
|
|
},
|
|
teams: [
|
|
{ id: "t1", ownerId: "user-alice" },
|
|
{ id: "t2", ownerId: "user-bob" },
|
|
{ id: "t3", ownerId: "user-carol" },
|
|
// dave has no team
|
|
],
|
|
activityEntries,
|
|
},
|
|
};
|
|
|
|
export const NotSelf: Story = {
|
|
name: "Viewer is not a commissioner",
|
|
args: {
|
|
commissioners,
|
|
commissionerMap,
|
|
teams,
|
|
activityEntries,
|
|
currentUserId: "user-carol",
|
|
},
|
|
};
|