refactor: remove personal_rating, DRY get_or_404, fix ty errors
- Drop Product.personal_rating from model, API schemas, and all frontend views (list table, detail view, quick-edit form, new-product form) - Extract get_or_404 into backend/innercontext/api/utils.py; remove five duplicate copies from individual API modules - Fix all ty type errors: generic get_or_404 with TypeVar, cast() in coerce_effect_profile validator, col() for ilike on SQLModel column, dict[str, Any] annotation in test helper, ty: ignore for CORSMiddleware Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5e3c0c97e5
commit
6333c6678a
15 changed files with 30 additions and 81 deletions
|
|
@ -149,7 +149,6 @@ export interface Product {
|
|||
is_medication: boolean;
|
||||
is_tool: boolean;
|
||||
needle_length_mm?: number;
|
||||
personal_rating?: number;
|
||||
personal_tolerance_notes?: string;
|
||||
personal_repurchase_intent?: boolean;
|
||||
created_at: string;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@
|
|||
<TableHead>Category</TableHead>
|
||||
<TableHead>Targets</TableHead>
|
||||
<TableHead>Time</TableHead>
|
||||
<TableHead>Rating</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
|
|
@ -93,17 +92,10 @@
|
|||
</div>
|
||||
</TableCell>
|
||||
<TableCell class="uppercase text-sm">{product.recommended_time}</TableCell>
|
||||
<TableCell>
|
||||
{#if product.personal_rating}
|
||||
{product.personal_rating}/10
|
||||
{:else}
|
||||
<span class="text-muted-foreground">—</span>
|
||||
{/if}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{:else}
|
||||
<TableRow>
|
||||
<TableCell colspan={6} class="text-center text-muted-foreground py-8">
|
||||
<TableCell colspan={5} class="text-center text-muted-foreground py-8">
|
||||
No products found.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ export const actions: Actions = {
|
|||
if (value !== '') body[key] = value;
|
||||
}
|
||||
if ('leave_on' in body) body.leave_on = body.leave_on === 'true';
|
||||
if ('personal_rating' in body) body.personal_rating = Number(body.personal_rating);
|
||||
try {
|
||||
try {
|
||||
const product = await updateProduct(params.id, body);
|
||||
return { success: true, product };
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@
|
|||
—
|
||||
{/if}
|
||||
</span>
|
||||
<span class="text-muted-foreground">Rating</span>
|
||||
<span>{product.personal_rating != null ? `${product.personal_rating}/10` : '—'}</span>
|
||||
</div>
|
||||
</div>
|
||||
{#if product.targets.length}
|
||||
<div>
|
||||
<span class="text-muted-foreground">Targets: </span>
|
||||
|
|
@ -80,17 +78,6 @@
|
|||
<CardHeader><CardTitle>Quick edit</CardTitle></CardHeader>
|
||||
<CardContent>
|
||||
<form method="POST" action="?/update" use:enhance class="grid grid-cols-2 gap-4">
|
||||
<div class="space-y-1">
|
||||
<Label for="personal_rating">Personal rating (1-10)</Label>
|
||||
<Input
|
||||
id="personal_rating"
|
||||
name="personal_rating"
|
||||
type="number"
|
||||
min="1"
|
||||
max="10"
|
||||
value={product.personal_rating ?? ''}
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<Label for="personal_tolerance_notes">Tolerance notes</Label>
|
||||
<Input
|
||||
|
|
|
|||
|
|
@ -109,9 +109,6 @@ export const actions: Actions = {
|
|||
const max_frequency_per_week = parseOptionalInt(form.get('max_frequency_per_week') as string | null);
|
||||
if (max_frequency_per_week !== undefined) payload.max_frequency_per_week = max_frequency_per_week;
|
||||
|
||||
const personal_rating = parseOptionalInt(form.get('personal_rating') as string | null);
|
||||
if (personal_rating !== undefined) payload.personal_rating = personal_rating;
|
||||
|
||||
const needle_length_mm = parseOptionalFloat(form.get('needle_length_mm') as string | null);
|
||||
if (needle_length_mm !== undefined) payload.needle_length_mm = needle_length_mm;
|
||||
|
||||
|
|
|
|||
|
|
@ -366,11 +366,6 @@
|
|||
<CardHeader><CardTitle>Personal notes</CardTitle></CardHeader>
|
||||
<CardContent class="space-y-4">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="space-y-2">
|
||||
<Label for="personal_rating">Personal rating (1–10)</Label>
|
||||
<Input id="personal_rating" name="personal_rating" type="number" min="1" max="10" placeholder="e.g. 8" />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label>Repurchase intent</Label>
|
||||
<input type="hidden" name="personal_repurchase_intent" value={personalRepurchaseIntent} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue