| @@ -163,9 +163,9 @@ | ||
| 163 | 163 | }); |
| 164 | 164 | |
| 165 | 165 | return await apiService.getCustomers(paramsObj); |
| 166 | 166 | }, |
| 167 | - enabled: can("yatra_view_bookings"), | |
| 167 | + enabled: can("yatra_view_customers"), | |
| 168 | 168 | }); |
| 169 | 169 | |
| 170 | 170 | // Fetch customer stats (counts) |
| 171 | 171 | const { data: statsRaw } = useQuery({ |
| @@ -172,9 +172,9 @@ | ||
| 172 | 172 | queryKey: ["customers-stats"], |
| 173 | 173 | queryFn: async () => { |
| 174 | 174 | return await apiService.getCustomerStats(); |
| 175 | 175 | }, |
| 176 | - enabled: can("yatra_view_bookings"), | |
| 176 | + enabled: can("yatra_view_customers"), | |
| 177 | 177 | }); |
| 178 | 178 | const statsData: any = statsRaw ?? {}; |
| 179 | 179 | |
| 180 | 180 | // Delete mutation |
| @@ -202,9 +202,11 @@ | ||
| 202 | 202 | return formatDateUtil(dateString); |
| 203 | 203 | }; |
| 204 | 204 | |
| 205 | 205 | const formatPrice = (price: number, currencyCode: string = "USD") => |
| 206 | - formatYatraMoney(Number(price) || 0, currencyCode, { zeroAsUnknown: false }); | |
| 206 | + formatYatraMoney(Number(price) || 0, currencyCode, { | |
| 207 | + zeroAsUnknown: false, | |
| 208 | + }); | |
| 207 | 209 | |
| 208 | 210 | const getStatusBadge = (status: string) => { |
| 209 | 211 | const statusMap: Record<string, { className: string; label: string }> = { |
| 210 | 212 | active: { |
| @@ -589,9 +591,9 @@ | ||
| 589 | 591 | key: "edit", |
| 590 | 592 | label: __("Edit"), |
| 591 | 593 | icon: <Edit className="w-4 h-4" />, |
| 592 | 594 | onClick: (customer: Customer) => handleEdit(customer), |
| 593 | - condition: () => can("yatra_edit_bookings"), | |
| 595 | + condition: () => can("yatra_edit_customers"), | |
| 594 | 596 | }, |
| 595 | 597 | { |
| 596 | 598 | key: "mark_active", |
| 597 | 599 | label: __("Mark as Active"), |
| @@ -600,9 +602,9 @@ | ||
| 600 | 602 | await updateStatusForIds([customer.id], "active"); |
| 601 | 603 | queryClient.invalidateQueries({ queryKey: ["customers"] }); |
| 602 | 604 | }, |
| 603 | 605 | condition: (customer: Customer) => |
| 604 | - can("yatra_edit_bookings") && customer.status !== "active", | |
| 606 | + can("yatra_edit_customers") && customer.status !== "active", | |
| 605 | 607 | }, |
| 606 | 608 | { |
| 607 | 609 | key: "mark_inactive", |
| 608 | 610 | label: __("Mark as Inactive"), |
| @@ -611,9 +613,9 @@ | ||
| 611 | 613 | await updateStatusForIds([customer.id], "inactive"); |
| 612 | 614 | queryClient.invalidateQueries({ queryKey: ["customers"] }); |
| 613 | 615 | }, |
| 614 | 616 | condition: (customer: Customer) => |
| 615 | - can("yatra_edit_bookings") && customer.status !== "inactive", | |
| 617 | + can("yatra_edit_customers") && customer.status !== "inactive", | |
| 616 | 618 | }, |
| 617 | 619 | { |
| 618 | 620 | key: "mark_blocked", |
| 619 | 621 | label: __("Mark as Blocked"), |
| @@ -622,9 +624,9 @@ | ||
| 622 | 624 | await updateStatusForIds([customer.id], "blocked"); |
| 623 | 625 | queryClient.invalidateQueries({ queryKey: ["customers"] }); |
| 624 | 626 | }, |
| 625 | 627 | condition: (customer: Customer) => |
| 626 | - can("yatra_edit_bookings") && customer.status !== "blocked", | |
| 628 | + can("yatra_edit_customers") && customer.status !== "blocked", | |
| 627 | 629 | }, |
| 628 | 630 | { |
| 629 | 631 | key: "delete", |
| 630 | 632 | label: __("Delete"), |
| @@ -630,9 +632,9 @@ | ||
| 630 | 632 | label: __("Delete"), |
| 631 | 633 | icon: <Trash2 className="w-4 h-4" />, |
| 632 | 634 | onClick: (customer: Customer) => handleDelete(customer), |
| 633 | 635 | variant: "destructive" as const, |
| 634 | - condition: () => can("yatra_delete_bookings"), | |
| 636 | + condition: () => can("yatra_delete_customers"), | |
| 635 | 637 | }, |
| 636 | 638 | ]; |
| 637 | 639 | |
| 638 | 640 | // Skeleton loader |
| @@ -700,9 +702,9 @@ | ||
| 700 | 702 | <div className="space-y-3"> |
| 701 | 703 | <PageHeader |
| 702 | 704 | title={__("Customers")} |
| 703 | 705 | description={__("Manage your customer database")} |
| 704 | - actionCapability="yatra_edit_bookings" | |
| 706 | + actionCapability="yatra_edit_customers" | |
| 705 | 707 | actions={ |
| 706 | 708 | <Button |
| 707 | 709 | onClick={handleCreateCustomer} |
| 708 | 710 | className="flex items-center gap-2" |
| @@ -714,9 +716,9 @@ | ||
| 714 | 716 | /> |
| 715 | 717 | |
| 716 | 718 | <div className="space-y-3"> |
| 717 | 719 | {/* Search and Filters Card */} |
| 718 | - <ConditionalRender capability="yatra_view_bookings"> | |
| 720 | + <ConditionalRender capability="yatra_view_customers"> | |
| 719 | 721 | <Card> |
| 720 | 722 | <CardContent className="p-4"> |
| 721 | 723 | <div className="grid grid-cols-1 lg:grid-cols-12 gap-4 items-center"> |
| 722 | 724 | {/* Search & status/sort (handled by toolbar) */} |
| @@ -771,9 +773,9 @@ | ||
| 771 | 773 | </Card> |
| 772 | 774 | </ConditionalRender> |
| 773 | 775 | |
| 774 | 776 | {/* Bulk Actions Toolbar */} |
| 775 | - <ConditionalRender capability="yatra_view_bookings"> | |
| 777 | + <ConditionalRender capability="yatra_view_customers"> | |
| 776 | 778 | <BulkActionToolbar |
| 777 | 779 | selectedIds={selectedIds} |
| 778 | 780 | bulkAction={bulkAction} |
| 779 | 781 | setBulkAction={setBulkAction} |
| @@ -812,9 +814,9 @@ | ||
| 812 | 814 | /> |
| 813 | 815 | </ConditionalRender> |
| 814 | 816 | |
| 815 | 817 | {/* Customers Table Card */} |
| 816 | - <ConditionalRender capability="yatra_view_bookings"> | |
| 818 | + <ConditionalRender capability="yatra_view_customers"> | |
| 817 | 819 | <Card> |
| 818 | 820 | <CardContent className="p-0"> |
| 819 | 821 | {isLoading ? ( |
| 820 | 822 | renderSkeleton() |
| @@ -840,9 +842,9 @@ | ||
| 840 | 842 | ? __("Try adjusting your filters to see more results.") |
| 841 | 843 | : __("Customers will appear here when bookings are made") |
| 842 | 844 | } |
| 843 | 845 | onCreateClick={ |
| 844 | - can("yatra_edit_bookings") | |
| 846 | + can("yatra_edit_customers") | |
| 845 | 847 | ? handleCreateCustomer |
| 846 | 848 | : undefined |
| 847 | 849 | } |
| 848 | 850 | onSort={handleSort} |
| @@ -852,9 +854,9 @@ | ||
| 852 | 854 | onSelectAll={handleSelectAll} |
| 853 | 855 | isAllSelected={isAllSelected} |
| 854 | 856 | getItemId={(customer: Customer) => customer.id} |
| 855 | 857 | skeletonRows={5} |
| 856 | - capability="yatra_view_bookings" | |
| 858 | + capability="yatra_view_customers" | |
| 857 | 859 | /> |
| 858 | 860 | )} |
| 859 | 861 | </CardContent> |
| 860 | 862 | </Card> |