From 4aa7d8a1d459bd7b27661964ec1d25703f1e6f73 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Mon, 7 Sep 2026 23:42:50 +0530 Subject: [PATCH] enhh --- .commandcode/settings.json | 7 +- .commandcode/taste/taste/taste.md | 2 +- .../web-ui/src/components/FloatingCartBar.tsx | 12 +- apps/web-ui/src/components/me/MeOrderMenu.tsx | 252 +++++++++ .../src/components/me/MeScreenHeader.tsx | 38 ++ .../src/components/me/NextOrderGlimpse.tsx | 200 +++++++ apps/web-ui/src/routes/me.addresses.tsx | 300 ++++++++-- apps/web-ui/src/routes/me.complaints.tsx | 28 +- apps/web-ui/src/routes/me.coupons.tsx | 91 ++-- apps/web-ui/src/routes/me.edit-profile.tsx | 235 ++++++-- apps/web-ui/src/routes/me.orders.$id.tsx | 12 +- apps/web-ui/src/routes/me.orders.tsx | 514 +++++++++++++++--- apps/web-ui/src/routes/me.terms.tsx | 212 ++++++-- apps/web-ui/src/routes/me.tsx | 216 +++++--- change-log.txt | 17 + 15 files changed, 1790 insertions(+), 346 deletions(-) create mode 100644 apps/web-ui/src/components/me/MeOrderMenu.tsx create mode 100644 apps/web-ui/src/components/me/MeScreenHeader.tsx create mode 100644 apps/web-ui/src/components/me/NextOrderGlimpse.tsx diff --git a/.commandcode/settings.json b/.commandcode/settings.json index 73983ed..00d8ceb 100644 --- a/.commandcode/settings.json +++ b/.commandcode/settings.json @@ -45,7 +45,12 @@ "Shell(done:*)", "Shell(cd /Users/mohammedshafiuddin/WebDev/freshyo && echo \"=== product.ts trpc import line & usage count ===\" && sed -n '1,40p' apps/backend/src/trpc/apis/admin-apis/apis/product.ts && echo \"=== count occurrences of each beyond import ===\" && for fn in checkUnitExists getProductImagesById replaceProductTags; do echo \"$fn: total=$(grep -c \"$fn\" apps/backend/src/trpc/apis/admin-apis/apis/product.ts)\"; done)", "Shell(node -e const fs = require(\"fs\"); const parse = (p) => { const src = fs.readFileSync(p,\"utf8\"); const names = new Set(); // export { a, b as c, ... } from / re-export lists const re = /\\bexport\\s*\\{([^}]*)\\}/g; let m; while ((m = re.exec(src))) { const body = m[1]; for (let line of body.split(\",\")) { line = line.trim().replace(/\\/\\/.*$/,\"\").trim(); if (!line) continue; const asMatch = line.match(/^(.+?)\\s+as\\s+(.+)$/); if (asMatch) names.add(asMatch[2].trim()); else if (line.match(/^[A-Za-z_$][\\w$]*$/)) names.add(line); } } return names; }; const sqlite = parse(\"packages/db_helper_sqlite/index.ts\"); const pg = parse(\"packages/db_helper_postgres/index.ts\"); const onlySqlite = [...sqlite].filter(x=>!pg.has(x)).sort(); const onlyPg = [...pg].filter(x=>!sqlite.has(x)).sort(); console.log(\"ONLY IN SQLITE INDEX:\", onlySqlite.join(\", \")); console.log(\"ONLY IN POSTGRES INDEX:\", onlyPg.join(\", \")); )", - "Shell(cd /Users/mohammedshafiuddin/WebDev/freshyo/packages/db_helper_postgres npx tsc --noEmit > /tmp/pg_tsc.log 2>&1 echo \"tsc exit: $?\" echo \"=== error count ===\"; grep -c \"error TS\" /tmp/pg_tsc.log echo \"=== errors touching shared types / banner / coupon / store / const / complaint / staff-user ===\" grep -E \"admin-apis/(banner|coupon|store|const|complaint|staff-user|slots|vendor-snippets|order)\\.ts\" /tmp/pg_tsc.log | head -20 echo \"=== total error files ===\" grep \"error TS\" /tmp/pg_tsc.log | grep -oE \"^[^(]+\" | sort -u)" + "Shell(cd /Users/mohammedshafiuddin/WebDev/freshyo/packages/db_helper_postgres npx tsc --noEmit > /tmp/pg_tsc.log 2>&1 echo \"tsc exit: $?\" echo \"=== error count ===\"; grep -c \"error TS\" /tmp/pg_tsc.log echo \"=== errors touching shared types / banner / coupon / store / const / complaint / staff-user ===\" grep -E \"admin-apis/(banner|coupon|store|const|complaint|staff-user|slots|vendor-snippets|order)\\.ts\" /tmp/pg_tsc.log | head -20 echo \"=== total error files ===\" grep \"error TS\" /tmp/pg_tsc.log | grep -oE \"^[^(]+\" | sort -u)", + "Shell(cd /Users/mohammedshafiuddin/WebDev/freshyo/apps/web-ui && npx tsc --noEmit > /tmp/me_tsc.txt 2>&1; echo \"exit=$?\"; wc -l /tmp/me_tsc.txt; head -20 /tmp/me_tsc.txt)", + "Shell(sleep:*)", + "Shell(for p in /me /me/orders /me/addresses /me/coupons /me/complaints /me/edit-profile /me/terms; do code=$(curl -s -o /dev/null -w \"%{http_code}\" \"http://localhost:4175$p\"); echo \"$p -> $code\"; done)", + "Shell(curl -s http://localhost:4175/me)", + "Shell(pkill -f \"vite dev\" 2>/dev/null; pkill -f \"web-ui\" 2>/dev/null; echo \"stopped\")" ], "deny": [], "defaultMode": "default" diff --git a/.commandcode/taste/taste/taste.md b/.commandcode/taste/taste/taste.md index e157291..f9fec00 100644 --- a/.commandcode/taste/taste/taste.md +++ b/.commandcode/taste/taste/taste.md @@ -30,7 +30,7 @@ - Prefers detailed technical documentation of system architecture, data models, flows, and integrations in markdown format. Confidence: 0.8 - Wants edge cases explicitly enumerated when documenting or analyzing existing code/systems. Confidence: 0.8 - Values end-to-end analysis of features (architecture, data model, flows, integrations, and edge cases) when asked to explain how something works. Confidence: 0.7 -- When creating a clone/mirror of an app on a different platform (e.g., a web version of a React Native app), expects EXACT replication — functionality and looks must match the reference app with zero changes ("not even a slight change is acceptable"). The tech stack is inherited from the existing clone, not the original. Confidence: 0.9 +- When creating a clone/mirror of an app on a different platform (e.g., a web version of a React Native app), expects EXACT replication — functionality and looks must match the reference app with zero changes ("not even a slight change is acceptable"). The tech stack is inherited from the existing clone, not the original. The exactness requirement applies per section and down to every sub-page: naming a section of the RN app (e.g., "the 'me' section and all its sub pages") means the entire subtree must be an exact replica of the mobile screens, and he will flag remaining gaps ("I see a lot of gaps") if any sub-screen diverges — so the agent should audit every sub-page, not just the section hub, against the RN source of truth. Confidence: 0.95 - Prefers unifying parallel data structures into a single instance rather than maintaining separate ones (e.g., one cart for flash and regular items instead of separate flash/regular carts). Confidence: 0.9 - Prefers using sentinel values in existing fields (e.g., slotId = 0) to distinguish special-case items rather than creating separate fields or structures. Confidence: 0.9 - Prefers handling special-case logic locally in the relevant component/file rather than globally or via parallel flows. Confidence: 0.85 diff --git a/apps/web-ui/src/components/FloatingCartBar.tsx b/apps/web-ui/src/components/FloatingCartBar.tsx index 08d3fe5..7b66efd 100644 --- a/apps/web-ui/src/components/FloatingCartBar.tsx +++ b/apps/web-ui/src/components/FloatingCartBar.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react' import type { FlashDeliveryProps } from '@packages/shared' -import { useNavigate } from '@tanstack/react-router' +import { useNavigate, useLocation } from '@tanstack/react-router' import { useGetCart, useUpdateCartItem, useRemoveFromCart } from '../hooks/cart-query-hooks' import { useAllProducts } from '../hooks/prominent-api-hooks' import { useGetEssentialConsts } from '../hooks/prominent-api-hooks' @@ -27,6 +27,8 @@ const formatTimeRange = (deliveryTime: string | Date) => { export function FloatingCartBar({ isFlashDelivery = false }: FlashDeliveryProps) { const navigate = useNavigate() + const location = useLocation() + const isCartPage = location.pathname === '/cart' || location.pathname === '/flash/cart' || location.pathname.startsWith('/me') const [isExpanded, setIsExpanded] = useState(false) const [quantities, setQuantities] = useState>({}) const cartType = isFlashDelivery ? 'flash' : 'regular' @@ -78,7 +80,7 @@ export function FloatingCartBar({ isFlashDelivery = false }: FlashDeliveryProps) /* ---------- Desktop: slide-over panel ---------- */ const slideOver = ( -
+
{/* Header */}
@@ -147,7 +149,7 @@ export function FloatingCartBar({ isFlashDelivery = false }: FlashDeliveryProps) className="h-14 w-14 shrink-0 rounded-lg border border-gray-100 bg-gray-50 object-cover" />
-

+

{productsById[item.skuId]?.name || ''}

@@ -222,7 +224,7 @@ export function FloatingCartBar({ isFlashDelivery = false }: FlashDeliveryProps) return ( <> {/* Mobile: compact bottom bar */} -

+
+ ) +} + +export function MeOrderMenu({ orderId, postActionHandler }: MeOrderMenuProps) { + const navigate = useNavigate() + const [open, setOpen] = useState(false) + const [editNotesDialogOpen, setEditNotesDialogOpen] = useState(false) + const [editNotes, setEditNotes] = useState('') + const [complaintDialogOpen, setComplaintDialogOpen] = useState(false) + const [cancelDialogOpen, setCancelDialogOpen] = useState(false) + const [cancelReason, setCancelReason] = useState('') + + const cancelOrderMutation = trpc.user.order.cancelOrder.useMutation() + const updateNotesMutation = trpc.user.order.updateUserNotes.useMutation({ + onSuccess: () => { + alert('Notes updated successfully') + setEditNotesDialogOpen(false) + setEditNotes('') + postActionHandler?.() + }, + onError: (error: any) => { + alert(error.message || 'Failed to update notes') + }, + }) + + const handleEditNotes = async () => { + try { + await updateNotesMutation.mutateAsync({ + id: orderId, + userNotes: editNotes.trim(), + }) + } catch (error) { + // handled in mutation + } + } + + const handleCancelOrder = async () => { + if (!cancelReason.trim()) { + alert('Please enter a reason for cancellation') + return + } + try { + await cancelOrderMutation.mutateAsync({ id: orderId, reason: cancelReason }) + alert('Order cancelled successfully') + setCancelDialogOpen(false) + setCancelReason('') + postActionHandler?.() + } catch (error: any) { + alert(error.message || 'Failed to cancel order') + } + } + + const handleComplaintClose = () => { + setComplaintDialogOpen(false) + postActionHandler?.() + } + + return ( + <> + + + {/* Menu Dialog */} + setOpen(false)}> +
+
+
+

Order Options

+

Select an action for Order #{orderId}

+
+ + } + iconBg="bg-gray-50" + iconColor="text-gray-600" + title="View Details" + subtitle="View complete order information" + onClick={() => { + setOpen(false) + navigate({ to: '/me/orders/$id', params: { id: String(orderId) } }) + }} + /> + + } + iconBg="bg-blue-50" + iconColor="text-blue-600" + title="Edit Notes" + subtitle="Add special instructions" + onClick={() => { + setOpen(false) + setEditNotes('') + setEditNotesDialogOpen(true) + }} + /> + + } + iconBg="bg-yellow-50" + iconColor="text-yellow-600" + title="Raise Complaint" + subtitle="Report an issue with this order" + onClick={() => { + setOpen(false) + setComplaintDialogOpen(true) + }} + /> + + } + iconBg="bg-red-50" + iconColor="text-red-600" + title="Cancel Order" + subtitle="Request order cancellation" + onClick={() => { + setOpen(false) + setCancelDialogOpen(true) + }} + /> +
+ + + {/* Edit Notes Dialog */} + setEditNotesDialogOpen(false)}> +
+
+

Edit Instructions

+ +
+ +