@goplusvn/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/assets/erp_wallpaper.png +0 -0
- package/src/assets/goeat_logo.png +0 -0
- package/src/audit/audit-manager.ts +139 -0
- package/src/audit/index.ts +11 -0
- package/src/audit/memory-audit-logger.ts +86 -0
- package/src/audit/types.ts +50 -0
- package/src/auth/auth-service.ts +97 -0
- package/src/auth/index.ts +266 -0
- package/src/code-generation/index.ts +69 -0
- package/src/configs/auth-routes.ts +17 -0
- package/src/configs/crud.ts +136 -0
- package/src/configs/data/navigations.ts +781 -0
- package/src/configs/data/oauth-links.ts +10 -0
- package/src/configs/entities/material-categories.config.ts +125 -0
- package/src/configs/i18n.ts +12 -0
- package/src/configs/index.ts +26 -0
- package/src/configs/status.ts +25 -0
- package/src/configs/themes.ts +100 -0
- package/src/crud/components/crud-bulk-actions.tsx +91 -0
- package/src/crud/components/crud-card-view.tsx +241 -0
- package/src/crud/components/crud-context.tsx +122 -0
- package/src/crud/components/crud-delete-dialog.tsx +145 -0
- package/src/crud/components/crud-dialog.tsx +406 -0
- package/src/crud/components/crud-empty-state.tsx +104 -0
- package/src/crud/components/crud-export-button.tsx +170 -0
- package/src/crud/components/crud-field-renderer.tsx +653 -0
- package/src/crud/components/crud-filter-chips.tsx +102 -0
- package/src/crud/components/crud-filters/checkbox-filter.tsx +97 -0
- package/src/crud/components/crud-filters/datetime-filter.tsx +83 -0
- package/src/crud/components/crud-filters/filter-builder.tsx +66 -0
- package/src/crud/components/crud-filters/index.tsx +76 -0
- package/src/crud/components/crud-filters/radio-filter.tsx +86 -0
- package/src/crud/components/crud-filters/select-filter.tsx +141 -0
- package/src/crud/components/crud-filters/text-filter.tsx +86 -0
- package/src/crud/components/crud-form.tsx +642 -0
- package/src/crud/components/crud-import-dialog.tsx +440 -0
- package/src/crud/components/crud-infinite-scroll.tsx +116 -0
- package/src/crud/components/crud-page.tsx +1017 -0
- package/src/crud/components/crud-provider.tsx +277 -0
- package/src/crud/components/crud-row-actions.tsx +189 -0
- package/src/crud/components/crud-search.tsx +82 -0
- package/src/crud/components/crud-sheet.tsx +336 -0
- package/src/crud/components/crud-table-skeleton.tsx +26 -0
- package/src/crud/components/crud-table-toolbar.tsx +91 -0
- package/src/crud/components/crud-table.tsx +352 -0
- package/src/crud/components/crud-virtual-table.tsx +55 -0
- package/src/crud/components/index.tsx +20 -0
- package/src/crud/crud-filters/checkbox-filter.tsx +87 -0
- package/src/crud/crud-filters/datetime-filter.tsx +82 -0
- package/src/crud/crud-filters/filter-builder.tsx +64 -0
- package/src/crud/crud-filters/index.tsx +78 -0
- package/src/crud/crud-filters/radio-filter.tsx +79 -0
- package/src/crud/crud-filters/select-filter.tsx +148 -0
- package/src/crud/crud-filters/text-filter.tsx +81 -0
- package/src/crud/index.ts +43 -0
- package/src/crud/lib/crud-service.test.ts +334 -0
- package/src/crud/lib/crud-service.ts +358 -0
- package/src/crud/lib/crud-utils.test.ts +354 -0
- package/src/crud/lib/crud-utils.ts +299 -0
- package/src/crud/lib/crud-validator.ts +247 -0
- package/src/crud/lib/data-loader.ts +234 -0
- package/src/crud/lib/field-calculator.ts +241 -0
- package/src/crud/lib/field-formatter.ts +240 -0
- package/src/crud/lib/import-export-service.test.ts +290 -0
- package/src/crud/lib/import-export-service.ts +352 -0
- package/src/crud/lib/import-server-utils.ts +109 -0
- package/src/crud/lib/lazy-loader.ts +241 -0
- package/src/crud/lib/parse-filters.ts +85 -0
- package/src/crud/lib/permissions.ts +52 -0
- package/src/crud/lib/serialize-config.ts +60 -0
- package/src/crud/lib/stream-loader.ts +145 -0
- package/src/crud/lib/translate-config.ts +335 -0
- package/src/crud/lib/types.ts +11 -0
- package/src/crud/pages/entity-crud-page.tsx +144 -0
- package/src/crud/server.ts +8 -0
- package/src/home/constants.tsx +142 -0
- package/src/home/feature-showcase.tsx +171 -0
- package/src/home/home-page.tsx +191 -0
- package/src/home/hooks/index.ts +1 -0
- package/src/home/hooks/useWidgetPreferences.ts +167 -0
- package/src/home/index.ts +33 -0
- package/src/home/quick-access-dialog.tsx +271 -0
- package/src/home/quick-access-menu.tsx +267 -0
- package/src/home/types.ts +140 -0
- package/src/home/welcome-card.tsx +92 -0
- package/src/home/widget-container.tsx +258 -0
- package/src/home/widgets/base-widget.tsx +200 -0
- package/src/home/widgets/customers-widget.tsx +74 -0
- package/src/home/widgets/index.ts +6 -0
- package/src/home/widgets/orders-widget.tsx +87 -0
- package/src/home/widgets/revenue-widget.tsx +71 -0
- package/src/home/widgets/stock-widget.tsx +109 -0
- package/src/hooks/index.tsx +598 -0
- package/src/hooks/use-tenant.test.tsx +30 -0
- package/src/hooks/use-tenant.ts +5 -0
- package/src/index.ts +17 -0
- package/src/infrastructure/__tests__/architecture-verification.spec.ts +103 -0
- package/src/infrastructure/api-service.ts +317 -0
- package/src/infrastructure/cache/cache-manager.ts +107 -0
- package/src/infrastructure/cache/cache.ts +120 -0
- package/src/infrastructure/cache/index.ts +8 -0
- package/src/infrastructure/cache/types.ts +48 -0
- package/src/infrastructure/cron/cron-manager.ts +239 -0
- package/src/infrastructure/cron/index.ts +6 -0
- package/src/infrastructure/cron/types.ts +41 -0
- package/src/infrastructure/event-bus/event-bus.ts +145 -0
- package/src/infrastructure/event-bus/index.ts +2 -0
- package/src/infrastructure/event-bus/types.ts +22 -0
- package/src/infrastructure/index.ts +32 -0
- package/src/infrastructure/lock/decorators.ts +67 -0
- package/src/infrastructure/lock/index.ts +2 -0
- package/src/infrastructure/lock/lock-manager.ts +33 -0
- package/src/infrastructure/logger/index.ts +2 -0
- package/src/infrastructure/logger/logger.ts +96 -0
- package/src/infrastructure/logger/types.ts +25 -0
- package/src/layout/index.tsx +185 -0
- package/src/navigation/index.ts +91 -0
- package/src/notification/index.ts +14 -0
- package/src/notification/notification-service.ts +120 -0
- package/src/notification/storage/in-memory.ts +56 -0
- package/src/notification/storage/index.ts +1 -0
- package/src/notification/types.ts +51 -0
- package/src/organization/branch-service.ts +299 -0
- package/src/organization/branches.config.ts +154 -0
- package/src/organization/index.ts +5 -0
- package/src/plugin/apps-registry.ts +97 -0
- package/src/plugin/index.ts +5 -0
- package/src/plugin/types.ts +41 -0
- package/src/providers/index.tsx +109 -0
- package/src/providers/tenant-provider.tsx +45 -0
- package/src/rbac/components/roles/role-card.tsx +158 -0
- package/src/rbac/components/roles/role-stats-cards.tsx +29 -0
- package/src/rbac/components/roles/role-toolbar.tsx +123 -0
- package/src/rbac/hooks/use-role-operations.ts +159 -0
- package/src/rbac/hooks/use-roles-data.ts +59 -0
- package/src/rbac/index.ts +297 -0
- package/src/rbac/lib/permission-helpers.ts +63 -0
- package/src/rbac/pages/action-list-page.tsx +25 -0
- package/src/rbac/pages/resource-list-page.tsx +25 -0
- package/src/rbac/pages/role-list-page.tsx +378 -0
- package/src/rbac/permission-service.ts +140 -0
- package/src/rbac/permissions.ts +135 -0
- package/src/rbac/resource-service.ts +115 -0
- package/src/rbac/resource-validator.ts +119 -0
- package/src/rbac/role-service.ts +165 -0
- package/src/rbac/server.ts +16 -0
- package/src/rbac/types.ts +38 -0
- package/src/schemas/action.schema.ts +66 -0
- package/src/schemas/branch.schema.ts +52 -0
- package/src/schemas/coming-soon-schema.ts +9 -0
- package/src/schemas/company.schema.ts +44 -0
- package/src/schemas/forgot-passward-schema.ts +9 -0
- package/src/schemas/index.ts +30 -0
- package/src/schemas/material-category.schema.ts +43 -0
- package/src/schemas/material-pricing.schema.ts +74 -0
- package/src/schemas/material.schema.ts +76 -0
- package/src/schemas/materials.ts +52 -0
- package/src/schemas/new-passward-schema.ts +15 -0
- package/src/schemas/partner-company.schema.ts +149 -0
- package/src/schemas/register-schema.ts +36 -0
- package/src/schemas/resource.schema.ts +133 -0
- package/src/schemas/role.schema.ts +11 -0
- package/src/schemas/sign-in-schema.ts +24 -0
- package/src/schemas/supplier-pricing.schema.ts +15 -0
- package/src/schemas/supplier.schema.ts +120 -0
- package/src/schemas/system-category-group.schema.ts +67 -0
- package/src/schemas/system-category.schema.ts +77 -0
- package/src/schemas/system-config.schema.ts +118 -0
- package/src/schemas/uom.schema.ts +75 -0
- package/src/schemas/user-supplier.schema.ts +179 -0
- package/src/schemas/user.schema.ts +18 -0
- package/src/schemas/verify-email-schema.ts +9 -0
- package/src/schemas/warehouse.schema.ts +49 -0
- package/src/system/components/categories/category-list.tsx +529 -0
- package/src/system/components/categories/category-manager.tsx +89 -0
- package/src/system/components/categories/group-sidebar.tsx +308 -0
- package/src/system/components/settings/setting-dialogs.tsx +197 -0
- package/src/system/components/settings/setting-field.tsx +291 -0
- package/src/system/components/settings/setting-form-dialog.tsx +308 -0
- package/src/system/components/settings/settings-groups.ts +80 -0
- package/src/system/components/settings/settings-search.tsx +71 -0
- package/src/system/components/settings/settings-section.tsx +74 -0
- package/src/system/components/settings/settings-sidebar.tsx +81 -0
- package/src/system/constants.ts +3 -0
- package/src/system/index.ts +150 -0
- package/src/system/job-manager.ts +176 -0
- package/src/system/pages/components/categories/category-list.tsx +537 -0
- package/src/system/pages/components/categories/category-manager.tsx +90 -0
- package/src/system/pages/components/categories/group-sidebar.tsx +311 -0
- package/src/system/pages/components/settings/sales-rules-settings.tsx +222 -0
- package/src/system/pages/components/settings/setting-dialogs.tsx +197 -0
- package/src/system/pages/components/settings/setting-field.tsx +292 -0
- package/src/system/pages/components/settings/setting-form-dialog.tsx +308 -0
- package/src/system/pages/components/settings/settings-groups.ts +87 -0
- package/src/system/pages/components/settings/settings-page.tsx +372 -0
- package/src/system/pages/components/settings/settings-search.tsx +71 -0
- package/src/system/pages/components/settings/settings-section.tsx +74 -0
- package/src/system/pages/components/settings/settings-sidebar.tsx +81 -0
- package/src/system/pages/components/settings/system-settings.tsx +244 -0
- package/src/system/pages/system-category-page.tsx +15 -0
- package/src/system/pages/system-settings-page.tsx +380 -0
- package/src/system/schemas/system-category-group.schema.ts +46 -0
- package/src/system/schemas/system-category.schema.ts +56 -0
- package/src/system/services/settings-service.ts +127 -0
- package/src/system/services/system-category-service.ts +63 -0
- package/src/system/types.ts +45 -0
- package/src/types/index.ts +703 -0
- package/src/ui/auth/auth-layout.tsx +135 -0
- package/src/ui/auth/forgot-password-form.tsx +98 -0
- package/src/ui/auth/index.tsx +7 -0
- package/src/ui/auth/new-password-form.tsx +107 -0
- package/src/ui/auth/oauth-links.tsx +30 -0
- package/src/ui/auth/register-form.tsx +202 -0
- package/src/ui/auth/sign-in-form.tsx +238 -0
- package/src/ui/auth/verify-email-form.tsx +104 -0
- package/src/ui/crud/index.tsx +10 -0
- package/src/ui/data-display/accordion.tsx +65 -0
- package/src/ui/data-display/aspect-ratio.tsx +11 -0
- package/src/ui/data-display/avatar.tsx +163 -0
- package/src/ui/data-display/bento-grid.tsx +77 -0
- package/src/ui/data-display/carousel.tsx +249 -0
- package/src/ui/data-display/chart.tsx +363 -0
- package/src/ui/data-display/code-block-highlight.tsx +54 -0
- package/src/ui/data-display/collapsible.tsx +42 -0
- package/src/ui/data-display/compact-stat-bar.tsx +149 -0
- package/src/ui/data-display/data-table/data-table-context.tsx +255 -0
- package/src/ui/data-display/data-table/data-table-empty-state.tsx +133 -0
- package/src/ui/data-display/data-table/data-table-skeleton.tsx +145 -0
- package/src/ui/data-display/data-table/data-table-toolbar.tsx +353 -0
- package/src/ui/data-display/data-table/data-table.tsx +597 -0
- package/src/ui/data-display/data-table/index.ts +44 -0
- package/src/ui/data-display/data-table-column-header.tsx +75 -0
- package/src/ui/data-display/data-table-pagination.tsx +130 -0
- package/src/ui/data-display/data-table-view-options.tsx +59 -0
- package/src/ui/data-display/formatted-number-input.tsx +210 -0
- package/src/ui/data-display/highlight.tsx +20 -0
- package/src/ui/data-display/hover-card.tsx +48 -0
- package/src/ui/data-display/index.tsx +50 -0
- package/src/ui/data-display/iphone-15-pro.tsx +114 -0
- package/src/ui/data-display/kanban/index.ts +4 -0
- package/src/ui/data-display/kanban/kanban-board.tsx +192 -0
- package/src/ui/data-display/kanban/kanban-column.tsx +74 -0
- package/src/ui/data-display/kanban/kanban-item.tsx +50 -0
- package/src/ui/data-display/kanban/kanban-types.ts +21 -0
- package/src/ui/data-display/kpi-card.tsx +68 -0
- package/src/ui/data-display/media-grid.tsx +110 -0
- package/src/ui/data-display/safari.tsx +175 -0
- package/src/ui/data-display/show-more-text.tsx +55 -0
- package/src/ui/data-display/tabs.tsx +68 -0
- package/src/ui/data-display/timeline.tsx +256 -0
- package/src/ui/feedback/alert.tsx +60 -0
- package/src/ui/feedback/context-menu.tsx +245 -0
- package/src/ui/feedback/drawer.tsx +132 -0
- package/src/ui/feedback/error-dialog.tsx +273 -0
- package/src/ui/feedback/index.tsx +183 -0
- package/src/ui/feedback/progress.tsx +32 -0
- package/src/ui/feedback/sheet.tsx +148 -0
- package/src/ui/feedback/sonner.tsx +36 -0
- package/src/ui/forms/command.tsx +157 -0
- package/src/ui/forms/date-picker.tsx +73 -0
- package/src/ui/forms/date-range-picker.tsx +76 -0
- package/src/ui/forms/date-time-picker.tsx +109 -0
- package/src/ui/forms/editor/editor-menu-bar.tsx +394 -0
- package/src/ui/forms/editor/index.tsx +130 -0
- package/src/ui/forms/editor/multi-select-example.tsx +1234 -0
- package/src/ui/forms/emoji-picker.tsx +109 -0
- package/src/ui/forms/file-dropzone.tsx +169 -0
- package/src/ui/forms/file-thumbnail.tsx +29 -0
- package/src/ui/forms/index.tsx +201 -0
- package/src/ui/forms/input-file.tsx +99 -0
- package/src/ui/forms/input-group.tsx +46 -0
- package/src/ui/forms/input-otp.tsx +81 -0
- package/src/ui/forms/input-phone.tsx +172 -0
- package/src/ui/forms/input-spin.tsx +116 -0
- package/src/ui/forms/input-tags.tsx +219 -0
- package/src/ui/forms/input-time.tsx +42 -0
- package/src/ui/forms/multi-select.tsx +629 -0
- package/src/ui/forms/multiple-date-picker.tsx +74 -0
- package/src/ui/forms/radio-group.tsx +42 -0
- package/src/ui/forms/rating.tsx +158 -0
- package/src/ui/forms/time-picker.tsx +57 -0
- package/src/ui/index.tsx +17 -0
- package/src/ui/layout/animated-list.tsx +77 -0
- package/src/ui/layout/animated-sidebar.tsx +294 -0
- package/src/ui/layout/command-menu.tsx +355 -0
- package/src/ui/layout/customizer.tsx +324 -0
- package/src/ui/layout/footer.tsx +43 -0
- package/src/ui/layout/full-screen-toggle.tsx +52 -0
- package/src/ui/layout/header-breadcrumb.tsx +77 -0
- package/src/ui/layout/horizontal-layout-header.tsx +83 -0
- package/src/ui/layout/horizontal-layout.tsx +50 -0
- package/src/ui/layout/index.tsx +25 -0
- package/src/ui/layout/language-dropdown.tsx +103 -0
- package/src/ui/layout/logo.tsx +63 -0
- package/src/ui/layout/main-layout.tsx +57 -0
- package/src/ui/layout/mode-dropdown.tsx +58 -0
- package/src/ui/layout/notification-dropdown.tsx +127 -0
- package/src/ui/layout/page-tabs.tsx +306 -0
- package/src/ui/layout/route-cache.tsx +214 -0
- package/src/ui/layout/sidebar-group-icon-menu.tsx +195 -0
- package/src/ui/layout/sidebar.tsx +279 -0
- package/src/ui/layout/tab-content-cache.tsx +201 -0
- package/src/ui/layout/tab-navigation-provider.tsx +536 -0
- package/src/ui/layout/toggle-mobile-sidebar.tsx +33 -0
- package/src/ui/layout/top-bar-header-menubar.tsx +412 -0
- package/src/ui/layout/user-dropdown.tsx +188 -0
- package/src/ui/layout/vertical-layout-header.tsx +65 -0
- package/src/ui/layout/vertical-layout.tsx +47 -0
- package/src/ui/management/audit-log-page.tsx +209 -0
- package/src/ui/management/cache-management.tsx +349 -0
- package/src/ui/management/index.ts +3 -0
- package/src/ui/management/job-management.tsx +308 -0
- package/src/ui/pages/not-found.tsx +30 -0
- package/src/ui/primitives/badge.tsx +66 -0
- package/src/ui/primitives/breadcrumb.tsx +103 -0
- package/src/ui/primitives/button.tsx +129 -0
- package/src/ui/primitives/calendar.tsx +74 -0
- package/src/ui/primitives/card.tsx +86 -0
- package/src/ui/primitives/checkbox.tsx +31 -0
- package/src/ui/primitives/client.ts +30 -0
- package/src/ui/primitives/combobox.tsx +290 -0
- package/src/ui/primitives/dialog.tsx +121 -0
- package/src/ui/primitives/dropdown-menu.tsx +239 -0
- package/src/ui/primitives/dynamic-icon.tsx +24 -0
- package/src/ui/primitives/index.tsx +134 -0
- package/src/ui/primitives/input-number.tsx +131 -0
- package/src/ui/primitives/input.tsx +22 -0
- package/src/ui/primitives/keyboard.tsx +23 -0
- package/src/ui/primitives/label.tsx +24 -0
- package/src/ui/primitives/menubar.tsx +262 -0
- package/src/ui/primitives/navigation-menu.tsx +157 -0
- package/src/ui/primitives/pagination.tsx +118 -0
- package/src/ui/primitives/popover.tsx +56 -0
- package/src/ui/primitives/prefetch-link.tsx +60 -0
- package/src/ui/primitives/resizable.tsx +59 -0
- package/src/ui/primitives/scroll-area.tsx +63 -0
- package/src/ui/primitives/select.tsx +172 -0
- package/src/ui/primitives/separator.tsx +51 -0
- package/src/ui/primitives/sidebar.tsx +844 -0
- package/src/ui/primitives/slider.tsx +27 -0
- package/src/ui/primitives/status-badge.tsx +47 -0
- package/src/ui/primitives/sticky-layout.tsx +50 -0
- package/src/ui/primitives/switch.tsx +29 -0
- package/src/ui/primitives/table.tsx +116 -0
- package/src/ui/primitives/tabs.tsx +55 -0
- package/src/ui/primitives/toggle-group.tsx +70 -0
- package/src/ui/primitives/toggle.tsx +47 -0
- package/src/ui/primitives/tooltip.tsx +59 -0
- package/src/user/components/dangerous-zone.tsx +34 -0
- package/src/user/components/delete-account-form.tsx +40 -0
- package/src/user/components/index.ts +4 -0
- package/src/user/components/profile-info-form.tsx +390 -0
- package/src/user/components/profile-info.tsx +32 -0
- package/src/user/components/unified-profile-dialog.tsx +1019 -0
- package/src/user/components/user-stats.tsx +27 -0
- package/src/user/components/user-toolbar.tsx +137 -0
- package/src/user/components/users-card-view.tsx +253 -0
- package/src/user/index.ts +11 -0
- package/src/user/pages/user-list-page.tsx +234 -0
- package/src/user/pages/users-client-page.tsx +385 -0
- package/src/user/profile-page.tsx +19 -0
- package/src/user/schemas.ts +68 -0
- package/src/user/types.ts +34 -0
- package/src/user/user-service.ts +538 -0
- package/src/utils/index.ts +906 -0
- package/src/workflow/activity-timeline.tsx +412 -0
- package/src/workflow/approval-workflow.tsx +31 -0
- package/src/workflow/index.ts +2 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { FilterX, Inbox, Search } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import type { EntityConfig } from "../../types";
|
|
6
|
+
|
|
7
|
+
import { Button } from "../../ui";
|
|
8
|
+
|
|
9
|
+
interface CrudEmptyStateProps {
|
|
10
|
+
config: EntityConfig;
|
|
11
|
+
hasSearch?: boolean;
|
|
12
|
+
hasFilters?: boolean;
|
|
13
|
+
onClearSearch?: () => void;
|
|
14
|
+
onClearFilters?: () => void;
|
|
15
|
+
onCreate?: () => void;
|
|
16
|
+
canCreate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function CrudEmptyState({
|
|
20
|
+
config,
|
|
21
|
+
hasSearch = false,
|
|
22
|
+
hasFilters = false,
|
|
23
|
+
onClearSearch,
|
|
24
|
+
onClearFilters,
|
|
25
|
+
onCreate,
|
|
26
|
+
canCreate = false,
|
|
27
|
+
}: CrudEmptyStateProps) {
|
|
28
|
+
const hasActiveFilters = hasSearch || hasFilters;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className="flex flex-col items-center justify-center py-16 sm:py-20 px-4"
|
|
33
|
+
role="status"
|
|
34
|
+
aria-live="polite"
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
className="rounded-full bg-muted/50 p-4 sm:p-5 mb-4 sm:mb-6 transition-all duration-300"
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
>
|
|
40
|
+
{hasActiveFilters ? (
|
|
41
|
+
<Search className="h-8 w-8 sm:h-10 sm:w-10 text-muted-foreground" />
|
|
42
|
+
) : (
|
|
43
|
+
<Inbox className="h-8 w-8 sm:h-10 sm:w-10 text-muted-foreground" />
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<h3 className="text-lg sm:text-xl font-semibold mb-2 sm:mb-3 text-center">
|
|
48
|
+
{hasActiveFilters
|
|
49
|
+
? "No results found"
|
|
50
|
+
: `No ${config.pluralLabel.toLowerCase()} yet`}
|
|
51
|
+
</h3>
|
|
52
|
+
|
|
53
|
+
<p className="text-sm sm:text-base text-muted-foreground text-center max-w-md mb-6 sm:mb-8 px-2">
|
|
54
|
+
{hasActiveFilters
|
|
55
|
+
? `We couldn't find any ${config.pluralLabel.toLowerCase()} matching your search or filters. Try adjusting your filters or search terms.`
|
|
56
|
+
: `Get started by creating your first ${config.label.toLowerCase()}.`}
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
<div className="flex items-center gap-2 sm:gap-3 flex-wrap justify-center w-full sm:w-auto">
|
|
60
|
+
{hasActiveFilters && (
|
|
61
|
+
<>
|
|
62
|
+
{hasSearch && onClearSearch && (
|
|
63
|
+
<Button
|
|
64
|
+
variant="outline"
|
|
65
|
+
size="sm"
|
|
66
|
+
onClick={onClearSearch}
|
|
67
|
+
className="gap-2 w-full sm:w-auto"
|
|
68
|
+
aria-label="Clear search"
|
|
69
|
+
>
|
|
70
|
+
<Search className="h-4 w-4" aria-hidden="true" />
|
|
71
|
+
<span className="hidden sm:inline">Clear search</span>
|
|
72
|
+
<span className="sm:hidden">Clear</span>
|
|
73
|
+
</Button>
|
|
74
|
+
)}
|
|
75
|
+
{hasFilters && onClearFilters && (
|
|
76
|
+
<Button
|
|
77
|
+
variant="outline"
|
|
78
|
+
size="sm"
|
|
79
|
+
onClick={onClearFilters}
|
|
80
|
+
className="gap-2 w-full sm:w-auto"
|
|
81
|
+
aria-label="Clear all filters"
|
|
82
|
+
>
|
|
83
|
+
<FilterX className="h-4 w-4" aria-hidden="true" />
|
|
84
|
+
<span className="hidden sm:inline">Clear filters</span>
|
|
85
|
+
<span className="sm:hidden">Clear</span>
|
|
86
|
+
</Button>
|
|
87
|
+
)}
|
|
88
|
+
</>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{!hasActiveFilters && canCreate && onCreate && (
|
|
92
|
+
<Button
|
|
93
|
+
onClick={onCreate}
|
|
94
|
+
size="sm"
|
|
95
|
+
className="w-full sm:w-auto"
|
|
96
|
+
aria-label={`Create new ${config.label.toLowerCase()}`}
|
|
97
|
+
>
|
|
98
|
+
Create {config.label}
|
|
99
|
+
</Button>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Download, ChevronDown } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import type { ActiveFilter, ExportOptions } from "../../types";
|
|
7
|
+
|
|
8
|
+
import { buildQueryString } from "../lib/crud-utils";
|
|
9
|
+
|
|
10
|
+
import { toast } from "sonner";
|
|
11
|
+
import { Button } from "../../ui";
|
|
12
|
+
import {
|
|
13
|
+
DropdownMenu,
|
|
14
|
+
DropdownMenuContent,
|
|
15
|
+
DropdownMenuItem,
|
|
16
|
+
DropdownMenuTrigger,
|
|
17
|
+
} from "../../ui/primitives/client";
|
|
18
|
+
|
|
19
|
+
interface CrudExportButtonProps {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
filters?: ActiveFilter[];
|
|
22
|
+
search?: string;
|
|
23
|
+
canExport?: boolean;
|
|
24
|
+
format?: ExportOptions["format"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function CrudExportButton({
|
|
28
|
+
endpoint,
|
|
29
|
+
filters = [],
|
|
30
|
+
search,
|
|
31
|
+
canExport = true,
|
|
32
|
+
}: CrudExportButtonProps) {
|
|
33
|
+
const [loading, setLoading] = useState(false);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if (!canExport) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const handleExport = async (scope: "current" | "all") => {
|
|
41
|
+
setLoading(true);
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// If scope is 'all', we ignore the current filters
|
|
45
|
+
const activeFilters = scope === "current" ? filters : undefined;
|
|
46
|
+
const activeSearch = scope === "current" ? search : undefined;
|
|
47
|
+
|
|
48
|
+
const queryParams = buildQueryString({
|
|
49
|
+
page: 1,
|
|
50
|
+
pageSize: 10000, // Large page size for export
|
|
51
|
+
filters:
|
|
52
|
+
activeFilters && activeFilters.length > 0 ? activeFilters : undefined,
|
|
53
|
+
search: activeSearch,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Always force format to xlsx
|
|
57
|
+
const url = `${endpoint}?${queryParams}&format=xlsx`;
|
|
58
|
+
|
|
59
|
+
const response = await fetch(url);
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
// Try to get error message from response
|
|
62
|
+
let errorMessage = "Export failed";
|
|
63
|
+
try {
|
|
64
|
+
const errorData = await response.json();
|
|
65
|
+
errorMessage = errorData.error || errorMessage;
|
|
66
|
+
} catch {
|
|
67
|
+
// If response is not JSON, use status text
|
|
68
|
+
errorMessage = `${response.status} ${response.statusText}`;
|
|
69
|
+
}
|
|
70
|
+
throw new Error(errorMessage);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const blob = await response.blob();
|
|
74
|
+
|
|
75
|
+
// Get filename from Content-Disposition header or use default
|
|
76
|
+
const contentDisposition = response.headers.get("Content-Disposition");
|
|
77
|
+
let filename = `export.xlsx`;
|
|
78
|
+
if (contentDisposition) {
|
|
79
|
+
// Parse filename from Content-Disposition header
|
|
80
|
+
// Format: attachment; filename="filename.ext" or attachment; filename=filename.ext
|
|
81
|
+
// Try multiple patterns to handle different formats
|
|
82
|
+
let filenameMatch = contentDisposition.match(
|
|
83
|
+
/filename\*?=['"]?([^'";\n]+)['"]?/i,
|
|
84
|
+
);
|
|
85
|
+
if (!filenameMatch) {
|
|
86
|
+
filenameMatch = contentDisposition.match(
|
|
87
|
+
/filename[^=]*=\s*['"]?([^'";\n]+)['"]?/i,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (filenameMatch && filenameMatch[1]) {
|
|
91
|
+
filename = filenameMatch[1].trim();
|
|
92
|
+
// Remove any trailing underscores, spaces, or quotes
|
|
93
|
+
filename = filename.replace(/[_\s"']+$/, "");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Ensure filename has correct extension
|
|
98
|
+
if (!filename.toLowerCase().endsWith(".xlsx")) {
|
|
99
|
+
filename = `${filename}.xlsx`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Download file
|
|
103
|
+
const downloadUrl = URL.createObjectURL(blob);
|
|
104
|
+
const link = document.createElement("a");
|
|
105
|
+
link.href = downloadUrl;
|
|
106
|
+
link.download = filename;
|
|
107
|
+
document.body.appendChild(link);
|
|
108
|
+
link.click();
|
|
109
|
+
document.body.removeChild(link);
|
|
110
|
+
|
|
111
|
+
// Delay revoke to ensure download completes
|
|
112
|
+
// Revoke after a short delay to allow browser to start download
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
URL.revokeObjectURL(downloadUrl);
|
|
115
|
+
}, 100);
|
|
116
|
+
|
|
117
|
+
toast.success("Export Successful", {
|
|
118
|
+
description: `File "${filename}" downloaded successfully`,
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("Export error:", error);
|
|
122
|
+
toast.error("Export Failed", {
|
|
123
|
+
description:
|
|
124
|
+
error instanceof Error ? error.message : "Please try again.",
|
|
125
|
+
});
|
|
126
|
+
} finally {
|
|
127
|
+
setLoading(false);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div className="flex items-center">
|
|
133
|
+
<Button
|
|
134
|
+
variant="outline"
|
|
135
|
+
size="sm"
|
|
136
|
+
disabled={loading}
|
|
137
|
+
className="rounded-r-none border-r-0"
|
|
138
|
+
onClick={() => handleExport("current")}
|
|
139
|
+
>
|
|
140
|
+
<Download className="mr-2 h-4 w-4" />
|
|
141
|
+
{loading ? "Exporting..." : "Export"}
|
|
142
|
+
</Button>
|
|
143
|
+
<DropdownMenu>
|
|
144
|
+
<DropdownMenuTrigger asChild>
|
|
145
|
+
<Button
|
|
146
|
+
variant="outline"
|
|
147
|
+
size="sm"
|
|
148
|
+
disabled={loading}
|
|
149
|
+
className="rounded-l-none px-2"
|
|
150
|
+
>
|
|
151
|
+
<ChevronDown className="h-4 w-4" />
|
|
152
|
+
</Button>
|
|
153
|
+
</DropdownMenuTrigger>
|
|
154
|
+
<DropdownMenuContent align="end">
|
|
155
|
+
<DropdownMenuItem onClick={() => handleExport("current")}>
|
|
156
|
+
Export Current View (XLSX)
|
|
157
|
+
{filters.length > 0 && (
|
|
158
|
+
<span className="ml-2 text-xs text-muted-foreground">
|
|
159
|
+
(Filtered)
|
|
160
|
+
</span>
|
|
161
|
+
)}
|
|
162
|
+
</DropdownMenuItem>
|
|
163
|
+
<DropdownMenuItem onClick={() => handleExport("all")}>
|
|
164
|
+
Export All Data (XLSX)
|
|
165
|
+
</DropdownMenuItem>
|
|
166
|
+
</DropdownMenuContent>
|
|
167
|
+
</DropdownMenu>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|