From 41f992b824ed1d6e80bf5859c5a680fa778ec7ea Mon Sep 17 00:00:00 2001 From: DeepnaPooja Date: Thu, 24 Sep 2026 15:05:48 +0530 Subject: [PATCH] store page fixes --- .../app/(dashboard)/stores/[id]/edit/page.tsx | 64 +++++++++++++------ .../app/(dashboard)/stores/[id]/page.tsx | 15 +---- .../stores/_components/store-sheet.tsx | 4 +- .../stores/_components/stores-client.tsx | 27 +------- .../app/(dashboard)/stores/new/page.tsx | 62 ++++++++++++------ 5 files changed, 93 insertions(+), 79 deletions(-) diff --git a/distribution_fe/app/(dashboard)/stores/[id]/edit/page.tsx b/distribution_fe/app/(dashboard)/stores/[id]/edit/page.tsx index 5d93c0c..7917a1a 100644 --- a/distribution_fe/app/(dashboard)/stores/[id]/edit/page.tsx +++ b/distribution_fe/app/(dashboard)/stores/[id]/edit/page.tsx @@ -29,7 +29,8 @@ const LocationPicker = dynamic( const schema = z.object({ storeName: z.string().min(1, 'Store name is required'), - ownerName: z.string().min(1, 'Owner name is required'), + ownerName: z.string().optional(), + contactNumber: z.string().optional(), storeAddress: z.string().min(1, 'Store address is required'), routeId: z.string().min(1, 'Route is required'), latitude: z.number(), @@ -55,7 +56,8 @@ function StoreEditForm({ store, routes, onSaved, onCancel }: StoreEditFormProps) resolver: zodResolver(schema), defaultValues: { storeName: store.storeName, - ownerName: store.ownerName, + ownerName: store.ownerName ?? '', + contactNumber: store.contactNumber ?? '', storeAddress: store.storeAddress, routeId: store.routeId, latitude: store.latitude, @@ -74,6 +76,8 @@ function StoreEditForm({ store, routes, onSaved, onCancel }: StoreEditFormProps) await storesApi.update(store.id, { ...values, segment: values.segment || undefined, + ownerName: values.ownerName || null, + contactNumber: values.contactNumber || null, }) toast.add({ title: 'Store updated', type: 'success' }) onSaved() @@ -108,25 +112,6 @@ function StoreEditForm({ store, routes, onSaved, onCancel }: StoreEditFormProps) )} /> - ( - - )} - /> - + ( + + )} + /> + + ( + + )} + /> + import('../_components/location-picker').then((m) => m.LocationPicker), @@ -22,12 +22,6 @@ const fmtDate = (v: string) => const fmtMoney = (v: number) => `Rs. ${v.toLocaleString('en-LK', { minimumFractionDigits: 2 })}` -function kycVariant(status: KycStatus): 'default' | 'secondary' | 'destructive' { - if (status === 'Verified') return 'default' - if (status === 'Rejected') return 'destructive' - return 'secondary' -} - function DetailRow({ label, children }: { label: string; children: React.ReactNode }) { return (
@@ -95,7 +89,6 @@ export default function StoreViewPage() { {store.isActive ? 'Active' : 'Inactive'} - {store.kycStatus} )}
@@ -136,7 +129,8 @@ export default function StoreViewPage() { {/* Left — store details */}
- {store.ownerName} + {store.ownerName ?? "—"} + {store.contactNumber ?? "—"} {store.storeAddress} {routeName ?? {store.routeId}} @@ -145,9 +139,6 @@ export default function StoreViewPage() { {store.segment} )} {fmtMoney(store.creditLimit)} - - {store.kycStatus} - {fmtDate(store.createdAt)}
diff --git a/distribution_fe/app/(dashboard)/stores/_components/store-sheet.tsx b/distribution_fe/app/(dashboard)/stores/_components/store-sheet.tsx index 420b278..7c73465 100644 --- a/distribution_fe/app/(dashboard)/stores/_components/store-sheet.tsx +++ b/distribution_fe/app/(dashboard)/stores/_components/store-sheet.tsx @@ -35,7 +35,7 @@ const LocationPicker = dynamic( const schema = z.object({ storeName: z.string().min(1, 'Store name is required'), - ownerName: z.string().min(1, 'Owner name is required'), + ownerName: z.string().optional(), storeAddress: z.string().min(1, 'Store address is required'), routeId: z.string().min(1, 'Route is required'), latitude: z.number(), @@ -83,7 +83,7 @@ export function StoreSheet({ open, onClose, store, onSuccess }: StoreSheetProps) if (store) form.reset({ storeName: store.storeName, - ownerName: store.ownerName, + ownerName: store.ownerName ?? '', storeAddress: store.storeAddress, routeId: store.routeId, latitude: store.latitude, diff --git a/distribution_fe/app/(dashboard)/stores/_components/stores-client.tsx b/distribution_fe/app/(dashboard)/stores/_components/stores-client.tsx index cff3fb4..d66cef2 100644 --- a/distribution_fe/app/(dashboard)/stores/_components/stores-client.tsx +++ b/distribution_fe/app/(dashboard)/stores/_components/stores-client.tsx @@ -11,17 +11,11 @@ import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { toast } from '@/components/ui/toast' import { stores as storesApi, routes as routesApi, getApiError, getPaginatedItems } from '@/lib/api/index' -import type { StoreResponse, KycStatus, RouteResponse } from '@/types/api' +import type { StoreResponse, RouteResponse } from '@/types/api' import { StoreSheet } from './store-sheet' import { StoreVisitHistorySheet } from './store-visit-history-sheet' -function kycBadgeVariant(status: KycStatus): 'default' | 'secondary' | 'destructive' { - if (status === 'Verified') return 'default' - if (status === 'Rejected') return 'destructive' - return 'secondary' -} - export function StoresClient() { const router = useRouter() const [data, setData] = useState([]) @@ -120,17 +114,6 @@ export function StoresClient() { {routeNameById.get(row.routeId) ?? row.routeId} ), }, - { - key: 'kycStatus', - title: 'KYC', - fields: ['kycStatus'], - width: 130, - cellRender: (row) => ( - - {row.kycStatus} - - ), - }, { key: 'status', title: 'Status', @@ -155,11 +138,6 @@ export function StoresClient() { label: 'Edit store', onClick: (store) => router.push(`/stores/${store.id}/edit`), }, - { - action: 'confirm', - label: 'View visit history', - onClick: openHistory, - }, { action: 'deactivate', label: 'Deactivate store', @@ -182,7 +160,7 @@ export function StoresClient() {

Stores

- Retail store accounts, credit limits, and KYC status + Retail store accounts, credit limits and balances