fix: Use correct column names for tastings table
- Change nose/palate/finish/notes to nose_notes/palate_notes/finish_notes - Update query, interface, and all references in admin tastings page
This commit is contained in:
@@ -8,10 +8,9 @@ interface Tasting {
|
|||||||
bottle_id: string;
|
bottle_id: string;
|
||||||
user_id: string;
|
user_id: string;
|
||||||
rating: number;
|
rating: number;
|
||||||
nose: string | null;
|
nose_notes: string | null;
|
||||||
palate: string | null;
|
palate_notes: string | null;
|
||||||
finish: string | null;
|
finish_notes: string | null;
|
||||||
notes: string | null;
|
|
||||||
created_at: string;
|
created_at: string;
|
||||||
user: { username: string; display_name: string | null };
|
user: { username: string; display_name: string | null };
|
||||||
bottle: { id: string; name: string; distillery: string | null; image_url: string | null } | null;
|
bottle: { id: string; name: string; distillery: string | null; image_url: string | null } | null;
|
||||||
@@ -45,10 +44,9 @@ export default function AdminTastingsList({ tastings }: AdminTastingsListProps)
|
|||||||
t.bottle?.name?.toLowerCase().includes(searchLower) ||
|
t.bottle?.name?.toLowerCase().includes(searchLower) ||
|
||||||
t.bottle?.distillery?.toLowerCase().includes(searchLower) ||
|
t.bottle?.distillery?.toLowerCase().includes(searchLower) ||
|
||||||
t.user.username.toLowerCase().includes(searchLower) ||
|
t.user.username.toLowerCase().includes(searchLower) ||
|
||||||
t.notes?.toLowerCase().includes(searchLower) ||
|
t.nose_notes?.toLowerCase().includes(searchLower) ||
|
||||||
t.nose?.toLowerCase().includes(searchLower) ||
|
t.palate_notes?.toLowerCase().includes(searchLower) ||
|
||||||
t.palate?.toLowerCase().includes(searchLower) ||
|
t.finish_notes?.toLowerCase().includes(searchLower)
|
||||||
t.finish?.toLowerCase().includes(searchLower)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +125,7 @@ export default function AdminTastingsList({ tastings }: AdminTastingsListProps)
|
|||||||
{/* Tastings List */}
|
{/* Tastings List */}
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{filteredTastings.map(tasting => {
|
{filteredTastings.map(tasting => {
|
||||||
const hasNotes = tasting.notes || tasting.nose || tasting.palate || tasting.finish;
|
const hasNotes = tasting.nose_notes || tasting.palate_notes || tasting.finish_notes;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -171,14 +169,14 @@ export default function AdminTastingsList({ tastings }: AdminTastingsListProps)
|
|||||||
{/* Notes Preview */}
|
{/* Notes Preview */}
|
||||||
{hasNotes && (
|
{hasNotes && (
|
||||||
<div className="mt-2 space-y-1">
|
<div className="mt-2 space-y-1">
|
||||||
{tasting.nose && (
|
{tasting.nose_notes && (
|
||||||
<p className="text-xs text-zinc-400">
|
<p className="text-xs text-zinc-400">
|
||||||
<span className="text-zinc-600">Nose:</span> {tasting.nose.slice(0, 80)}...
|
<span className="text-zinc-600">Nose:</span> {tasting.nose_notes.slice(0, 80)}...
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{tasting.notes && (
|
{tasting.palate_notes && (
|
||||||
<p className="text-xs text-zinc-400 line-clamp-2">
|
<p className="text-xs text-zinc-400">
|
||||||
{tasting.notes.slice(0, 150)}...
|
<span className="text-zinc-600">Palate:</span> {tasting.palate_notes.slice(0, 80)}...
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ export default async function AdminTastingsPage() {
|
|||||||
bottle_id,
|
bottle_id,
|
||||||
user_id,
|
user_id,
|
||||||
rating,
|
rating,
|
||||||
nose,
|
nose_notes,
|
||||||
palate,
|
palate_notes,
|
||||||
finish,
|
finish_notes,
|
||||||
notes,
|
|
||||||
created_at,
|
created_at,
|
||||||
bottles (id, name, distillery, image_url)
|
bottles (id, name, distillery, image_url)
|
||||||
`)
|
`)
|
||||||
@@ -60,7 +59,7 @@ export default async function AdminTastingsPage() {
|
|||||||
avgRating: tastings.length > 0
|
avgRating: tastings.length > 0
|
||||||
? tastings.reduce((sum, t) => sum + (t.rating || 0), 0) / tastings.filter(t => t.rating > 0).length
|
? tastings.reduce((sum, t) => sum + (t.rating || 0), 0) / tastings.filter(t => t.rating > 0).length
|
||||||
: 0,
|
: 0,
|
||||||
withNotes: tastings.filter(t => t.notes || t.nose || t.palate || t.finish).length,
|
withNotes: tastings.filter(t => t.nose_notes || t.palate_notes || t.finish_notes).length,
|
||||||
todayCount: tastings.filter(t => {
|
todayCount: tastings.filter(t => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const tastingDate = new Date(t.created_at);
|
const tastingDate = new Date(t.created_at);
|
||||||
|
|||||||
Reference in New Issue
Block a user