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
6 changes: 6 additions & 0 deletions app/lib/forms/settings.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export const workspaceSchema = z.object({
.optional(),
reportTheme: z.enum(THEMES).optional(),
customReferralSources: z.string().optional(),
// Track E1 — gate the "Repair List" tab on published reports.
// The action reads these via fd.getAll() and appends to body directly;
// the schema entries ensure they are present in the field map for conform.
enableRepairList: z.boolean().optional(),
// Gate the client-driven "Build repair request" export on published reports.
enableCustomerRepairExport: z.boolean().optional(),
});

export type WorkspaceInput = z.infer<typeof workspaceSchema>;
Expand Down
48 changes: 48 additions & 0 deletions app/routes/settings-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface Branding {
logoUrl?: string | null;
reportTheme?: string | null;
customReferralSources?: string[];
enableRepairList?: boolean | null;
enableCustomerRepairExport?: boolean | null;
}

const THEMES = ["modern", "classic", "minimal"] as const;
Expand Down Expand Up @@ -73,6 +75,13 @@ export async function action({ request, context }: Route.ActionArgs) {
.filter(Boolean);
}

// Boolean feature flags — read via getAll() so the hidden "false" sibling
// and the checkbox "true" value are both visible; last entry wins.
const repairListVals = fd.getAll("enableRepairList");
body.enableRepairList = repairListVals[repairListVals.length - 1] === "true";
const repairExportVals = fd.getAll("enableCustomerRepairExport");
body.enableCustomerRepairExport = repairExportVals[repairExportVals.length - 1] === "true";

const api = createApi(context, { token });
// Body is runtime-assembled from Zod-validated form values matching UpdateBrandingSchema;
// cast through unknown to satisfy the strict hono/client intersection type. (C-10)
Expand Down Expand Up @@ -219,6 +228,45 @@ export default function SettingsWorkspacePage() {
</div>
</section>

{/* Report features */}
<section className="bg-ih-bg-card rounded-lg border border-ih-border p-6 space-y-5">
<h3 className="text-[11px] font-bold text-ih-fg-2 uppercase tracking-[0.2em]">Report Features</h3>

<label className="flex items-start gap-3 cursor-pointer select-none">
<input type="hidden" name={fields.enableRepairList.name} value="false" />
<input
type="checkbox"
name={fields.enableRepairList.name}
value="true"
defaultChecked={branding.enableRepairList ?? false}
className="mt-0.5 h-4 w-4 rounded border-ih-border text-ih-primary"
/>
<span>
<span className="block text-[13px] font-bold text-ih-fg-1">Show repair list tab</span>
<span className="block text-[12px] text-ih-fg-3 mt-0.5">
Displays a summarised Repair List tab on the published client report.
</span>
</span>
</label>

<label className="flex items-start gap-3 cursor-pointer select-none">
<input type="hidden" name={fields.enableCustomerRepairExport.name} value="false" />
<input
type="checkbox"
name={fields.enableCustomerRepairExport.name}
value="true"
defaultChecked={branding.enableCustomerRepairExport ?? false}
className="mt-0.5 h-4 w-4 rounded border-ih-border text-ih-primary"
/>
<span>
<span className="block text-[13px] font-bold text-ih-fg-1">Allow clients to build repair requests</span>
<span className="block text-[12px] text-ih-fg-3 mt-0.5">
Lets clients, agents, and inspectors build a shareable repair-request addendum from a published report.
</span>
</span>
</label>
</section>

{form.errors && (
<div className="px-4 py-2.5 rounded-md bg-ih-bad-bg border border-ih-bad text-[13px] text-ih-bad-fg font-medium">
{form.errors[0]}
Expand Down
Loading