@jmruthers/pace-core 0.5.186 → 0.5.187
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/dist/{DataTable-Z9NLVJh0.d.ts → DataTable-IVYljGJ6.d.ts} +1 -1
- package/dist/{DataTable-IX2NBUTP.js → DataTable-K3RJRSOX.js} +7 -7
- package/dist/{PublicPageProvider-DIzEzwKl.d.ts → PublicPageProvider-DrLDztHt.d.ts} +211 -106
- package/dist/{UnifiedAuthProvider-A4BCQRJY.js → UnifiedAuthProvider-B76OWOAT.js} +2 -2
- package/dist/{api-BMFCXVQX.js → api-YP7XD5L6.js} +3 -3
- package/dist/{audit-WRS3KJKI.js → audit-B5P6FFIR.js} +2 -2
- package/dist/{chunk-445GEP27.js → chunk-3IC5WCMO.js} +33 -8
- package/dist/chunk-3IC5WCMO.js.map +1 -0
- package/dist/{chunk-OALXJH4Y.js → chunk-3NFNJOO7.js} +8 -8
- package/dist/chunk-3NFNJOO7.js.map +1 -0
- package/dist/{chunk-FSFQFJCU.js → chunk-63FOKYGO.js} +174 -6
- package/dist/chunk-63FOKYGO.js.map +1 -0
- package/dist/{chunk-TC7D3CR3.js → chunk-C4OYJOV4.js} +556 -101
- package/dist/chunk-C4OYJOV4.js.map +1 -0
- package/dist/{chunk-HGPQUCBC.js → chunk-FMTK4XNN.js} +3 -3
- package/dist/{chunk-U6WNSFX5.js → chunk-HEHYGYOX.js} +279 -44
- package/dist/chunk-HEHYGYOX.js.map +1 -0
- package/dist/{chunk-XAUHJD3L.js → chunk-K2JGDXGU.js} +2 -2
- package/dist/{chunk-HDCUMOOI.js → chunk-LBBUPSSC.js} +792 -559
- package/dist/chunk-LBBUPSSC.js.map +1 -0
- package/dist/{chunk-UQWSHFVX.js → chunk-SAUPYVLF.js} +1 -1
- package/dist/{chunk-UQWSHFVX.js.map → chunk-SAUPYVLF.js.map} +1 -1
- package/dist/{chunk-GRIQLQ52.js → chunk-T6ZJVI3A.js} +27 -23
- package/dist/chunk-T6ZJVI3A.js.map +1 -0
- package/dist/{chunk-DAGICKHT.js → chunk-ULX5FYEM.js} +3 -3
- package/dist/{chunk-FXFJRTKI.js → chunk-WK2Y6TGA.js} +3 -3
- package/dist/chunk-WK2Y6TGA.js.map +1 -0
- package/dist/chunk-YHCN776L.js +447 -0
- package/dist/chunk-YHCN776L.js.map +1 -0
- package/dist/components.d.ts +4 -4
- package/dist/components.js +12 -10
- package/dist/components.js.map +1 -1
- package/dist/{file-reference-PRTSLxKx.d.ts → file-reference-D037xOFK.d.ts} +0 -1
- package/dist/hooks.d.ts +221 -6
- package/dist/hooks.js +146 -49
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +24 -9
- package/dist/index.js +62 -28
- package/dist/index.js.map +1 -1
- package/dist/providers.js +1 -1
- package/dist/rbac/index.d.ts +124 -7
- package/dist/rbac/index.js +27 -7
- package/dist/{types-DUyCRSTj.d.ts → types-Bwgl--Xo.d.ts} +162 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/{usePublicRouteParams-D71QLlg4.d.ts → usePublicRouteParams-CTDELQ7H.d.ts} +2 -2
- package/dist/utils.d.ts +213 -3
- package/dist/utils.js +22 -2
- package/dist/utils.js.map +1 -1
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/Logger.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +21 -17
- package/docs/api/classes/RBACCache.md +31 -23
- package/docs/api/classes/RBACEngine.md +5 -5
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/enums/LogLevel.md +1 -1
- package/docs/api/enums/RBACErrorCode.md +1 -1
- package/docs/api/enums/RPCFunction.md +1 -1
- package/docs/api/interfaces/AddressFieldProps.md +241 -0
- package/docs/api/interfaces/AddressFieldRef.md +94 -0
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/AutocompleteOptions.md +75 -0
- package/docs/api/interfaces/BadgeProps.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CalendarProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/ComplianceResult.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/DatabaseComplianceResult.md +1 -1
- package/docs/api/interfaces/DatabaseIssue.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventAppRoleData.md +1 -1
- package/docs/api/interfaces/ExportColumn.md +1 -1
- package/docs/api/interfaces/ExportOptions.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +15 -15
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/FormFieldProps.md +1 -1
- package/docs/api/interfaces/FormProps.md +1 -1
- package/docs/api/interfaces/GrantEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoggerConfig.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +11 -11
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/ParsedAddress.md +120 -0
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/ProgressProps.md +1 -1
- package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/QuickFix.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
- package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
- package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +26 -3
- package/docs/api/interfaces/RBACContext.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +5 -5
- package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPerformanceMetrics.md +138 -0
- package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckResult.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
- package/docs/api/interfaces/RBACResult.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantParams.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeParams.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateParams.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
- package/docs/api/interfaces/RBACRolesListParams.md +1 -1
- package/docs/api/interfaces/RBACRolesListResult.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
- package/docs/api/interfaces/ResourcePermissions.md +1 -1
- package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RoleManagementResult.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/SetupIssue.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/TabsContentProps.md +1 -1
- package/docs/api/interfaces/TabsListProps.md +1 -1
- package/docs/api/interfaces/TabsProps.md +1 -1
- package/docs/api/interfaces/TabsTriggerProps.md +1 -1
- package/docs/api/interfaces/TextareaProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
- package/docs/api/interfaces/UseFormDialogReturn.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +318 -59
- package/docs/best-practices/performance.md +11 -0
- package/docs/implementation-guides/file-upload-storage.md +29 -0
- package/docs/rbac/README.md +2 -1
- package/docs/rbac/api-reference.md +11 -0
- package/docs/rbac/performance.md +320 -0
- package/docs/standards/01-architecture-standard.md +5 -0
- package/docs/standards/05-security-standard.md +12 -0
- package/package.json +1 -1
- package/src/components/AddressField/AddressField.test.tsx +411 -0
- package/src/components/AddressField/AddressField.tsx +323 -0
- package/src/components/AddressField/README.md +336 -0
- package/src/components/AddressField/index.ts +10 -0
- package/src/components/AddressField/types.ts +65 -0
- package/src/components/FileDisplay/FileDisplay.test.tsx +454 -0
- package/src/components/FileDisplay/FileDisplay.tsx +28 -1
- package/src/components/index.ts +2 -0
- package/src/hooks/__tests__/useFileDisplay.unit.test.ts +30 -5
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +11 -10
- package/src/hooks/__tests__/usePublicFileDisplay.test.ts +31 -6
- package/src/hooks/index.ts +6 -0
- package/src/hooks/public/usePublicFileDisplay.ts +8 -10
- package/src/hooks/useAddressAutocomplete.test.ts +318 -0
- package/src/hooks/useAddressAutocomplete.ts +268 -0
- package/src/hooks/useFileDisplay.ts +3 -15
- package/src/hooks/useFileReference.test.ts +20 -3
- package/src/hooks/useFileReference.ts +3 -24
- package/src/hooks/useFileUrlCache.ts +246 -0
- package/src/hooks/useInactivityTracker.ts +31 -20
- package/src/hooks/useOrganisationSecurity.test.ts +10 -7
- package/src/hooks/useOrganisationSecurity.ts +3 -3
- package/src/hooks/useQueryCache.ts +315 -0
- package/src/index.ts +2 -0
- package/src/providers/services/EventServiceProvider.tsx +4 -1
- package/src/rbac/api.test.ts +21 -6
- package/src/rbac/api.ts +32 -11
- package/src/rbac/audit-batched.ts +223 -0
- package/src/rbac/audit-enhanced.ts +2 -2
- package/src/rbac/audit.test.ts +6 -5
- package/src/rbac/audit.ts +34 -6
- package/src/rbac/cache-invalidation.ts +63 -12
- package/src/rbac/cache.test.ts +2 -2
- package/src/rbac/cache.ts +61 -14
- package/src/rbac/components/PagePermissionGuard.tsx +19 -10
- package/src/rbac/components/__tests__/PagePermissionGuard.performance.test.tsx +248 -0
- package/src/rbac/config.ts +9 -0
- package/src/rbac/engine.ts +2 -21
- package/src/rbac/hooks/usePermissions.ts +21 -5
- package/src/rbac/index.ts +19 -0
- package/src/rbac/performance.ts +210 -0
- package/src/rbac/request-deduplication.ts +87 -0
- package/src/rbac/utils/deep-equal.ts +93 -0
- package/src/types/file-reference.ts +0 -1
- package/src/utils/file-reference/__tests__/file-reference.test.ts +31 -4
- package/src/utils/file-reference/index.ts +44 -15
- package/src/utils/google-places/googlePlacesUtils.test.ts +403 -0
- package/src/utils/google-places/googlePlacesUtils.ts +475 -0
- package/src/utils/google-places/index.ts +26 -0
- package/src/utils/google-places/loadGoogleMapsScript.ts +207 -0
- package/src/utils/google-places/types.ts +94 -0
- package/src/utils/index.ts +23 -0
- package/src/utils/request-deduplication.ts +165 -0
- package/src/utils/storage/helpers.ts +143 -4
- package/dist/chunk-445GEP27.js.map +0 -1
- package/dist/chunk-FMUCXFII.js +0 -76
- package/dist/chunk-FMUCXFII.js.map +0 -1
- package/dist/chunk-FSFQFJCU.js.map +0 -1
- package/dist/chunk-FXFJRTKI.js.map +0 -1
- package/dist/chunk-GRIQLQ52.js.map +0 -1
- package/dist/chunk-HDCUMOOI.js.map +0 -1
- package/dist/chunk-OALXJH4Y.js.map +0 -1
- package/dist/chunk-TC7D3CR3.js.map +0 -1
- package/dist/chunk-U6WNSFX5.js.map +0 -1
- /package/dist/{DataTable-IX2NBUTP.js.map → DataTable-K3RJRSOX.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-A4BCQRJY.js.map → UnifiedAuthProvider-B76OWOAT.js.map} +0 -0
- /package/dist/{api-BMFCXVQX.js.map → api-YP7XD5L6.js.map} +0 -0
- /package/dist/{audit-WRS3KJKI.js.map → audit-B5P6FFIR.js.map} +0 -0
- /package/dist/{chunk-HGPQUCBC.js.map → chunk-FMTK4XNN.js.map} +0 -0
- /package/dist/{chunk-XAUHJD3L.js.map → chunk-K2JGDXGU.js.map} +0 -0
- /package/dist/{chunk-DAGICKHT.js.map → chunk-ULX5FYEM.js.map} +0 -0
|
@@ -25,42 +25,44 @@ import {
|
|
|
25
25
|
SelectSeparator,
|
|
26
26
|
SelectTrigger,
|
|
27
27
|
SelectValue
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FMTK4XNN.js";
|
|
29
29
|
import {
|
|
30
30
|
useCan,
|
|
31
31
|
usePermissions,
|
|
32
32
|
useRBAC,
|
|
33
33
|
useResolvedScope
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-3IC5WCMO.js";
|
|
35
35
|
import {
|
|
36
36
|
isSuperAdmin
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-HEHYGYOX.js";
|
|
38
38
|
import {
|
|
39
39
|
ErrorBoundary,
|
|
40
40
|
PublicPageContext,
|
|
41
41
|
createFileReferenceService,
|
|
42
|
+
generateFileUrlsBatch,
|
|
42
43
|
getPublicUrl,
|
|
43
44
|
getSignedUrl,
|
|
44
45
|
uploadFileWithReference,
|
|
46
|
+
useAddressAutocomplete,
|
|
45
47
|
useAppConfig,
|
|
46
48
|
useEventTheme,
|
|
47
49
|
useFileDisplay,
|
|
48
50
|
useIsPublicPage,
|
|
49
51
|
usePreventTabReload,
|
|
50
52
|
usePublicFileDisplay
|
|
51
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-C4OYJOV4.js";
|
|
52
54
|
import {
|
|
53
55
|
useToast
|
|
54
56
|
} from "./chunk-6C4YBBJM.js";
|
|
55
57
|
import {
|
|
56
58
|
useEvents,
|
|
57
59
|
useOrganisations
|
|
58
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-K2JGDXGU.js";
|
|
59
61
|
import {
|
|
60
62
|
EventServiceContext,
|
|
61
63
|
useSessionRestoration,
|
|
62
64
|
useUnifiedAuth
|
|
63
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-WK2Y6TGA.js";
|
|
64
66
|
import {
|
|
65
67
|
assertAppId
|
|
66
68
|
} from "./chunk-QXHPKYJV.js";
|
|
@@ -82,14 +84,240 @@ import {
|
|
|
82
84
|
logger
|
|
83
85
|
} from "./chunk-PWLANIRT.js";
|
|
84
86
|
|
|
85
|
-
// src/components/
|
|
87
|
+
// src/components/AddressField/AddressField.tsx
|
|
86
88
|
import * as React from "react";
|
|
89
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
90
|
+
var AddressField = React.forwardRef(
|
|
91
|
+
({
|
|
92
|
+
apiKey,
|
|
93
|
+
value: controlledValue,
|
|
94
|
+
defaultValue = "",
|
|
95
|
+
onChange,
|
|
96
|
+
onInputChange,
|
|
97
|
+
placeholder = "Enter address",
|
|
98
|
+
error,
|
|
99
|
+
disabled,
|
|
100
|
+
className,
|
|
101
|
+
size = "md",
|
|
102
|
+
variant = "default",
|
|
103
|
+
autocompleteOptions,
|
|
104
|
+
debounceDelay,
|
|
105
|
+
cacheEnabled = true,
|
|
106
|
+
cacheTTL,
|
|
107
|
+
...props
|
|
108
|
+
}, ref) => {
|
|
109
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
110
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
111
|
+
const [selectedIndex, setSelectedIndex] = React.useState(-1);
|
|
112
|
+
const [inputFocused, setInputFocused] = React.useState(false);
|
|
113
|
+
const inputRef = React.useRef(null);
|
|
114
|
+
const suggestionsRef = React.useRef(null);
|
|
115
|
+
const containerRef = React.useRef(null);
|
|
116
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
117
|
+
const { suggestions, isLoading, error: autocompleteError, selectAddress, clearSuggestions } = useAddressAutocomplete(apiKey, value, {
|
|
118
|
+
autocompleteOptions,
|
|
119
|
+
debounceDelay,
|
|
120
|
+
cacheEnabled,
|
|
121
|
+
cacheTTL
|
|
122
|
+
});
|
|
123
|
+
React.useEffect(() => {
|
|
124
|
+
if (suggestions.length > 0 && inputFocused && value.trim()) {
|
|
125
|
+
setIsOpen(true);
|
|
126
|
+
} else if (suggestions.length === 0 || !value.trim()) {
|
|
127
|
+
setIsOpen(false);
|
|
128
|
+
}
|
|
129
|
+
}, [suggestions, inputFocused, value]);
|
|
130
|
+
const handleInputChange = React.useCallback(
|
|
131
|
+
(e) => {
|
|
132
|
+
const newValue = e.target.value;
|
|
133
|
+
if (controlledValue === void 0) {
|
|
134
|
+
setInternalValue(newValue);
|
|
135
|
+
}
|
|
136
|
+
onInputChange?.(newValue);
|
|
137
|
+
setSelectedIndex(-1);
|
|
138
|
+
if (!newValue.trim()) {
|
|
139
|
+
onChange?.(null);
|
|
140
|
+
clearSuggestions();
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[controlledValue, onInputChange, onChange, clearSuggestions]
|
|
144
|
+
);
|
|
145
|
+
const handleSelectAddress = React.useCallback(
|
|
146
|
+
async (placeId) => {
|
|
147
|
+
setIsOpen(false);
|
|
148
|
+
setSelectedIndex(-1);
|
|
149
|
+
const address = await selectAddress(placeId);
|
|
150
|
+
if (address) {
|
|
151
|
+
const displayValue = address.full_address || "";
|
|
152
|
+
if (controlledValue === void 0) {
|
|
153
|
+
setInternalValue(displayValue);
|
|
154
|
+
}
|
|
155
|
+
onInputChange?.(displayValue);
|
|
156
|
+
onChange?.(address);
|
|
157
|
+
}
|
|
158
|
+
inputRef.current?.blur();
|
|
159
|
+
},
|
|
160
|
+
[selectAddress, onChange, onInputChange, controlledValue]
|
|
161
|
+
);
|
|
162
|
+
const handleKeyDown = React.useCallback(
|
|
163
|
+
(e) => {
|
|
164
|
+
if (!isOpen || suggestions.length === 0) {
|
|
165
|
+
if (e.key === "Escape") {
|
|
166
|
+
setIsOpen(false);
|
|
167
|
+
inputRef.current?.blur();
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
switch (e.key) {
|
|
172
|
+
case "ArrowDown":
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
setSelectedIndex((prev) => prev < suggestions.length - 1 ? prev + 1 : prev);
|
|
175
|
+
break;
|
|
176
|
+
case "ArrowUp":
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
setSelectedIndex((prev) => prev > 0 ? prev - 1 : -1);
|
|
179
|
+
break;
|
|
180
|
+
case "Enter":
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
if (selectedIndex >= 0 && selectedIndex < suggestions.length) {
|
|
183
|
+
handleSelectAddress(suggestions[selectedIndex].place_id);
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
case "Escape":
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
setIsOpen(false);
|
|
189
|
+
setSelectedIndex(-1);
|
|
190
|
+
inputRef.current?.blur();
|
|
191
|
+
break;
|
|
192
|
+
case "Tab":
|
|
193
|
+
setIsOpen(false);
|
|
194
|
+
setSelectedIndex(-1);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
[isOpen, suggestions, selectedIndex, handleSelectAddress]
|
|
199
|
+
);
|
|
200
|
+
const handleFocus = React.useCallback(() => {
|
|
201
|
+
setInputFocused(true);
|
|
202
|
+
if (suggestions.length > 0 && value.trim()) {
|
|
203
|
+
setIsOpen(true);
|
|
204
|
+
}
|
|
205
|
+
}, [suggestions, value]);
|
|
206
|
+
const handleBlur = React.useCallback(
|
|
207
|
+
(e) => {
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
if (!containerRef.current?.contains(document.activeElement)) {
|
|
210
|
+
setInputFocused(false);
|
|
211
|
+
setIsOpen(false);
|
|
212
|
+
setSelectedIndex(-1);
|
|
213
|
+
}
|
|
214
|
+
}, 200);
|
|
215
|
+
},
|
|
216
|
+
[]
|
|
217
|
+
);
|
|
218
|
+
React.useEffect(() => {
|
|
219
|
+
const handleClickOutside = (event) => {
|
|
220
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
221
|
+
setIsOpen(false);
|
|
222
|
+
setSelectedIndex(-1);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
if (isOpen) {
|
|
226
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
227
|
+
return () => {
|
|
228
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}, [isOpen]);
|
|
232
|
+
React.useEffect(() => {
|
|
233
|
+
if (selectedIndex >= 0 && suggestionsRef.current) {
|
|
234
|
+
const selectedItem = suggestionsRef.current.children[selectedIndex];
|
|
235
|
+
if (selectedItem && typeof selectedItem.scrollIntoView === "function") {
|
|
236
|
+
selectedItem.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, [selectedIndex]);
|
|
240
|
+
React.useImperativeHandle(ref, () => inputRef.current);
|
|
241
|
+
const suggestionsId = React.useId();
|
|
242
|
+
const hasError = error || !!autocompleteError;
|
|
243
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: cn("relative w-full", className), children: [
|
|
244
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
245
|
+
/* @__PURE__ */ jsx(
|
|
246
|
+
Input,
|
|
247
|
+
{
|
|
248
|
+
ref: inputRef,
|
|
249
|
+
type: "text",
|
|
250
|
+
value,
|
|
251
|
+
onChange: handleInputChange,
|
|
252
|
+
onKeyDown: handleKeyDown,
|
|
253
|
+
onFocus: handleFocus,
|
|
254
|
+
onBlur: handleBlur,
|
|
255
|
+
placeholder,
|
|
256
|
+
disabled,
|
|
257
|
+
error: hasError,
|
|
258
|
+
size,
|
|
259
|
+
variant,
|
|
260
|
+
role: "combobox",
|
|
261
|
+
"aria-expanded": isOpen,
|
|
262
|
+
"aria-autocomplete": "list",
|
|
263
|
+
"aria-controls": suggestionsId,
|
|
264
|
+
"aria-haspopup": "listbox",
|
|
265
|
+
"aria-activedescendant": selectedIndex >= 0 ? `${suggestionsId}-item-${selectedIndex}` : void 0,
|
|
266
|
+
...props
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
isLoading && /* @__PURE__ */ jsx("div", { className: "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsx(LoadingSpinner, { size: "sm" }) })
|
|
270
|
+
] }),
|
|
271
|
+
isOpen && suggestions.length > 0 && /* @__PURE__ */ jsx(
|
|
272
|
+
"ul",
|
|
273
|
+
{
|
|
274
|
+
ref: suggestionsRef,
|
|
275
|
+
id: suggestionsId,
|
|
276
|
+
role: "listbox",
|
|
277
|
+
className: cn(
|
|
278
|
+
"absolute z-[99999] w-full mt-1 max-h-60 overflow-y-auto",
|
|
279
|
+
"border border-main-300 bg-main-50 shadow-lg rounded-md",
|
|
280
|
+
"list-none p-0 m-0"
|
|
281
|
+
),
|
|
282
|
+
"data-testid": "address-suggestions",
|
|
283
|
+
children: suggestions.map((suggestion, index) => /* @__PURE__ */ jsxs(
|
|
284
|
+
"li",
|
|
285
|
+
{
|
|
286
|
+
id: `${suggestionsId}-item-${index}`,
|
|
287
|
+
role: "option",
|
|
288
|
+
"aria-selected": selectedIndex === index,
|
|
289
|
+
className: cn(
|
|
290
|
+
"px-3 py-2 cursor-pointer text-sm",
|
|
291
|
+
"hover:bg-main-100 focus:bg-main-100",
|
|
292
|
+
"border-b border-main-200 last:border-b-0",
|
|
293
|
+
selectedIndex === index && "bg-main-100"
|
|
294
|
+
),
|
|
295
|
+
onClick: () => handleSelectAddress(suggestion.place_id),
|
|
296
|
+
onMouseEnter: () => setSelectedIndex(index),
|
|
297
|
+
"data-testid": `address-suggestion-${index}`,
|
|
298
|
+
children: [
|
|
299
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-main-900", children: suggestion.structured_formatting?.main_text || suggestion.description }),
|
|
300
|
+
suggestion.structured_formatting?.secondary_text && /* @__PURE__ */ jsx("div", { className: "text-xs text-main-600 mt-0.5", children: suggestion.structured_formatting.secondary_text })
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
suggestion.place_id
|
|
304
|
+
))
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
autocompleteError && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-destructive", role: "alert", children: autocompleteError.message })
|
|
308
|
+
] });
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
AddressField.displayName = "AddressField";
|
|
312
|
+
|
|
313
|
+
// src/components/Label/Label.tsx
|
|
314
|
+
import * as React2 from "react";
|
|
87
315
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
88
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
316
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
317
|
var getLabelClasses = () => {
|
|
90
318
|
return "font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70";
|
|
91
319
|
};
|
|
92
|
-
var Label =
|
|
320
|
+
var Label = React2.forwardRef(({
|
|
93
321
|
className,
|
|
94
322
|
required = false,
|
|
95
323
|
requiredIndicator,
|
|
@@ -104,8 +332,8 @@ var Label = React.forwardRef(({
|
|
|
104
332
|
}, ref) => {
|
|
105
333
|
const hasError = !!error;
|
|
106
334
|
const showHelperText = helperText && !hasError;
|
|
107
|
-
return /* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
335
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
336
|
+
/* @__PURE__ */ jsxs2(
|
|
109
337
|
LabelPrimitive.Root,
|
|
110
338
|
{
|
|
111
339
|
ref,
|
|
@@ -118,7 +346,7 @@ var Label = React.forwardRef(({
|
|
|
118
346
|
...props,
|
|
119
347
|
children: [
|
|
120
348
|
children,
|
|
121
|
-
required && /* @__PURE__ */
|
|
349
|
+
required && /* @__PURE__ */ jsx2(
|
|
122
350
|
"span",
|
|
123
351
|
{
|
|
124
352
|
"aria-label": "required",
|
|
@@ -132,8 +360,8 @@ var Label = React.forwardRef(({
|
|
|
132
360
|
]
|
|
133
361
|
}
|
|
134
362
|
),
|
|
135
|
-
showHelperText && /* @__PURE__ */
|
|
136
|
-
hasError && /* @__PURE__ */
|
|
363
|
+
showHelperText && /* @__PURE__ */ jsx2("p", { className: cn("text-muted-foreground", helperTextClassName), children: helperText }),
|
|
364
|
+
hasError && /* @__PURE__ */ jsx2(
|
|
137
365
|
"p",
|
|
138
366
|
{
|
|
139
367
|
role: "alert",
|
|
@@ -147,11 +375,11 @@ var Label = React.forwardRef(({
|
|
|
147
375
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
148
376
|
|
|
149
377
|
// src/components/Textarea/Textarea.tsx
|
|
150
|
-
import * as
|
|
151
|
-
import { jsx as
|
|
152
|
-
var Textarea =
|
|
378
|
+
import * as React3 from "react";
|
|
379
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
380
|
+
var Textarea = React3.forwardRef(
|
|
153
381
|
({ className, variant = "default", size = "md", error, ...props }, ref) => {
|
|
154
|
-
return /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ jsx3(
|
|
155
383
|
"textarea",
|
|
156
384
|
{
|
|
157
385
|
className: cn(
|
|
@@ -179,10 +407,10 @@ var Textarea = React2.forwardRef(
|
|
|
179
407
|
Textarea.displayName = "Textarea";
|
|
180
408
|
|
|
181
409
|
// src/components/Avatar/Avatar.tsx
|
|
182
|
-
import * as
|
|
410
|
+
import * as React4 from "react";
|
|
183
411
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
184
|
-
import { jsx as
|
|
185
|
-
var Avatar =
|
|
412
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
413
|
+
var Avatar = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
186
414
|
AvatarPrimitive.Root,
|
|
187
415
|
{
|
|
188
416
|
ref,
|
|
@@ -194,7 +422,7 @@ var Avatar = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
194
422
|
}
|
|
195
423
|
));
|
|
196
424
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
197
|
-
var AvatarImage =
|
|
425
|
+
var AvatarImage = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
198
426
|
AvatarPrimitive.Image,
|
|
199
427
|
{
|
|
200
428
|
ref,
|
|
@@ -203,7 +431,7 @@ var AvatarImage = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
203
431
|
}
|
|
204
432
|
));
|
|
205
433
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
206
|
-
var AvatarFallback =
|
|
434
|
+
var AvatarFallback = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
207
435
|
AvatarPrimitive.Fallback,
|
|
208
436
|
{
|
|
209
437
|
ref,
|
|
@@ -217,8 +445,8 @@ var AvatarFallback = React3.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
217
445
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
218
446
|
|
|
219
447
|
// src/components/Badge/Badge.tsx
|
|
220
|
-
import * as
|
|
221
|
-
import { jsx as
|
|
448
|
+
import * as React5 from "react";
|
|
449
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
222
450
|
var shadeConfig = {
|
|
223
451
|
muted: {
|
|
224
452
|
bg: 200,
|
|
@@ -283,7 +511,7 @@ function getBadgeClasses(variant = "solid-main-normal") {
|
|
|
283
511
|
const baseClasses = "text-balance rounded-2xl px-3 py-1 mr-1 text-xs font-medium transition-colors box-border";
|
|
284
512
|
return `${baseClasses} ${variantClassesMap[variant]}`;
|
|
285
513
|
}
|
|
286
|
-
var Badge =
|
|
514
|
+
var Badge = React5.forwardRef(
|
|
287
515
|
({ className, variant = "solid-main-normal", ...props }, ref) => {
|
|
288
516
|
const isSoftVariant = variant.startsWith("soft-");
|
|
289
517
|
if (isSoftVariant) {
|
|
@@ -293,7 +521,7 @@ var Badge = React4.forwardRef(
|
|
|
293
521
|
const classesWithoutShadows = variantClasses.replace(/\bshadow-badge-soft\b/g, "").replace(/\bshadow-\w+-\d+\b/g, "").replace(/\s+/g, " ").trim();
|
|
294
522
|
const mergedClasses = cn(classesWithoutShadows, className);
|
|
295
523
|
const finalClasses = `${mergedClasses} shadow-badge-soft ${shadowColorClass}`.trim();
|
|
296
|
-
return /* @__PURE__ */
|
|
524
|
+
return /* @__PURE__ */ jsx5(
|
|
297
525
|
"span",
|
|
298
526
|
{
|
|
299
527
|
ref,
|
|
@@ -302,7 +530,7 @@ var Badge = React4.forwardRef(
|
|
|
302
530
|
}
|
|
303
531
|
);
|
|
304
532
|
}
|
|
305
|
-
return /* @__PURE__ */
|
|
533
|
+
return /* @__PURE__ */ jsx5(
|
|
306
534
|
"span",
|
|
307
535
|
{
|
|
308
536
|
ref,
|
|
@@ -315,10 +543,10 @@ var Badge = React4.forwardRef(
|
|
|
315
543
|
Badge.displayName = "Badge";
|
|
316
544
|
|
|
317
545
|
// src/components/Switch/Switch.tsx
|
|
318
|
-
import * as
|
|
546
|
+
import * as React6 from "react";
|
|
319
547
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
320
|
-
import { jsx as
|
|
321
|
-
var Switch =
|
|
548
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
549
|
+
var Switch = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
|
|
322
550
|
SwitchPrimitive.Root,
|
|
323
551
|
{
|
|
324
552
|
className: cn(
|
|
@@ -340,7 +568,7 @@ var Switch = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
340
568
|
),
|
|
341
569
|
...props,
|
|
342
570
|
ref,
|
|
343
|
-
children: /* @__PURE__ */
|
|
571
|
+
children: /* @__PURE__ */ jsx6(
|
|
344
572
|
SwitchPrimitive.Thumb,
|
|
345
573
|
{
|
|
346
574
|
className: cn(
|
|
@@ -361,12 +589,12 @@ var Switch = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
361
589
|
Switch.displayName = SwitchPrimitive.Root.displayName;
|
|
362
590
|
|
|
363
591
|
// src/components/Tabs/Tabs.tsx
|
|
364
|
-
import * as
|
|
592
|
+
import * as React7 from "react";
|
|
365
593
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
366
|
-
import { jsx as
|
|
367
|
-
var Tabs =
|
|
594
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
595
|
+
var Tabs = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7(TabsPrimitive.Root, { asChild: true, ...props, children: /* @__PURE__ */ jsx7("section", { ref, className, children }) }));
|
|
368
596
|
Tabs.displayName = TabsPrimitive.Root.displayName || "Tabs";
|
|
369
|
-
var TabsList =
|
|
597
|
+
var TabsList = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7(TabsPrimitive.List, { asChild: true, ...props, children: /* @__PURE__ */ jsx7(
|
|
370
598
|
"nav",
|
|
371
599
|
{
|
|
372
600
|
ref,
|
|
@@ -378,8 +606,8 @@ var TabsList = React6.forwardRef(({ className, children, ...props }, ref) => /*
|
|
|
378
606
|
}
|
|
379
607
|
) }));
|
|
380
608
|
TabsList.displayName = TabsPrimitive.List.displayName || "TabsList";
|
|
381
|
-
var TabsTrigger =
|
|
382
|
-
return /* @__PURE__ */
|
|
609
|
+
var TabsTrigger = React7.forwardRef(({ className, variant, size, children, ...props }, ref) => {
|
|
610
|
+
return /* @__PURE__ */ jsx7(TabsPrimitive.Trigger, { asChild: true, ...props, children: /* @__PURE__ */ jsx7(
|
|
383
611
|
Button,
|
|
384
612
|
{
|
|
385
613
|
ref,
|
|
@@ -397,7 +625,7 @@ var TabsTrigger = React6.forwardRef(({ className, variant, size, children, ...pr
|
|
|
397
625
|
) });
|
|
398
626
|
});
|
|
399
627
|
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName || "TabsTrigger";
|
|
400
|
-
var TabsContent =
|
|
628
|
+
var TabsContent = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7(TabsPrimitive.Content, { asChild: true, ...props, children: /* @__PURE__ */ jsx7(
|
|
401
629
|
"aside",
|
|
402
630
|
{
|
|
403
631
|
ref,
|
|
@@ -411,13 +639,13 @@ var TabsContent = React6.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
411
639
|
TabsContent.displayName = TabsPrimitive.Content.displayName || "TabsContent";
|
|
412
640
|
|
|
413
641
|
// src/components/Calendar/Calendar.tsx
|
|
414
|
-
import * as
|
|
642
|
+
import * as React8 from "react";
|
|
415
643
|
import { DayPicker } from "react-day-picker";
|
|
416
|
-
import { jsx as
|
|
417
|
-
var Calendar =
|
|
644
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
645
|
+
var Calendar = React8.forwardRef(
|
|
418
646
|
({ className, classNames, mode, components, ...props }, ref) => {
|
|
419
647
|
const defaultComponents = {
|
|
420
|
-
IconLeft: ({ ...iconProps }) => /* @__PURE__ */
|
|
648
|
+
IconLeft: ({ ...iconProps }) => /* @__PURE__ */ jsx8(
|
|
421
649
|
"svg",
|
|
422
650
|
{
|
|
423
651
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -429,10 +657,10 @@ var Calendar = React7.forwardRef(
|
|
|
429
657
|
strokeLinejoin: "round",
|
|
430
658
|
className: "h-4 w-4",
|
|
431
659
|
...iconProps,
|
|
432
|
-
children: /* @__PURE__ */
|
|
660
|
+
children: /* @__PURE__ */ jsx8("path", { d: "m15 18-6-6 6-6" })
|
|
433
661
|
}
|
|
434
662
|
),
|
|
435
|
-
IconRight: ({ ...iconProps }) => /* @__PURE__ */
|
|
663
|
+
IconRight: ({ ...iconProps }) => /* @__PURE__ */ jsx8(
|
|
436
664
|
"svg",
|
|
437
665
|
{
|
|
438
666
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -444,12 +672,12 @@ var Calendar = React7.forwardRef(
|
|
|
444
672
|
strokeLinejoin: "round",
|
|
445
673
|
className: "h-4 w-4",
|
|
446
674
|
...iconProps,
|
|
447
|
-
children: /* @__PURE__ */
|
|
675
|
+
children: /* @__PURE__ */ jsx8("path", { d: "m9 18 6-6-6-6" })
|
|
448
676
|
}
|
|
449
677
|
),
|
|
450
678
|
...components
|
|
451
679
|
};
|
|
452
|
-
return /* @__PURE__ */
|
|
680
|
+
return /* @__PURE__ */ jsx8("div", { ref, className: cn("p-3", className), children: /* @__PURE__ */ jsx8(
|
|
453
681
|
DayPicker,
|
|
454
682
|
{
|
|
455
683
|
...mode ? { mode } : {},
|
|
@@ -497,12 +725,12 @@ var Calendar = React7.forwardRef(
|
|
|
497
725
|
Calendar.displayName = "Calendar";
|
|
498
726
|
|
|
499
727
|
// src/components/Toast/Toast.tsx
|
|
500
|
-
import * as
|
|
728
|
+
import * as React9 from "react";
|
|
501
729
|
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
502
730
|
import { X } from "lucide-react";
|
|
503
|
-
import { jsx as
|
|
731
|
+
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
504
732
|
var ToastProvider = ToastPrimitives.Provider;
|
|
505
|
-
var ToastViewport =
|
|
733
|
+
var ToastViewport = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
506
734
|
ToastPrimitives.Viewport,
|
|
507
735
|
{
|
|
508
736
|
ref,
|
|
@@ -515,8 +743,8 @@ var ToastViewport = React8.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
515
743
|
}
|
|
516
744
|
));
|
|
517
745
|
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
518
|
-
var Toast =
|
|
519
|
-
return /* @__PURE__ */
|
|
746
|
+
var Toast = React9.forwardRef(({ className, ...props }, ref) => {
|
|
747
|
+
return /* @__PURE__ */ jsx9(
|
|
520
748
|
ToastPrimitives.Root,
|
|
521
749
|
{
|
|
522
750
|
ref,
|
|
@@ -530,7 +758,7 @@ var Toast = React8.forwardRef(({ className, ...props }, ref) => {
|
|
|
530
758
|
);
|
|
531
759
|
});
|
|
532
760
|
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
533
|
-
var ToastAction =
|
|
761
|
+
var ToastAction = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
534
762
|
ToastPrimitives.Action,
|
|
535
763
|
{
|
|
536
764
|
ref,
|
|
@@ -543,7 +771,7 @@ var ToastAction = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
543
771
|
}
|
|
544
772
|
));
|
|
545
773
|
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
546
|
-
var ToastClose =
|
|
774
|
+
var ToastClose = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
547
775
|
ToastPrimitives.Close,
|
|
548
776
|
{
|
|
549
777
|
ref,
|
|
@@ -554,11 +782,11 @@ var ToastClose = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
554
782
|
),
|
|
555
783
|
"toast-close": "",
|
|
556
784
|
...props,
|
|
557
|
-
children: /* @__PURE__ */
|
|
785
|
+
children: /* @__PURE__ */ jsx9(X, { className: "h-4 w-4" })
|
|
558
786
|
}
|
|
559
787
|
));
|
|
560
788
|
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
561
|
-
var ToastTitle =
|
|
789
|
+
var ToastTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
562
790
|
ToastPrimitives.Title,
|
|
563
791
|
{
|
|
564
792
|
ref,
|
|
@@ -568,7 +796,7 @@ var ToastTitle = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
568
796
|
}
|
|
569
797
|
));
|
|
570
798
|
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
571
|
-
var ToastDescription =
|
|
799
|
+
var ToastDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
572
800
|
ToastPrimitives.Description,
|
|
573
801
|
{
|
|
574
802
|
ref,
|
|
@@ -580,15 +808,15 @@ var ToastDescription = React8.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
580
808
|
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
581
809
|
function Toaster() {
|
|
582
810
|
const { toasts } = useToast();
|
|
583
|
-
return /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
811
|
+
return /* @__PURE__ */ jsxs3(ToastProvider, { "data-testid": "toast-provider", children: [
|
|
812
|
+
/* @__PURE__ */ jsx9(ToastViewport, {}),
|
|
585
813
|
toasts.map((toast) => {
|
|
586
814
|
const { id, title, description, action, dismiss, duration, ...toastProps } = toast;
|
|
587
|
-
return /* @__PURE__ */
|
|
588
|
-
title && /* @__PURE__ */
|
|
589
|
-
description && /* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ jsxs3(Toast, { ...toastProps, duration, children: [
|
|
816
|
+
title && /* @__PURE__ */ jsx9(ToastTitle, { children: title }),
|
|
817
|
+
description && /* @__PURE__ */ jsx9(ToastDescription, { children: description }),
|
|
590
818
|
action && action,
|
|
591
|
-
/* @__PURE__ */
|
|
819
|
+
/* @__PURE__ */ jsx9(ToastClose, { onClick: dismiss })
|
|
592
820
|
] }, id);
|
|
593
821
|
})
|
|
594
822
|
] });
|
|
@@ -597,7 +825,7 @@ function Toaster() {
|
|
|
597
825
|
// src/components/Form/Form.tsx
|
|
598
826
|
import { useForm, FormProvider, useFormContext, Controller } from "react-hook-form";
|
|
599
827
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
600
|
-
import { jsx as
|
|
828
|
+
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
601
829
|
function Form({
|
|
602
830
|
schema,
|
|
603
831
|
defaultValues,
|
|
@@ -613,7 +841,7 @@ function Form({
|
|
|
613
841
|
mode
|
|
614
842
|
});
|
|
615
843
|
const handleSubmit = methods.handleSubmit(onSubmit, onError);
|
|
616
|
-
return /* @__PURE__ */
|
|
844
|
+
return /* @__PURE__ */ jsx10(FormProvider, { ...methods, children: /* @__PURE__ */ jsx10("form", { onSubmit: handleSubmit, className: cn("space-y-4", className), children: typeof children === "function" ? children(methods) : children }) });
|
|
617
845
|
}
|
|
618
846
|
function FormField({
|
|
619
847
|
name,
|
|
@@ -629,12 +857,12 @@ function FormField({
|
|
|
629
857
|
const { control, formState: { errors } } = useFormContext();
|
|
630
858
|
const fieldError = errors[name];
|
|
631
859
|
const errorMessage = fieldError && typeof fieldError === "object" && "message" in fieldError ? String(fieldError.message) : void 0;
|
|
632
|
-
return /* @__PURE__ */
|
|
633
|
-
label && /* @__PURE__ */
|
|
860
|
+
return /* @__PURE__ */ jsxs4("div", { className: cn("space-y-2", className), children: [
|
|
861
|
+
label && /* @__PURE__ */ jsxs4(Label, { htmlFor: name, children: [
|
|
634
862
|
label,
|
|
635
|
-
validation?.required && /* @__PURE__ */
|
|
863
|
+
validation?.required && /* @__PURE__ */ jsx10("span", { className: "text-destructive ml-1", "aria-label": "required", children: "*" })
|
|
636
864
|
] }),
|
|
637
|
-
/* @__PURE__ */
|
|
865
|
+
/* @__PURE__ */ jsx10(
|
|
638
866
|
Controller,
|
|
639
867
|
{
|
|
640
868
|
name,
|
|
@@ -644,7 +872,7 @@ function FormField({
|
|
|
644
872
|
if (render) {
|
|
645
873
|
return render(props);
|
|
646
874
|
}
|
|
647
|
-
return /* @__PURE__ */
|
|
875
|
+
return /* @__PURE__ */ jsx10(
|
|
648
876
|
"input",
|
|
649
877
|
{
|
|
650
878
|
...props.field,
|
|
@@ -662,14 +890,14 @@ function FormField({
|
|
|
662
890
|
}
|
|
663
891
|
}
|
|
664
892
|
),
|
|
665
|
-
errorMessage && /* @__PURE__ */
|
|
893
|
+
errorMessage && /* @__PURE__ */ jsx10("p", { className: "text-destructive", role: "alert", children: errorMessage })
|
|
666
894
|
] });
|
|
667
895
|
}
|
|
668
896
|
|
|
669
897
|
// src/components/LoginForm/LoginForm.tsx
|
|
670
|
-
import
|
|
671
|
-
import { jsx as
|
|
672
|
-
var LoginForm =
|
|
898
|
+
import React10, { useState as useState2, useCallback as useCallback2, useMemo } from "react";
|
|
899
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
900
|
+
var LoginForm = React10.memo(({
|
|
673
901
|
onSignIn,
|
|
674
902
|
onSuccess,
|
|
675
903
|
onError,
|
|
@@ -681,18 +909,18 @@ var LoginForm = React9.memo(({
|
|
|
681
909
|
onSignUp,
|
|
682
910
|
className
|
|
683
911
|
}) => {
|
|
684
|
-
const [formData, setFormData] =
|
|
685
|
-
const [error, setError] =
|
|
912
|
+
const [formData, setFormData] = useState2({ email: "", password: "" });
|
|
913
|
+
const [error, setError] = useState2(null);
|
|
686
914
|
const isFormValid = useMemo(() => {
|
|
687
915
|
return formData.email.length > 0 && formData.password.length > 0;
|
|
688
916
|
}, [formData.email, formData.password]);
|
|
689
|
-
const handleEmailChange =
|
|
917
|
+
const handleEmailChange = useCallback2((e) => {
|
|
690
918
|
setFormData((prev) => ({ ...prev, email: e.target.value }));
|
|
691
919
|
}, []);
|
|
692
|
-
const handlePasswordChange =
|
|
920
|
+
const handlePasswordChange = useCallback2((e) => {
|
|
693
921
|
setFormData((prev) => ({ ...prev, password: e.target.value }));
|
|
694
922
|
}, []);
|
|
695
|
-
const handleSubmit =
|
|
923
|
+
const handleSubmit = useCallback2(async (e) => {
|
|
696
924
|
e.preventDefault();
|
|
697
925
|
setError(null);
|
|
698
926
|
if (!isFormValid || isLoading) return;
|
|
@@ -705,20 +933,20 @@ var LoginForm = React9.memo(({
|
|
|
705
933
|
onError?.(err instanceof Error ? err : new Error(errorMessage));
|
|
706
934
|
}
|
|
707
935
|
}, [formData, isFormValid, isLoading, onSignIn, onSuccess, onError]);
|
|
708
|
-
const handleSignUpClick =
|
|
936
|
+
const handleSignUpClick = useCallback2(() => {
|
|
709
937
|
onSignUp?.();
|
|
710
938
|
}, [onSignUp]);
|
|
711
939
|
const displayTitle = useMemo(() => title || (appName ? `Sign in to ${appName}` : "Sign In"), [title, appName]);
|
|
712
940
|
const displaySubtitle = useMemo(() => subtitle || "Enter your credentials to continue.", [subtitle]);
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
/* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ jsx11(Card, { className: cn("w-full max-w-md mx-auto", className), children: /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, "data-testid": "login-form", children: [
|
|
942
|
+
/* @__PURE__ */ jsxs5(CardHeader, { className: "space-y-1", children: [
|
|
943
|
+
/* @__PURE__ */ jsx11(CardTitle, { className: "text-2xl text-center", children: displayTitle }),
|
|
944
|
+
/* @__PURE__ */ jsx11(CardDescription, { className: "text-center", children: displaySubtitle })
|
|
717
945
|
] }),
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
error && /* @__PURE__ */
|
|
720
|
-
/* @__PURE__ */
|
|
721
|
-
/* @__PURE__ */
|
|
946
|
+
/* @__PURE__ */ jsxs5(CardContent, { className: "space-y-4", children: [
|
|
947
|
+
error && /* @__PURE__ */ jsx11(Alert, { variant: "destructive", role: "alert", "aria-live": "assertive", children: /* @__PURE__ */ jsx11(AlertDescription, { children: error }) }),
|
|
948
|
+
/* @__PURE__ */ jsx11(Label, { htmlFor: "email", children: "Email" }),
|
|
949
|
+
/* @__PURE__ */ jsx11(
|
|
722
950
|
Input,
|
|
723
951
|
{
|
|
724
952
|
id: "email",
|
|
@@ -730,8 +958,8 @@ var LoginForm = React9.memo(({
|
|
|
730
958
|
disabled: isLoading
|
|
731
959
|
}
|
|
732
960
|
),
|
|
733
|
-
/* @__PURE__ */
|
|
734
|
-
/* @__PURE__ */
|
|
961
|
+
/* @__PURE__ */ jsx11(Label, { htmlFor: "password", children: "Password" }),
|
|
962
|
+
/* @__PURE__ */ jsx11(
|
|
735
963
|
Input,
|
|
736
964
|
{
|
|
737
965
|
id: "password",
|
|
@@ -744,8 +972,8 @@ var LoginForm = React9.memo(({
|
|
|
744
972
|
}
|
|
745
973
|
)
|
|
746
974
|
] }),
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ jsxs5(CardFooter, { className: "flex flex-col space-y-4", children: [
|
|
976
|
+
/* @__PURE__ */ jsx11(
|
|
749
977
|
Button,
|
|
750
978
|
{
|
|
751
979
|
type: "submit",
|
|
@@ -754,7 +982,7 @@ var LoginForm = React9.memo(({
|
|
|
754
982
|
children: isLoading ? "Signing in..." : "Sign In"
|
|
755
983
|
}
|
|
756
984
|
),
|
|
757
|
-
showSignUp && (onSignUp ? /* @__PURE__ */
|
|
985
|
+
showSignUp && (onSignUp ? /* @__PURE__ */ jsx11("div", { className: "text-sm text-center text-muted-foreground", children: /* @__PURE__ */ jsx11(
|
|
758
986
|
"button",
|
|
759
987
|
{
|
|
760
988
|
type: "button",
|
|
@@ -762,10 +990,10 @@ var LoginForm = React9.memo(({
|
|
|
762
990
|
className: "text-primary hover:underline",
|
|
763
991
|
children: "Don't have an account? Sign up"
|
|
764
992
|
}
|
|
765
|
-
) }) : /* @__PURE__ */
|
|
993
|
+
) }) : /* @__PURE__ */ jsxs5("p", { className: "text-center text-muted-foreground", children: [
|
|
766
994
|
"Don't have an account?",
|
|
767
995
|
" ",
|
|
768
|
-
/* @__PURE__ */
|
|
996
|
+
/* @__PURE__ */ jsx11("a", { href: "/signup", className: "text-primary hover:underline", children: "Sign up" })
|
|
769
997
|
] }))
|
|
770
998
|
] })
|
|
771
999
|
] }) });
|
|
@@ -773,8 +1001,8 @@ var LoginForm = React9.memo(({
|
|
|
773
1001
|
|
|
774
1002
|
// src/components/EventSelector/EventSelector.tsx
|
|
775
1003
|
import { RefreshCw, AlertCircle, Lock, Calendar as Calendar2, Star } from "lucide-react";
|
|
776
|
-
import { useEffect, useMemo as useMemo2, useRef } from "react";
|
|
777
|
-
import { jsx as
|
|
1004
|
+
import { useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
1005
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
778
1006
|
function EventSelector({
|
|
779
1007
|
placeholder = "Select an event",
|
|
780
1008
|
className,
|
|
@@ -836,10 +1064,10 @@ function EventSelector({
|
|
|
836
1064
|
const getTime = (e) => e.event_date ? new Date(e.event_date).getTime() : Number.NEGATIVE_INFINITY;
|
|
837
1065
|
return [...events].sort((a, b) => getTime(b) - getTime(a));
|
|
838
1066
|
}, [events]);
|
|
839
|
-
const prevEventsLengthRef =
|
|
840
|
-
const prevSelectedEventIdRef =
|
|
841
|
-
const hasAutoSelectedRef =
|
|
842
|
-
|
|
1067
|
+
const prevEventsLengthRef = useRef2(events.length);
|
|
1068
|
+
const prevSelectedEventIdRef = useRef2(selectedEvent?.event_id);
|
|
1069
|
+
const hasAutoSelectedRef = useRef2(false);
|
|
1070
|
+
useEffect2(() => {
|
|
843
1071
|
const eventsLengthChanged = events.length !== prevEventsLengthRef.current;
|
|
844
1072
|
const selectedEventChanged = selectedEvent?.event_id !== prevSelectedEventIdRef.current;
|
|
845
1073
|
if (eventsLengthChanged) {
|
|
@@ -880,17 +1108,17 @@ function EventSelector({
|
|
|
880
1108
|
}
|
|
881
1109
|
}, [events.length, selectedEvent?.event_id, isLoading, setSelectedEvent, onEventChange]);
|
|
882
1110
|
if (isLoading) {
|
|
883
|
-
return /* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
/* @__PURE__ */
|
|
1111
|
+
return /* @__PURE__ */ jsxs6("div", { className: `flex items-center gap-2 ${className}`, children: [
|
|
1112
|
+
/* @__PURE__ */ jsx12(LoadingSpinner, { size: "sm" }),
|
|
1113
|
+
/* @__PURE__ */ jsx12("span", { className: "text-sm text-muted-foreground", children: "Loading events..." })
|
|
886
1114
|
] });
|
|
887
1115
|
}
|
|
888
1116
|
if (error) {
|
|
889
|
-
return /* @__PURE__ */
|
|
890
|
-
/* @__PURE__ */
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
/* @__PURE__ */
|
|
893
|
-
showRetryButton && /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ jsx12("div", { className, children: /* @__PURE__ */ jsxs6(Alert, { variant: "destructive", children: [
|
|
1118
|
+
/* @__PURE__ */ jsx12(Lock, { className: "h-4 w-4" }),
|
|
1119
|
+
/* @__PURE__ */ jsxs6(AlertDescription, { className: "flex items-center justify-between", children: [
|
|
1120
|
+
/* @__PURE__ */ jsx12("span", { children: error.message }),
|
|
1121
|
+
showRetryButton && /* @__PURE__ */ jsxs6(
|
|
894
1122
|
Button,
|
|
895
1123
|
{
|
|
896
1124
|
variant: "outline",
|
|
@@ -898,7 +1126,7 @@ function EventSelector({
|
|
|
898
1126
|
onClick: handleRetry,
|
|
899
1127
|
className: "ml-2",
|
|
900
1128
|
children: [
|
|
901
|
-
/* @__PURE__ */
|
|
1129
|
+
/* @__PURE__ */ jsx12(RefreshCw, { className: "h-3 w-3 mr-1" }),
|
|
902
1130
|
"Retry"
|
|
903
1131
|
]
|
|
904
1132
|
}
|
|
@@ -908,11 +1136,11 @@ function EventSelector({
|
|
|
908
1136
|
}
|
|
909
1137
|
if (events.length === 0) {
|
|
910
1138
|
if (showNoEventsMessage) {
|
|
911
|
-
return /* @__PURE__ */
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
showRetryButton && /* @__PURE__ */
|
|
1139
|
+
return /* @__PURE__ */ jsx12("div", { className, children: /* @__PURE__ */ jsxs6(Alert, { variant: "inline", children: [
|
|
1140
|
+
/* @__PURE__ */ jsx12(AlertCircle, { className: "h-4 w-4 text-acc-700" }),
|
|
1141
|
+
/* @__PURE__ */ jsxs6(AlertDescription, { className: "flex items-center justify-between", children: [
|
|
1142
|
+
/* @__PURE__ */ jsx12("span", { children: "No events available." }),
|
|
1143
|
+
showRetryButton && /* @__PURE__ */ jsxs6(
|
|
916
1144
|
Button,
|
|
917
1145
|
{
|
|
918
1146
|
variant: "outline",
|
|
@@ -920,7 +1148,7 @@ function EventSelector({
|
|
|
920
1148
|
onClick: handleRetry,
|
|
921
1149
|
className: "ml-2",
|
|
922
1150
|
children: [
|
|
923
|
-
/* @__PURE__ */
|
|
1151
|
+
/* @__PURE__ */ jsx12(RefreshCw, { className: "h-3 w-3 mr-1" }),
|
|
924
1152
|
"Refresh"
|
|
925
1153
|
]
|
|
926
1154
|
}
|
|
@@ -930,43 +1158,43 @@ function EventSelector({
|
|
|
930
1158
|
}
|
|
931
1159
|
return null;
|
|
932
1160
|
}
|
|
933
|
-
return /* @__PURE__ */
|
|
1161
|
+
return /* @__PURE__ */ jsxs6(
|
|
934
1162
|
Select,
|
|
935
1163
|
{
|
|
936
1164
|
value: selectedEvent ? selectedEvent.event_id || selectedEvent.id : "",
|
|
937
1165
|
onValueChange: handleValueChange,
|
|
938
1166
|
className,
|
|
939
1167
|
children: [
|
|
940
|
-
/* @__PURE__ */
|
|
941
|
-
/* @__PURE__ */
|
|
942
|
-
/* @__PURE__ */
|
|
943
|
-
selectedEvent.event_date && /* @__PURE__ */
|
|
1168
|
+
/* @__PURE__ */ jsx12(SelectTrigger, { className: "text-left", variant: "outline", children: /* @__PURE__ */ jsx12(SelectValue, { placeholder, children: selectedEvent && /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
1169
|
+
/* @__PURE__ */ jsx12(Calendar2, { className: "h-4 w-4 flex-shrink-0" }),
|
|
1170
|
+
/* @__PURE__ */ jsx12("span", { className: "truncate", children: selectedEvent.event_name }),
|
|
1171
|
+
selectedEvent.event_date && /* @__PURE__ */ jsxs6("span", { className: "text-xs text-muted-foreground flex-shrink-0", children: [
|
|
944
1172
|
"(",
|
|
945
1173
|
formatEventDate(selectedEvent.event_date),
|
|
946
1174
|
")"
|
|
947
1175
|
] })
|
|
948
1176
|
] }) }) }),
|
|
949
|
-
/* @__PURE__ */
|
|
1177
|
+
/* @__PURE__ */ jsx12(SelectContent, { children: sortedEvents.map((event) => {
|
|
950
1178
|
const isNext = isNextEvent(event);
|
|
951
1179
|
const isSelected = selectedEvent && (selectedEvent.event_id === event.event_id || selectedEvent.id === event.id);
|
|
952
|
-
return /* @__PURE__ */
|
|
1180
|
+
return /* @__PURE__ */ jsx12(
|
|
953
1181
|
SelectItem,
|
|
954
1182
|
{
|
|
955
1183
|
value: event.event_id || event.id,
|
|
956
1184
|
className: "flex items-center justify-between",
|
|
957
|
-
children: /* @__PURE__ */
|
|
958
|
-
showNextEventIndicator && isNext && /* @__PURE__ */
|
|
959
|
-
/* @__PURE__ */
|
|
960
|
-
/* @__PURE__ */
|
|
961
|
-
/* @__PURE__ */
|
|
962
|
-
isSelected && /* @__PURE__ */
|
|
1185
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 w-full", children: [
|
|
1186
|
+
showNextEventIndicator && isNext && /* @__PURE__ */ jsx12(Star, { className: "h-3 w-3 text-acc-500" }),
|
|
1187
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex-1", children: [
|
|
1188
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
1189
|
+
/* @__PURE__ */ jsx12("span", { className: isSelected ? "font-semibold" : "", children: event.event_name }),
|
|
1190
|
+
isSelected && /* @__PURE__ */ jsx12("span", { className: "text-xs bg-primary text-primary-foreground px-1 rounded", children: "Current" })
|
|
963
1191
|
] }),
|
|
964
|
-
showEventDetails && event.event_date && /* @__PURE__ */
|
|
965
|
-
/* @__PURE__ */
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
showNextEventIndicator && isNext && /* @__PURE__ */
|
|
1192
|
+
showEventDetails && event.event_date && /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
|
|
1193
|
+
/* @__PURE__ */ jsx12(Calendar2, { className: "h-3 w-3" }),
|
|
1194
|
+
/* @__PURE__ */ jsx12("span", { children: formatEventDate(event.event_date) }),
|
|
1195
|
+
showNextEventIndicator && isNext && /* @__PURE__ */ jsx12("span", { className: "text-acc-600 font-medium", children: "(Next)" })
|
|
968
1196
|
] }),
|
|
969
|
-
showEventDetails && event.event_venue && /* @__PURE__ */
|
|
1197
|
+
showEventDetails && event.event_venue && /* @__PURE__ */ jsxs6("div", { className: "text-xs text-muted-foreground", children: [
|
|
970
1198
|
"\u{1F4CD} ",
|
|
971
1199
|
event.event_venue
|
|
972
1200
|
] })
|
|
@@ -982,9 +1210,9 @@ function EventSelector({
|
|
|
982
1210
|
}
|
|
983
1211
|
|
|
984
1212
|
// src/components/OrganisationSelector/OrganisationSelector.tsx
|
|
985
|
-
import { useState as
|
|
1213
|
+
import { useState as useState3, useCallback as useCallback3 } from "react";
|
|
986
1214
|
import { RefreshCw as RefreshCw2, AlertCircle as AlertCircle2, Building2, Shield } from "lucide-react";
|
|
987
|
-
import { jsx as
|
|
1215
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
988
1216
|
function OrganisationSelector({
|
|
989
1217
|
placeholder = "Select organisation",
|
|
990
1218
|
className,
|
|
@@ -995,8 +1223,8 @@ function OrganisationSelector({
|
|
|
995
1223
|
compact = false,
|
|
996
1224
|
disabled = false
|
|
997
1225
|
}) {
|
|
998
|
-
const [isLoading, setIsLoading] =
|
|
999
|
-
const [switchError, setSwitchError] =
|
|
1226
|
+
const [isLoading, setIsLoading] = useState3(false);
|
|
1227
|
+
const [switchError, setSwitchError] = useState3(null);
|
|
1000
1228
|
const {
|
|
1001
1229
|
organisations,
|
|
1002
1230
|
selectedOrganisation,
|
|
@@ -1007,7 +1235,7 @@ function OrganisationSelector({
|
|
|
1007
1235
|
validateOrganisationAccess,
|
|
1008
1236
|
refreshOrganisations
|
|
1009
1237
|
} = useOrganisations();
|
|
1010
|
-
const handleOrganisationChange =
|
|
1238
|
+
const handleOrganisationChange = useCallback3(async (orgId) => {
|
|
1011
1239
|
if (disabled || isLoading) return;
|
|
1012
1240
|
setSwitchError(null);
|
|
1013
1241
|
setIsLoading(true);
|
|
@@ -1035,7 +1263,7 @@ function OrganisationSelector({
|
|
|
1035
1263
|
organisations,
|
|
1036
1264
|
onOrganisationChange
|
|
1037
1265
|
]);
|
|
1038
|
-
const handleRetry =
|
|
1266
|
+
const handleRetry = useCallback3(async () => {
|
|
1039
1267
|
setIsLoading(true);
|
|
1040
1268
|
setSwitchError(null);
|
|
1041
1269
|
try {
|
|
@@ -1048,21 +1276,21 @@ function OrganisationSelector({
|
|
|
1048
1276
|
}
|
|
1049
1277
|
}, [refreshOrganisations]);
|
|
1050
1278
|
if (orgLoading) {
|
|
1051
|
-
return /* @__PURE__ */
|
|
1052
|
-
/* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ jsxs7("div", { className: `flex items-center gap-2 ${className}`, children: [
|
|
1280
|
+
/* @__PURE__ */ jsx13(LoadingSpinner, { size: "sm" }),
|
|
1281
|
+
/* @__PURE__ */ jsx13("span", { className: "text-sm text-muted-foreground", children: compact ? "Loading..." : "Loading organisations..." })
|
|
1054
1282
|
] });
|
|
1055
1283
|
}
|
|
1056
1284
|
if (orgError) {
|
|
1057
|
-
return /* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1060
|
-
/* @__PURE__ */
|
|
1285
|
+
return /* @__PURE__ */ jsxs7("div", { className: `space-y-2 ${className}`, children: [
|
|
1286
|
+
/* @__PURE__ */ jsxs7(Alert, { variant: "destructive", children: [
|
|
1287
|
+
/* @__PURE__ */ jsx13(AlertCircle2, { className: "h-4 w-4" }),
|
|
1288
|
+
/* @__PURE__ */ jsxs7(AlertDescription, { children: [
|
|
1061
1289
|
"Failed to load organisations: ",
|
|
1062
1290
|
orgError.message
|
|
1063
1291
|
] })
|
|
1064
1292
|
] }),
|
|
1065
|
-
showRetryButton && /* @__PURE__ */
|
|
1293
|
+
showRetryButton && /* @__PURE__ */ jsxs7(
|
|
1066
1294
|
Button,
|
|
1067
1295
|
{
|
|
1068
1296
|
variant: "outline",
|
|
@@ -1071,7 +1299,7 @@ function OrganisationSelector({
|
|
|
1071
1299
|
disabled: isLoading,
|
|
1072
1300
|
className: "w-full",
|
|
1073
1301
|
children: [
|
|
1074
|
-
/* @__PURE__ */
|
|
1302
|
+
/* @__PURE__ */ jsx13(RefreshCw2, { className: `h-4 w-4 mr-2 ${isLoading ? "animate-spin" : ""}` }),
|
|
1075
1303
|
"Retry"
|
|
1076
1304
|
]
|
|
1077
1305
|
}
|
|
@@ -1080,12 +1308,12 @@ function OrganisationSelector({
|
|
|
1080
1308
|
}
|
|
1081
1309
|
if (organisations.length === 0) {
|
|
1082
1310
|
if (showNoOrganisationsMessage) {
|
|
1083
|
-
return /* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
/* @__PURE__ */
|
|
1311
|
+
return /* @__PURE__ */ jsxs7("div", { className: `space-y-2 ${className}`, children: [
|
|
1312
|
+
/* @__PURE__ */ jsxs7(Alert, { children: [
|
|
1313
|
+
/* @__PURE__ */ jsx13(Building2, { className: "h-4 w-4" }),
|
|
1314
|
+
/* @__PURE__ */ jsx13(AlertDescription, { children: "No organisations available. Please contact your administrator to be added to an organisation." })
|
|
1087
1315
|
] }),
|
|
1088
|
-
showRetryButton && /* @__PURE__ */
|
|
1316
|
+
showRetryButton && /* @__PURE__ */ jsxs7(
|
|
1089
1317
|
Button,
|
|
1090
1318
|
{
|
|
1091
1319
|
variant: "outline",
|
|
@@ -1094,7 +1322,7 @@ function OrganisationSelector({
|
|
|
1094
1322
|
disabled: isLoading,
|
|
1095
1323
|
className: "w-full",
|
|
1096
1324
|
children: [
|
|
1097
|
-
/* @__PURE__ */
|
|
1325
|
+
/* @__PURE__ */ jsx13(RefreshCw2, { className: `h-4 w-4 mr-2 ${isLoading ? "animate-spin" : ""}` }),
|
|
1098
1326
|
"Check Again"
|
|
1099
1327
|
]
|
|
1100
1328
|
}
|
|
@@ -1103,42 +1331,42 @@ function OrganisationSelector({
|
|
|
1103
1331
|
}
|
|
1104
1332
|
return null;
|
|
1105
1333
|
}
|
|
1106
|
-
const switchErrorDisplay = switchError && /* @__PURE__ */
|
|
1107
|
-
/* @__PURE__ */
|
|
1108
|
-
/* @__PURE__ */
|
|
1334
|
+
const switchErrorDisplay = switchError && /* @__PURE__ */ jsxs7(Alert, { variant: "destructive", className: "mt-2", children: [
|
|
1335
|
+
/* @__PURE__ */ jsx13(AlertCircle2, { className: "h-4 w-4" }),
|
|
1336
|
+
/* @__PURE__ */ jsx13(AlertDescription, { children: switchError })
|
|
1109
1337
|
] });
|
|
1110
|
-
return /* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1338
|
+
return /* @__PURE__ */ jsxs7("div", { className: `space-y-2 ${className}`, children: [
|
|
1339
|
+
/* @__PURE__ */ jsxs7(
|
|
1112
1340
|
Select,
|
|
1113
1341
|
{
|
|
1114
1342
|
value: selectedOrganisation?.id || "",
|
|
1115
1343
|
onValueChange: handleOrganisationChange,
|
|
1116
1344
|
disabled: disabled || isLoading || !selectedOrganisation,
|
|
1117
1345
|
children: [
|
|
1118
|
-
/* @__PURE__ */
|
|
1119
|
-
isLoading ? /* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1346
|
+
/* @__PURE__ */ jsx13(SelectTrigger, { className: `${isLoading ? "opacity-50" : ""}`, children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
|
|
1347
|
+
isLoading ? /* @__PURE__ */ jsx13(LoadingSpinner, { size: "sm" }) : /* @__PURE__ */ jsx13(Building2, { className: "h-4 w-4 text-muted-foreground" }),
|
|
1348
|
+
/* @__PURE__ */ jsx13(SelectValue, { placeholder })
|
|
1121
1349
|
] }) }),
|
|
1122
|
-
/* @__PURE__ */
|
|
1350
|
+
/* @__PURE__ */ jsx13(SelectContent, { children: organisations.map((org) => {
|
|
1123
1351
|
const userRole = getUserRole(org.id);
|
|
1124
1352
|
const hasAccess = validateOrganisationAccess(org.id);
|
|
1125
|
-
return /* @__PURE__ */
|
|
1353
|
+
return /* @__PURE__ */ jsx13(
|
|
1126
1354
|
SelectItem,
|
|
1127
1355
|
{
|
|
1128
1356
|
value: org.id,
|
|
1129
1357
|
disabled: !hasAccess,
|
|
1130
1358
|
className: !hasAccess ? "opacity-50" : "",
|
|
1131
|
-
children: /* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1133
|
-
/* @__PURE__ */
|
|
1134
|
-
/* @__PURE__ */
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
!compact && org.description && /* @__PURE__ */
|
|
1359
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between w-full", children: [
|
|
1360
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
|
|
1361
|
+
/* @__PURE__ */ jsx13(Building2, { className: "h-4 w-4" }),
|
|
1362
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
|
|
1363
|
+
/* @__PURE__ */ jsx13("span", { className: "font-medium", children: org.display_name }),
|
|
1364
|
+
!compact && org.description && /* @__PURE__ */ jsx13("span", { className: "text-xs text-muted-foreground truncate max-w-40", children: org.description })
|
|
1137
1365
|
] })
|
|
1138
1366
|
] }),
|
|
1139
|
-
showRole && /* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */
|
|
1367
|
+
showRole && /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1 ml-4", children: [
|
|
1368
|
+
/* @__PURE__ */ jsx13(Shield, { className: "h-3 w-3 text-muted-foreground" }),
|
|
1369
|
+
/* @__PURE__ */ jsx13("span", { className: "text-xs text-muted-foreground capitalize", children: userRole?.replace("_", " ") || "No Role" })
|
|
1142
1370
|
] })
|
|
1143
1371
|
] })
|
|
1144
1372
|
},
|
|
@@ -1153,13 +1381,13 @@ function OrganisationSelector({
|
|
|
1153
1381
|
}
|
|
1154
1382
|
|
|
1155
1383
|
// src/components/PasswordChange/PasswordChangeForm.tsx
|
|
1156
|
-
import { useState as
|
|
1157
|
-
import { jsx as
|
|
1384
|
+
import { useState as useState4 } from "react";
|
|
1385
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1158
1386
|
function PasswordChangeForm({ onSubmit, className }) {
|
|
1159
|
-
const [newPassword, setNewPassword] =
|
|
1160
|
-
const [confirmPassword, setConfirmPassword] =
|
|
1161
|
-
const [error, setError] =
|
|
1162
|
-
const [isSubmitting, setIsSubmitting] =
|
|
1387
|
+
const [newPassword, setNewPassword] = useState4("");
|
|
1388
|
+
const [confirmPassword, setConfirmPassword] = useState4("");
|
|
1389
|
+
const [error, setError] = useState4(null);
|
|
1390
|
+
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
1163
1391
|
const handleSubmit = async (e) => {
|
|
1164
1392
|
e.preventDefault();
|
|
1165
1393
|
setError(null);
|
|
@@ -1184,11 +1412,11 @@ function PasswordChangeForm({ onSubmit, className }) {
|
|
|
1184
1412
|
setIsSubmitting(false);
|
|
1185
1413
|
}
|
|
1186
1414
|
};
|
|
1187
|
-
return /* @__PURE__ */
|
|
1188
|
-
error && /* @__PURE__ */
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1191
|
-
/* @__PURE__ */
|
|
1415
|
+
return /* @__PURE__ */ jsxs8("form", { onSubmit: handleSubmit, className: cn("space-y-4", className), children: [
|
|
1416
|
+
error && /* @__PURE__ */ jsx14("div", { role: "alert", children: error }),
|
|
1417
|
+
/* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
1418
|
+
/* @__PURE__ */ jsx14(Label, { htmlFor: "new-password", children: "New Password" }),
|
|
1419
|
+
/* @__PURE__ */ jsx14(
|
|
1192
1420
|
Input,
|
|
1193
1421
|
{
|
|
1194
1422
|
id: "new-password",
|
|
@@ -1200,9 +1428,9 @@ function PasswordChangeForm({ onSubmit, className }) {
|
|
|
1200
1428
|
}
|
|
1201
1429
|
)
|
|
1202
1430
|
] }),
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
1432
|
+
/* @__PURE__ */ jsx14(Label, { htmlFor: "confirm-password", children: "Confirm Password" }),
|
|
1433
|
+
/* @__PURE__ */ jsx14(
|
|
1206
1434
|
Input,
|
|
1207
1435
|
{
|
|
1208
1436
|
id: "confirm-password",
|
|
@@ -1214,7 +1442,7 @@ function PasswordChangeForm({ onSubmit, className }) {
|
|
|
1214
1442
|
}
|
|
1215
1443
|
)
|
|
1216
1444
|
] }),
|
|
1217
|
-
/* @__PURE__ */
|
|
1445
|
+
/* @__PURE__ */ jsx14(
|
|
1218
1446
|
Button,
|
|
1219
1447
|
{
|
|
1220
1448
|
type: "submit",
|
|
@@ -1227,17 +1455,17 @@ function PasswordChangeForm({ onSubmit, className }) {
|
|
|
1227
1455
|
}
|
|
1228
1456
|
|
|
1229
1457
|
// src/components/UserMenu/UserMenu.tsx
|
|
1230
|
-
import
|
|
1458
|
+
import React13, { useCallback as useCallback4, useMemo as useMemo3, useState as useState5 } from "react";
|
|
1231
1459
|
import { ChevronDown, LogOut, KeyRound } from "lucide-react";
|
|
1232
|
-
import { jsx as
|
|
1233
|
-
var UserMenu =
|
|
1460
|
+
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1461
|
+
var UserMenu = React13.memo(function UserMenu2({
|
|
1234
1462
|
user,
|
|
1235
1463
|
onSignOut,
|
|
1236
1464
|
onChangePassword,
|
|
1237
1465
|
className,
|
|
1238
1466
|
showAvatar = true
|
|
1239
1467
|
}) {
|
|
1240
|
-
const [isPasswordDialogOpen, setPasswordDialogOpen] =
|
|
1468
|
+
const [isPasswordDialogOpen, setPasswordDialogOpen] = useState5(false);
|
|
1241
1469
|
const userInfo = useMemo3(() => {
|
|
1242
1470
|
if (!user) return null;
|
|
1243
1471
|
return {
|
|
@@ -1247,42 +1475,42 @@ var UserMenu = React12.memo(function UserMenu2({
|
|
|
1247
1475
|
initial: (user.user_metadata?.display_name || user.user_metadata?.full_name || user.email || "U").charAt(0).toUpperCase()
|
|
1248
1476
|
};
|
|
1249
1477
|
}, [user]);
|
|
1250
|
-
const handleSignOut =
|
|
1478
|
+
const handleSignOut = useCallback4(async () => {
|
|
1251
1479
|
if (onSignOut) await onSignOut();
|
|
1252
1480
|
}, [onSignOut]);
|
|
1253
1481
|
if (!user || !userInfo) {
|
|
1254
1482
|
return null;
|
|
1255
1483
|
}
|
|
1256
|
-
return /* @__PURE__ */
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1259
|
-
showAvatar && /* @__PURE__ */
|
|
1260
|
-
/* @__PURE__ */
|
|
1261
|
-
/* @__PURE__ */
|
|
1484
|
+
return /* @__PURE__ */ jsxs9(Dialog, { open: isPasswordDialogOpen, onOpenChange: setPasswordDialogOpen, children: [
|
|
1485
|
+
/* @__PURE__ */ jsxs9(Select, { className, children: [
|
|
1486
|
+
/* @__PURE__ */ jsx15(SelectTrigger, { asChild: true, children: /* @__PURE__ */ jsxs9(Button, { variant: "outline", className: "flex items-center gap-2", "aria-label": userInfo.displayName, children: [
|
|
1487
|
+
showAvatar && /* @__PURE__ */ jsxs9(Avatar, { className: "size-7", children: [
|
|
1488
|
+
/* @__PURE__ */ jsx15(AvatarImage, { src: userInfo.avatarUrl, alt: userInfo.displayName }),
|
|
1489
|
+
/* @__PURE__ */ jsx15(AvatarFallback, { children: userInfo.initial })
|
|
1262
1490
|
] }),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */
|
|
1491
|
+
/* @__PURE__ */ jsx15("span", { children: userInfo.displayName }),
|
|
1492
|
+
/* @__PURE__ */ jsx15(ChevronDown, { className: "h-4 w-4" })
|
|
1265
1493
|
] }) }),
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1269
|
-
/* @__PURE__ */
|
|
1494
|
+
/* @__PURE__ */ jsxs9(SelectContent, { children: [
|
|
1495
|
+
/* @__PURE__ */ jsx15(SelectLabel, { className: "font-normal", children: /* @__PURE__ */ jsxs9("div", { className: "flex flex-col space-y-1", children: [
|
|
1496
|
+
/* @__PURE__ */ jsx15("p", { className: "font-medium", children: userInfo.displayName }),
|
|
1497
|
+
/* @__PURE__ */ jsx15("p", { className: "text-muted-foreground", children: userInfo.email })
|
|
1270
1498
|
] }) }),
|
|
1271
|
-
/* @__PURE__ */
|
|
1272
|
-
/* @__PURE__ */
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
/* @__PURE__ */
|
|
1499
|
+
/* @__PURE__ */ jsx15(SelectSeparator, {}),
|
|
1500
|
+
/* @__PURE__ */ jsx15(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs9(SelectItem, { value: "change-password", children: [
|
|
1501
|
+
/* @__PURE__ */ jsx15(KeyRound, { className: "mr-2 h-4 w-4" }),
|
|
1502
|
+
/* @__PURE__ */ jsx15("span", { children: "Change Password" })
|
|
1275
1503
|
] }) }),
|
|
1276
|
-
/* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
1278
|
-
/* @__PURE__ */
|
|
1504
|
+
/* @__PURE__ */ jsxs9(SelectItem, { value: "sign-out", onClick: handleSignOut, children: [
|
|
1505
|
+
/* @__PURE__ */ jsx15(LogOut, { className: "mr-2 h-4 w-4" }),
|
|
1506
|
+
/* @__PURE__ */ jsx15("span", { children: "Sign out" })
|
|
1279
1507
|
] })
|
|
1280
1508
|
] })
|
|
1281
1509
|
] }),
|
|
1282
|
-
/* @__PURE__ */
|
|
1283
|
-
/* @__PURE__ */
|
|
1284
|
-
/* @__PURE__ */
|
|
1285
|
-
/* @__PURE__ */
|
|
1510
|
+
/* @__PURE__ */ jsx15(DialogOverlay, {}),
|
|
1511
|
+
/* @__PURE__ */ jsxs9(DialogContent, { className, children: [
|
|
1512
|
+
/* @__PURE__ */ jsx15(DialogHeader, { children: /* @__PURE__ */ jsx15(DialogTitle, { children: "Change Password" }) }),
|
|
1513
|
+
/* @__PURE__ */ jsx15(
|
|
1286
1514
|
PasswordChangeForm,
|
|
1287
1515
|
{
|
|
1288
1516
|
onSubmit: async ({ newPassword, confirmPassword }) => {
|
|
@@ -1300,31 +1528,31 @@ var UserMenu = React12.memo(function UserMenu2({
|
|
|
1300
1528
|
] })
|
|
1301
1529
|
] });
|
|
1302
1530
|
});
|
|
1303
|
-
var UserMenuLoading =
|
|
1304
|
-
return /* @__PURE__ */
|
|
1305
|
-
/* @__PURE__ */
|
|
1531
|
+
var UserMenuLoading = React13.memo(function UserMenuLoading2() {
|
|
1532
|
+
return /* @__PURE__ */ jsxs9("div", { className: "relative inline-block text-left", children: [
|
|
1533
|
+
/* @__PURE__ */ jsxs9(
|
|
1306
1534
|
"button",
|
|
1307
1535
|
{
|
|
1308
1536
|
type: "button",
|
|
1309
1537
|
disabled: true,
|
|
1310
1538
|
className: "flex items-center space-x-2 px-3 py-2 text-sm font-medium text-muted-foreground bg-muted border border-input rounded-md",
|
|
1311
1539
|
children: [
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1540
|
+
/* @__PURE__ */ jsx15("div", { className: "w-6 h-6 rounded-full bg-muted animate-pulse" }),
|
|
1541
|
+
/* @__PURE__ */ jsx15("span", { className: "truncate max-w-[150px]", children: "Loading..." }),
|
|
1542
|
+
/* @__PURE__ */ jsx15(ChevronDown, { className: "w-4 h-4 text-muted-foreground" })
|
|
1315
1543
|
]
|
|
1316
1544
|
}
|
|
1317
1545
|
),
|
|
1318
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ jsx15("div", { role: "status", "aria-label": "Loading user menu", "aria-live": "polite", className: "w-6 h-6 rounded-full bg-muted animate-pulse" })
|
|
1319
1547
|
] });
|
|
1320
1548
|
});
|
|
1321
1549
|
UserMenu.Loading = UserMenuLoading;
|
|
1322
1550
|
|
|
1323
1551
|
// src/components/NavigationMenu/NavigationMenu.tsx
|
|
1324
|
-
import * as
|
|
1552
|
+
import * as React14 from "react";
|
|
1325
1553
|
import { ChevronDown as ChevronDown2 } from "lucide-react";
|
|
1326
|
-
import { jsx as
|
|
1327
|
-
var NavigationMenu =
|
|
1554
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1555
|
+
var NavigationMenu = React14.forwardRef(({
|
|
1328
1556
|
items,
|
|
1329
1557
|
mode = "dropdown",
|
|
1330
1558
|
currentPath,
|
|
@@ -1342,8 +1570,8 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1342
1570
|
itemsPreFiltered = false,
|
|
1343
1571
|
...props
|
|
1344
1572
|
}, ref) => {
|
|
1345
|
-
const [expandedItems, setExpandedItems] =
|
|
1346
|
-
const buttonRef =
|
|
1573
|
+
const [expandedItems, setExpandedItems] = React14.useState(/* @__PURE__ */ new Set());
|
|
1574
|
+
const buttonRef = React14.useRef(null);
|
|
1347
1575
|
let authContext = null;
|
|
1348
1576
|
try {
|
|
1349
1577
|
authContext = useUnifiedAuth();
|
|
@@ -1368,15 +1596,15 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1368
1596
|
selectedOrganisationId: itemsPreFiltered ? null : selectedOrganisation?.id || null,
|
|
1369
1597
|
selectedEventId: itemsPreFiltered ? null : selectedEvent?.event_id || null
|
|
1370
1598
|
});
|
|
1371
|
-
const [resolvedAppId, setResolvedAppId] =
|
|
1372
|
-
|
|
1599
|
+
const [resolvedAppId, setResolvedAppId] = React14.useState(void 0);
|
|
1600
|
+
React14.useEffect(() => {
|
|
1373
1601
|
if (!scopeLoading && !resolvedScope?.appId && selectedOrganisation?.id && authContext?.appName && authContext?.user?.id && !resolvedAppId) {
|
|
1374
1602
|
if (!authContext.user || !authContext.appName) {
|
|
1375
1603
|
return;
|
|
1376
1604
|
}
|
|
1377
1605
|
const userId2 = authContext.user.id;
|
|
1378
1606
|
const appName = authContext.appName;
|
|
1379
|
-
import("./api-
|
|
1607
|
+
import("./api-YP7XD5L6.js").then(({ resolveAppContext }) => {
|
|
1380
1608
|
resolveAppContext({
|
|
1381
1609
|
userId: userId2,
|
|
1382
1610
|
appName
|
|
@@ -1390,7 +1618,7 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1390
1618
|
});
|
|
1391
1619
|
}
|
|
1392
1620
|
}, [scopeLoading, resolvedScope?.appId, selectedOrganisation?.id, authContext?.appName, authContext?.user?.id, resolvedAppId]);
|
|
1393
|
-
const effectiveScope =
|
|
1621
|
+
const effectiveScope = React14.useMemo(() => {
|
|
1394
1622
|
if (resolvedScope?.organisationId) {
|
|
1395
1623
|
return resolvedScope;
|
|
1396
1624
|
}
|
|
@@ -1405,7 +1633,7 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1405
1633
|
return null;
|
|
1406
1634
|
}, [resolvedScope, selectedOrganisation?.id, selectedEvent?.event_id, resolvedAppId]);
|
|
1407
1635
|
const scopeKey = effectiveScope ? `${effectiveScope.organisationId || ""}-${effectiveScope.eventId || ""}-${effectiveScope.appId || ""}` : "empty";
|
|
1408
|
-
const stableScope =
|
|
1636
|
+
const stableScope = React14.useMemo(() => {
|
|
1409
1637
|
if (effectiveScope?.organisationId) {
|
|
1410
1638
|
return {
|
|
1411
1639
|
organisationId: effectiveScope.organisationId,
|
|
@@ -1430,8 +1658,8 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1430
1658
|
itemsPreFiltered ? void 0 : stableScope.appId
|
|
1431
1659
|
// Skip if pre-filtered
|
|
1432
1660
|
);
|
|
1433
|
-
const previousFilteredItemsRef =
|
|
1434
|
-
const filteredItems =
|
|
1661
|
+
const previousFilteredItemsRef = React14.useRef([]);
|
|
1662
|
+
const filteredItems = React14.useMemo(() => {
|
|
1435
1663
|
if (itemsPreFiltered && items && items.length > 0) {
|
|
1436
1664
|
const visibleItems = (items || []).filter((item) => !item.meta?.hidden);
|
|
1437
1665
|
previousFilteredItemsRef.current = visibleItems;
|
|
@@ -1727,8 +1955,8 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1727
1955
|
const hasChildren = item.children && item.children.length > 0;
|
|
1728
1956
|
const isExpanded = expandedItems.has(item.id);
|
|
1729
1957
|
const itemIsActive = isActiveItem(item);
|
|
1730
|
-
return /* @__PURE__ */
|
|
1731
|
-
/* @__PURE__ */
|
|
1958
|
+
return /* @__PURE__ */ jsx16("li", { role: "none", children: hasChildren ? /* @__PURE__ */ jsxs10("div", { children: [
|
|
1959
|
+
/* @__PURE__ */ jsxs10(
|
|
1732
1960
|
"button",
|
|
1733
1961
|
{
|
|
1734
1962
|
onClick: () => toggleExpanded(item.id),
|
|
@@ -1737,21 +1965,21 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1737
1965
|
"aria-controls": `submenu-${item.id}`,
|
|
1738
1966
|
"aria-current": itemIsActive ? "page" : void 0,
|
|
1739
1967
|
children: [
|
|
1740
|
-
/* @__PURE__ */
|
|
1741
|
-
/* @__PURE__ */
|
|
1968
|
+
/* @__PURE__ */ jsx16("span", { children: item.label }),
|
|
1969
|
+
/* @__PURE__ */ jsx16(ChevronDown2, { "aria-hidden": "true" })
|
|
1742
1970
|
]
|
|
1743
1971
|
}
|
|
1744
1972
|
),
|
|
1745
|
-
isExpanded && item.children && /* @__PURE__ */
|
|
1973
|
+
isExpanded && item.children && /* @__PURE__ */ jsx16(
|
|
1746
1974
|
"ul",
|
|
1747
1975
|
{
|
|
1748
1976
|
id: `submenu-${item.id}`,
|
|
1749
1977
|
role: "menu",
|
|
1750
1978
|
"aria-label": `${item.label} submenu`,
|
|
1751
|
-
children: item.children.map((child) => /* @__PURE__ */
|
|
1979
|
+
children: item.children.map((child) => /* @__PURE__ */ jsx16(React14.Fragment, { children: renderHierarchicalItem(child, level + 1) }, child.id))
|
|
1752
1980
|
}
|
|
1753
1981
|
)
|
|
1754
|
-
] }) : /* @__PURE__ */
|
|
1982
|
+
] }) : /* @__PURE__ */ jsx16(
|
|
1755
1983
|
"a",
|
|
1756
1984
|
{
|
|
1757
1985
|
href: item.href || "#",
|
|
@@ -1769,26 +1997,26 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1769
1997
|
) });
|
|
1770
1998
|
};
|
|
1771
1999
|
if (mode === "dropdown") {
|
|
1772
|
-
return /* @__PURE__ */
|
|
2000
|
+
return /* @__PURE__ */ jsxs10(
|
|
1773
2001
|
Select,
|
|
1774
2002
|
{
|
|
1775
2003
|
onValueChange: handleNavigationSelect,
|
|
1776
2004
|
className,
|
|
1777
2005
|
"data-testid": "navigation-menu-root",
|
|
1778
2006
|
children: [
|
|
1779
|
-
/* @__PURE__ */
|
|
2007
|
+
/* @__PURE__ */ jsx16(
|
|
1780
2008
|
SelectTrigger,
|
|
1781
2009
|
{
|
|
1782
2010
|
ref: buttonRef,
|
|
1783
2011
|
disabled,
|
|
1784
2012
|
"aria-label": buttonText,
|
|
1785
2013
|
"data-testid": "navigation-menu-trigger",
|
|
1786
|
-
children: /* @__PURE__ */
|
|
2014
|
+
children: /* @__PURE__ */ jsx16(SelectValue, { placeholder: buttonText })
|
|
1787
2015
|
}
|
|
1788
2016
|
),
|
|
1789
|
-
/* @__PURE__ */
|
|
2017
|
+
/* @__PURE__ */ jsx16(SelectContent, { children: filteredItems.map((item) => {
|
|
1790
2018
|
const isActive = isActiveItem(item);
|
|
1791
|
-
return /* @__PURE__ */
|
|
2019
|
+
return /* @__PURE__ */ jsx16(
|
|
1792
2020
|
SelectItem,
|
|
1793
2021
|
{
|
|
1794
2022
|
value: item.id,
|
|
@@ -1803,14 +2031,14 @@ var NavigationMenu = React13.forwardRef(({
|
|
|
1803
2031
|
}
|
|
1804
2032
|
);
|
|
1805
2033
|
}
|
|
1806
|
-
return /* @__PURE__ */
|
|
2034
|
+
return /* @__PURE__ */ jsx16(
|
|
1807
2035
|
"nav",
|
|
1808
2036
|
{
|
|
1809
2037
|
ref,
|
|
1810
2038
|
className,
|
|
1811
2039
|
"aria-label": navigationLabel,
|
|
1812
2040
|
...props,
|
|
1813
|
-
children: /* @__PURE__ */
|
|
2041
|
+
children: /* @__PURE__ */ jsx16("ul", { role: "menubar", children: filteredItems.map((item) => /* @__PURE__ */ jsx16(React14.Fragment, { children: renderHierarchicalItem(item, 0) }, item.id)) })
|
|
1814
2042
|
}
|
|
1815
2043
|
);
|
|
1816
2044
|
});
|
|
@@ -1818,7 +2046,7 @@ NavigationMenu.displayName = "NavigationMenu";
|
|
|
1818
2046
|
|
|
1819
2047
|
// src/components/Header/Header.tsx
|
|
1820
2048
|
import { Link } from "react-router-dom";
|
|
1821
|
-
import { jsx as
|
|
2049
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1822
2050
|
function Header({
|
|
1823
2051
|
logoUrl,
|
|
1824
2052
|
logoAlt = "Logo",
|
|
@@ -1837,32 +2065,32 @@ function Header({
|
|
|
1837
2065
|
onNavigate,
|
|
1838
2066
|
logoHref
|
|
1839
2067
|
}) {
|
|
1840
|
-
return /* @__PURE__ */
|
|
2068
|
+
return /* @__PURE__ */ jsx17("header", { className: cn(
|
|
1841
2069
|
"w-full border-b border-main-200 h-16 shadow-sm bg-main-100 ",
|
|
1842
2070
|
className
|
|
1843
|
-
), role: "banner", children: /* @__PURE__ */
|
|
1844
|
-
logo ? logoHref ? /* @__PURE__ */
|
|
2071
|
+
), role: "banner", children: /* @__PURE__ */ jsxs11("nav", { className: "px-4 w-[min(var(--app-width),100%)] mx-auto flex items-center gap-4 h-full", children: [
|
|
2072
|
+
logo ? logoHref ? /* @__PURE__ */ jsx17(Link, { to: logoHref, className: "cursor-pointer hover:opacity-80 transition-opacity", children: logo }) : logo : logoUrl ? logoHref ? /* @__PURE__ */ jsx17(Link, { to: logoHref, className: "cursor-pointer hover:opacity-80 transition-opacity", children: /* @__PURE__ */ jsx17(
|
|
1845
2073
|
"img",
|
|
1846
2074
|
{
|
|
1847
2075
|
src: logoUrl,
|
|
1848
2076
|
alt: logoAlt || "Logo",
|
|
1849
2077
|
className: "h-[2.15rem] w-auto max-w-[200px] object-contain rounded-md shadow-md bg-transparent"
|
|
1850
2078
|
}
|
|
1851
|
-
) }) : /* @__PURE__ */
|
|
2079
|
+
) }) : /* @__PURE__ */ jsx17(
|
|
1852
2080
|
"img",
|
|
1853
2081
|
{
|
|
1854
2082
|
src: logoUrl,
|
|
1855
2083
|
alt: logoAlt || "Logo",
|
|
1856
2084
|
className: "h-[2.15rem] w-auto max-w-[200px] object-contain rounded-md shadow-md bg-transparent"
|
|
1857
2085
|
}
|
|
1858
|
-
) : logoHref ? /* @__PURE__ */
|
|
2086
|
+
) : logoHref ? /* @__PURE__ */ jsx17(Link, { to: logoHref, className: "cursor-pointer hover:opacity-80 transition-opacity", children: /* @__PURE__ */ jsx17(
|
|
1859
2087
|
"img",
|
|
1860
2088
|
{
|
|
1861
2089
|
src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23000'/%3E%3Ctext x='16' y='20' text-anchor='middle' fill='white' font-family='Arial' font-size='14' font-weight='bold'%3EL%3C/text%3E%3C/svg%3E",
|
|
1862
2090
|
alt: logoAlt || "Logo",
|
|
1863
2091
|
className: "h-8 w-8 shadow-md"
|
|
1864
2092
|
}
|
|
1865
|
-
) }) : /* @__PURE__ */
|
|
2093
|
+
) }) : /* @__PURE__ */ jsx17(
|
|
1866
2094
|
"img",
|
|
1867
2095
|
{
|
|
1868
2096
|
src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23000'/%3E%3Ctext x='16' y='20' text-anchor='middle' fill='white' font-family='Arial' font-size='14' font-weight='bold'%3EL%3C/text%3E%3C/svg%3E",
|
|
@@ -1870,7 +2098,7 @@ function Header({
|
|
|
1870
2098
|
className: "h-8 w-8 shadow-md"
|
|
1871
2099
|
}
|
|
1872
2100
|
),
|
|
1873
|
-
navItems && navItems.length > 0 && /* @__PURE__ */
|
|
2101
|
+
navItems && navItems.length > 0 && /* @__PURE__ */ jsx17(
|
|
1874
2102
|
NavigationMenu,
|
|
1875
2103
|
{
|
|
1876
2104
|
items: navItems,
|
|
@@ -1881,8 +2109,8 @@ function Header({
|
|
|
1881
2109
|
itemsPreFiltered: true
|
|
1882
2110
|
}
|
|
1883
2111
|
),
|
|
1884
|
-
/* @__PURE__ */
|
|
1885
|
-
showOrgSelector ? /* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-4 ml-auto", children: [
|
|
2113
|
+
showOrgSelector ? /* @__PURE__ */ jsx17(
|
|
1886
2114
|
OrganisationSelector,
|
|
1887
2115
|
{
|
|
1888
2116
|
placeholder: "Select organisation",
|
|
@@ -1891,7 +2119,7 @@ function Header({
|
|
|
1891
2119
|
compact: true
|
|
1892
2120
|
}
|
|
1893
2121
|
) : null,
|
|
1894
|
-
showEventSelector ? /* @__PURE__ */
|
|
2122
|
+
showEventSelector ? /* @__PURE__ */ jsx17(
|
|
1895
2123
|
EventSelector,
|
|
1896
2124
|
{
|
|
1897
2125
|
placeholder: "Select event",
|
|
@@ -1900,7 +2128,7 @@ function Header({
|
|
|
1900
2128
|
}
|
|
1901
2129
|
) : null,
|
|
1902
2130
|
actions,
|
|
1903
|
-
showUserMenu && (userMenu ? userMenu : /* @__PURE__ */
|
|
2131
|
+
showUserMenu && (userMenu ? userMenu : /* @__PURE__ */ jsx17(
|
|
1904
2132
|
UserMenu,
|
|
1905
2133
|
{
|
|
1906
2134
|
user: user || null,
|
|
@@ -1914,8 +2142,8 @@ function Header({
|
|
|
1914
2142
|
}
|
|
1915
2143
|
|
|
1916
2144
|
// src/components/Footer/Footer.tsx
|
|
1917
|
-
import
|
|
1918
|
-
import { Fragment as Fragment3, jsx as
|
|
2145
|
+
import React15 from "react";
|
|
2146
|
+
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1919
2147
|
var FooterComponent = ({
|
|
1920
2148
|
companyName = "Solvera Solutions Pty Ltd",
|
|
1921
2149
|
year = (/* @__PURE__ */ new Date()).getFullYear(),
|
|
@@ -1926,21 +2154,21 @@ var FooterComponent = ({
|
|
|
1926
2154
|
children
|
|
1927
2155
|
}) => {
|
|
1928
2156
|
const copyrightText = copyright || `\xA9 Copyright 2022\u2013${year} all rights reserved, ${companyName}.`;
|
|
1929
|
-
return /* @__PURE__ */
|
|
1930
|
-
logo && /* @__PURE__ */
|
|
1931
|
-
children && /* @__PURE__ */
|
|
1932
|
-
/* @__PURE__ */
|
|
1933
|
-
links && links.length > 0 && /* @__PURE__ */
|
|
2157
|
+
return /* @__PURE__ */ jsx18("footer", { className: cn("mt-8 py-6 flex justify-center border-t border-border bg-main-100", className), children: /* @__PURE__ */ jsxs12("section", { className: "px-4 w-[min(var(--app-width),100%)] mx-auto text-center", children: [
|
|
2158
|
+
logo && /* @__PURE__ */ jsx18("img", { src: logo, alt: "Logo", className: "h-8 w-auto" }),
|
|
2159
|
+
children && /* @__PURE__ */ jsx18(Fragment3, { children }),
|
|
2160
|
+
/* @__PURE__ */ jsx18("span", { className: "text-muted-foreground", children: copyrightText }),
|
|
2161
|
+
links && links.length > 0 && /* @__PURE__ */ jsx18("ul", { className: "flex gap-4 mt-2 md:mt-0", children: links.map((link, index) => /* @__PURE__ */ jsx18("li", { children: /* @__PURE__ */ jsx18("a", { href: link.href, className: "text-muted-foreground hover:text-foreground", children: link.label }) }, index)) })
|
|
1934
2162
|
] }) });
|
|
1935
2163
|
};
|
|
1936
2164
|
FooterComponent.displayName = "Footer";
|
|
1937
|
-
var Footer =
|
|
2165
|
+
var Footer = React15.memo(FooterComponent);
|
|
1938
2166
|
Footer.displayName = "Footer";
|
|
1939
2167
|
|
|
1940
2168
|
// src/components/PaceAppLayout/PaceAppLayout.tsx
|
|
1941
|
-
import { useState as
|
|
2169
|
+
import { useState as useState7, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1942
2170
|
import { Outlet, useNavigate, useLocation } from "react-router-dom";
|
|
1943
|
-
import { Fragment as Fragment4, jsx as
|
|
2171
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1944
2172
|
var EMPTY_PAGE_ID_MAPPING = {};
|
|
1945
2173
|
var EMPTY_ROUTE_PERMISSIONS = {};
|
|
1946
2174
|
function PaceAppLayout({
|
|
@@ -2034,9 +2262,9 @@ function PaceAppLayout({
|
|
|
2034
2262
|
const permissionString = `${currentRoutePermission}:page.${currentPageId}`;
|
|
2035
2263
|
return permissionString;
|
|
2036
2264
|
}, [enforcePermissions, currentRoutePermission, currentPageId]);
|
|
2037
|
-
const [isSuperAdminUser, setIsSuperAdminUser] =
|
|
2038
|
-
const [isCheckingSuperAdmin, setIsCheckingSuperAdmin] =
|
|
2039
|
-
|
|
2265
|
+
const [isSuperAdminUser, setIsSuperAdminUser] = useState7(false);
|
|
2266
|
+
const [isCheckingSuperAdmin, setIsCheckingSuperAdmin] = useState7(false);
|
|
2267
|
+
useEffect4(() => {
|
|
2040
2268
|
const checkSuperAdminStatus = async () => {
|
|
2041
2269
|
if (!user?.id) {
|
|
2042
2270
|
setIsSuperAdminUser(false);
|
|
@@ -2066,7 +2294,7 @@ function PaceAppLayout({
|
|
|
2066
2294
|
);
|
|
2067
2295
|
const can = isSuperAdminUser ? true : canFromHook;
|
|
2068
2296
|
const hasPermission = enforcePermissions ? can : true;
|
|
2069
|
-
|
|
2297
|
+
useEffect4(() => {
|
|
2070
2298
|
if (!enforcePermissions) {
|
|
2071
2299
|
return;
|
|
2072
2300
|
}
|
|
@@ -2089,8 +2317,8 @@ function PaceAppLayout({
|
|
|
2089
2317
|
onPageAccessDenied(currentPageId, currentRoutePermission);
|
|
2090
2318
|
}
|
|
2091
2319
|
}, [enforcePermissions, can, isCheckingPermission, isCheckingSuperAdmin, isSuperAdminUser, currentPageId, currentRoutePermission, user?.id, strictMode, auditLog, onPageAccessDenied, onStrictModeViolation]);
|
|
2092
|
-
const [filteredMenuItems, setFilteredMenuItems] =
|
|
2093
|
-
|
|
2320
|
+
const [filteredMenuItems, setFilteredMenuItems] = useState7(baseMenuItems);
|
|
2321
|
+
useEffect4(() => {
|
|
2094
2322
|
let isMounted = true;
|
|
2095
2323
|
const filterItems = async () => {
|
|
2096
2324
|
if (!user?.id) {
|
|
@@ -2116,7 +2344,7 @@ function PaceAppLayout({
|
|
|
2116
2344
|
return;
|
|
2117
2345
|
}
|
|
2118
2346
|
try {
|
|
2119
|
-
const { isSuperAdmin: isSuperAdmin2 } = await import("./api-
|
|
2347
|
+
const { isSuperAdmin: isSuperAdmin2 } = await import("./api-YP7XD5L6.js");
|
|
2120
2348
|
const isSuper = await isSuperAdmin2(user.id);
|
|
2121
2349
|
if (isSuper) {
|
|
2122
2350
|
if (isMounted) {
|
|
@@ -2131,7 +2359,7 @@ function PaceAppLayout({
|
|
|
2131
2359
|
}
|
|
2132
2360
|
}
|
|
2133
2361
|
try {
|
|
2134
|
-
const { getPermissionMap } = await import("./api-
|
|
2362
|
+
const { getPermissionMap } = await import("./api-YP7XD5L6.js");
|
|
2135
2363
|
const permissionScope = {
|
|
2136
2364
|
organisationId: currentScope.organisationId,
|
|
2137
2365
|
eventId: currentScope.eventId,
|
|
@@ -2165,7 +2393,7 @@ function PaceAppLayout({
|
|
|
2165
2393
|
isMounted = false;
|
|
2166
2394
|
};
|
|
2167
2395
|
}, [baseMenuItems, pageIdMapping, routePermissions, defaultPermission, can, user?.id, scope, scopeLoading, contextAppId, resolvedScope?.appId, selectedOrganisation?.id]);
|
|
2168
|
-
|
|
2396
|
+
useEffect4(() => {
|
|
2169
2397
|
if (!roleBasedRouting || routeConfig.length === 0) return;
|
|
2170
2398
|
let isMounted = true;
|
|
2171
2399
|
const checkRouteAccess = async () => {
|
|
@@ -2187,7 +2415,7 @@ function PaceAppLayout({
|
|
|
2187
2415
|
let hasAccess = true;
|
|
2188
2416
|
if (currentRoute.pageId && currentRoute.permissions && currentRoute.permissions.length > 0) {
|
|
2189
2417
|
try {
|
|
2190
|
-
const { isPermittedCached } = await import("./api-
|
|
2418
|
+
const { isPermittedCached } = await import("./api-YP7XD5L6.js");
|
|
2191
2419
|
const hasPagePermission = await isPermittedCached({
|
|
2192
2420
|
userId: user?.id || "",
|
|
2193
2421
|
scope,
|
|
@@ -2203,7 +2431,7 @@ function PaceAppLayout({
|
|
|
2203
2431
|
}
|
|
2204
2432
|
}
|
|
2205
2433
|
if (hasAccess && currentRoute.roles && currentRoute.roles.length > 0 && user?.id) {
|
|
2206
|
-
const { useUnifiedAuth: useUnifiedAuth2 } = await import("./UnifiedAuthProvider-
|
|
2434
|
+
const { useUnifiedAuth: useUnifiedAuth2 } = await import("./UnifiedAuthProvider-B76OWOAT.js");
|
|
2207
2435
|
hasAccess = true;
|
|
2208
2436
|
}
|
|
2209
2437
|
if (!isMounted) return;
|
|
@@ -2250,31 +2478,31 @@ function PaceAppLayout({
|
|
|
2250
2478
|
return {};
|
|
2251
2479
|
};
|
|
2252
2480
|
if (enforcePermissions && (isCheckingSuperAdmin || isCheckingPermission)) {
|
|
2253
|
-
return /* @__PURE__ */
|
|
2254
|
-
/* @__PURE__ */
|
|
2255
|
-
/* @__PURE__ */
|
|
2481
|
+
return /* @__PURE__ */ jsx19("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs13("div", { className: "text-center", children: [
|
|
2482
|
+
/* @__PURE__ */ jsx19("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-sec-900 mx-auto mb-4" }),
|
|
2483
|
+
/* @__PURE__ */ jsx19("p", { className: "text-sec-600", children: "Checking permissions..." })
|
|
2256
2484
|
] }) });
|
|
2257
2485
|
}
|
|
2258
2486
|
if (enforcePermissions && permissionError && !isSuperAdminUser) {
|
|
2259
|
-
return /* @__PURE__ */
|
|
2260
|
-
/* @__PURE__ */
|
|
2261
|
-
/* @__PURE__ */
|
|
2262
|
-
/* @__PURE__ */
|
|
2487
|
+
return /* @__PURE__ */ jsx19("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs13("div", { className: "text-center", children: [
|
|
2488
|
+
/* @__PURE__ */ jsx19("h2", { className: "text-xl font-semibold text-acc-600 mb-2", children: "Permission Error" }),
|
|
2489
|
+
/* @__PURE__ */ jsx19("p", { className: "text-sec-600 mb-4", children: permissionError.message }),
|
|
2490
|
+
/* @__PURE__ */ jsx19(Button, { onClick: () => navigate("/"), children: "Go Home" })
|
|
2263
2491
|
] }) });
|
|
2264
2492
|
}
|
|
2265
2493
|
if (enforcePermissions && hasPermission === false && !isCheckingSuperAdmin && !isSuperAdminUser) {
|
|
2266
2494
|
if (enforcePagePermissions && pagePermissionFallback) {
|
|
2267
|
-
return /* @__PURE__ */
|
|
2495
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children: pagePermissionFallback });
|
|
2268
2496
|
}
|
|
2269
2497
|
if (permissionFallback) {
|
|
2270
|
-
return /* @__PURE__ */
|
|
2498
|
+
return /* @__PURE__ */ jsx19(Fragment4, { children: permissionFallback });
|
|
2271
2499
|
}
|
|
2272
|
-
return /* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2274
|
-
/* @__PURE__ */
|
|
2275
|
-
/* @__PURE__ */
|
|
2276
|
-
/* @__PURE__ */
|
|
2277
|
-
/* @__PURE__ */
|
|
2500
|
+
return /* @__PURE__ */ jsx19("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs13("div", { className: "text-center", children: [
|
|
2501
|
+
/* @__PURE__ */ jsx19("h2", { className: "text-xl font-semibold text-acc-600 mb-2", children: "Access Denied" }),
|
|
2502
|
+
/* @__PURE__ */ jsx19("p", { className: "text-sec-600 mb-4", children: "You don't have permission to access this page." }),
|
|
2503
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex gap-2 justify-center", children: [
|
|
2504
|
+
/* @__PURE__ */ jsx19(Button, { onClick: () => navigate("/"), children: "Go Home" }),
|
|
2505
|
+
/* @__PURE__ */ jsx19(
|
|
2278
2506
|
Button,
|
|
2279
2507
|
{
|
|
2280
2508
|
variant: "outline",
|
|
@@ -2288,8 +2516,8 @@ function PaceAppLayout({
|
|
|
2288
2516
|
] })
|
|
2289
2517
|
] }) });
|
|
2290
2518
|
}
|
|
2291
|
-
return /* @__PURE__ */
|
|
2292
|
-
/* @__PURE__ */
|
|
2519
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
2520
|
+
/* @__PURE__ */ jsx19(
|
|
2293
2521
|
Header,
|
|
2294
2522
|
{
|
|
2295
2523
|
logo: customLogo || void 0,
|
|
@@ -2314,15 +2542,15 @@ function PaceAppLayout({
|
|
|
2314
2542
|
className: headerClassName || "sticky top-0 z-[40] w-full"
|
|
2315
2543
|
}
|
|
2316
2544
|
),
|
|
2317
|
-
/* @__PURE__ */
|
|
2318
|
-
/* @__PURE__ */
|
|
2545
|
+
/* @__PURE__ */ jsx19("main", { className: "px-4 w-[min(var(--app-width),100%)] mx-auto py-8", children: /* @__PURE__ */ jsx19(Outlet, {}) }),
|
|
2546
|
+
/* @__PURE__ */ jsx19(Footer, {})
|
|
2319
2547
|
] });
|
|
2320
2548
|
}
|
|
2321
2549
|
|
|
2322
2550
|
// src/components/PaceLoginPage/PaceLoginPage.tsx
|
|
2323
|
-
import { useEffect as
|
|
2551
|
+
import { useEffect as useEffect5, useState as useState8, useContext } from "react";
|
|
2324
2552
|
import { useNavigate as useNavigate2, useLocation as useLocation2 } from "react-router-dom";
|
|
2325
|
-
import { jsx as
|
|
2553
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2326
2554
|
var PaceLoginPage = ({
|
|
2327
2555
|
appName = "Pace",
|
|
2328
2556
|
onSuccessRedirectPath = "/",
|
|
@@ -2331,21 +2559,21 @@ var PaceLoginPage = ({
|
|
|
2331
2559
|
const { signIn, isAuthenticated, isLoading, authError, user, supabase } = useUnifiedAuth();
|
|
2332
2560
|
const navigate = useNavigate2();
|
|
2333
2561
|
const location = useLocation2();
|
|
2334
|
-
const [isSigningIn, setIsSigningIn] =
|
|
2335
|
-
const [accessError, setAccessError] =
|
|
2336
|
-
const [isCheckingAccess, setIsCheckingAccess] =
|
|
2562
|
+
const [isSigningIn, setIsSigningIn] = useState8(false);
|
|
2563
|
+
const [accessError, setAccessError] = useState8(null);
|
|
2564
|
+
const [isCheckingAccess, setIsCheckingAccess] = useState8(false);
|
|
2337
2565
|
const eventServiceContext = useContext(EventServiceContext);
|
|
2338
2566
|
const eventService = eventServiceContext?.eventService || null;
|
|
2339
|
-
|
|
2567
|
+
useEffect5(() => {
|
|
2340
2568
|
clearPalette();
|
|
2341
2569
|
}, []);
|
|
2342
|
-
|
|
2570
|
+
useEffect5(() => {
|
|
2343
2571
|
const isOnLoginPage = location.pathname === "/login" || location.pathname.startsWith("/login");
|
|
2344
2572
|
if (isOnLoginPage) {
|
|
2345
2573
|
clearPalette();
|
|
2346
2574
|
}
|
|
2347
2575
|
}, [location.pathname]);
|
|
2348
|
-
|
|
2576
|
+
useEffect5(() => {
|
|
2349
2577
|
const restoreEvent = async () => {
|
|
2350
2578
|
try {
|
|
2351
2579
|
const isOnLoginPage = window.location.pathname === "/login" || window.location.pathname.startsWith("/login");
|
|
@@ -2361,7 +2589,7 @@ var PaceLoginPage = ({
|
|
|
2361
2589
|
}, 100);
|
|
2362
2590
|
return () => clearTimeout(timeoutId);
|
|
2363
2591
|
}, [eventService]);
|
|
2364
|
-
|
|
2592
|
+
useEffect5(() => {
|
|
2365
2593
|
if (!requireAppAccess || !isAuthenticated || isLoading || !user || !supabase) {
|
|
2366
2594
|
return;
|
|
2367
2595
|
}
|
|
@@ -2453,8 +2681,8 @@ var PaceLoginPage = ({
|
|
|
2453
2681
|
setIsSigningIn(false);
|
|
2454
2682
|
}
|
|
2455
2683
|
};
|
|
2456
|
-
return /* @__PURE__ */
|
|
2457
|
-
/* @__PURE__ */
|
|
2684
|
+
return /* @__PURE__ */ jsxs14("main", { className: "min-h-screen grid mx-auto w-fit content-center justify-items-center gap-y-8", "aria-label": `${appName} Login Page`, children: [
|
|
2685
|
+
/* @__PURE__ */ jsx20(
|
|
2458
2686
|
"img",
|
|
2459
2687
|
{
|
|
2460
2688
|
src: `/${appName.toLowerCase()}_logo_square.svg`,
|
|
@@ -2462,7 +2690,7 @@ var PaceLoginPage = ({
|
|
|
2462
2690
|
className: "h-48"
|
|
2463
2691
|
}
|
|
2464
2692
|
),
|
|
2465
|
-
/* @__PURE__ */
|
|
2693
|
+
/* @__PURE__ */ jsx20(
|
|
2466
2694
|
LoginForm,
|
|
2467
2695
|
{
|
|
2468
2696
|
className: "w-md",
|
|
@@ -2476,20 +2704,20 @@ var PaceLoginPage = ({
|
|
|
2476
2704
|
),
|
|
2477
2705
|
(() => {
|
|
2478
2706
|
const benign = !!(authError && (authError.name === "AuthSessionMissingError" || /Auth session missing/i.test(authError.message)));
|
|
2479
|
-
return authError && !benign ? /* @__PURE__ */
|
|
2707
|
+
return authError && !benign ? /* @__PURE__ */ jsx20("em", { className: "mt-4 text-destructive text-center", children: authError.message }) : null;
|
|
2480
2708
|
})(),
|
|
2481
|
-
accessError && /* @__PURE__ */
|
|
2482
|
-
isCheckingAccess && /* @__PURE__ */
|
|
2709
|
+
accessError && /* @__PURE__ */ jsx20("em", { className: "mt-4 text-destructive text-center", children: accessError }),
|
|
2710
|
+
isCheckingAccess && /* @__PURE__ */ jsx20("em", { className: "mt-4 text-muted-foreground text-center", children: "Checking permissions..." })
|
|
2483
2711
|
] });
|
|
2484
2712
|
};
|
|
2485
2713
|
|
|
2486
2714
|
// src/components/SessionRestorationLoader/SessionRestorationLoader.tsx
|
|
2487
|
-
import { jsx as
|
|
2715
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2488
2716
|
var SessionRestorationLoader = ({
|
|
2489
2717
|
message = "Restoring session...",
|
|
2490
2718
|
className
|
|
2491
2719
|
}) => {
|
|
2492
|
-
return /* @__PURE__ */
|
|
2720
|
+
return /* @__PURE__ */ jsxs15(
|
|
2493
2721
|
"div",
|
|
2494
2722
|
{
|
|
2495
2723
|
className: cn(
|
|
@@ -2500,17 +2728,17 @@ var SessionRestorationLoader = ({
|
|
|
2500
2728
|
"aria-live": "polite",
|
|
2501
2729
|
"aria-label": message,
|
|
2502
2730
|
children: [
|
|
2503
|
-
/* @__PURE__ */
|
|
2504
|
-
/* @__PURE__ */
|
|
2731
|
+
/* @__PURE__ */ jsx21(LoadingSpinner, { size: "lg" }),
|
|
2732
|
+
/* @__PURE__ */ jsx21("div", { className: "text-sm text-sec-600", children: message })
|
|
2505
2733
|
]
|
|
2506
2734
|
}
|
|
2507
2735
|
);
|
|
2508
2736
|
};
|
|
2509
2737
|
|
|
2510
2738
|
// src/components/ProtectedRoute/ProtectedRoute.tsx
|
|
2511
|
-
import { useMemo as useMemo6, useEffect as
|
|
2739
|
+
import { useMemo as useMemo6, useEffect as useEffect6, useRef as useRef4, useState as useState9 } from "react";
|
|
2512
2740
|
import { Navigate, Outlet as Outlet2 } from "react-router-dom";
|
|
2513
|
-
import { jsx as
|
|
2741
|
+
import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2514
2742
|
function ProtectedRoute({
|
|
2515
2743
|
requireEvent = false,
|
|
2516
2744
|
allowSuperAdminBypass = false,
|
|
@@ -2525,17 +2753,17 @@ function ProtectedRoute({
|
|
|
2525
2753
|
const eventLoading = requireEvent ? eventsContext.isLoading || false : false;
|
|
2526
2754
|
const sessionRestoration = useSessionRestoration();
|
|
2527
2755
|
usePreventTabReload({ enabled: true, gracePeriodMs: 2e3 });
|
|
2528
|
-
const wasAuthenticatedRef =
|
|
2529
|
-
const [shouldRedirect, setShouldRedirect] =
|
|
2530
|
-
const tabJustBecameVisibleRef =
|
|
2531
|
-
|
|
2756
|
+
const wasAuthenticatedRef = useRef4(false);
|
|
2757
|
+
const [shouldRedirect, setShouldRedirect] = useState9(false);
|
|
2758
|
+
const tabJustBecameVisibleRef = useRef4(false);
|
|
2759
|
+
useEffect6(() => {
|
|
2532
2760
|
if (isAuthenticated) {
|
|
2533
2761
|
wasAuthenticatedRef.current = true;
|
|
2534
2762
|
setShouldRedirect(false);
|
|
2535
2763
|
tabJustBecameVisibleRef.current = false;
|
|
2536
2764
|
}
|
|
2537
2765
|
}, [isAuthenticated]);
|
|
2538
|
-
|
|
2766
|
+
useEffect6(() => {
|
|
2539
2767
|
if (typeof document === "undefined") return;
|
|
2540
2768
|
let timeoutId = null;
|
|
2541
2769
|
let wasHidden = document.hidden;
|
|
@@ -2579,7 +2807,7 @@ function ProtectedRoute({
|
|
|
2579
2807
|
}
|
|
2580
2808
|
};
|
|
2581
2809
|
}, [isAuthenticated]);
|
|
2582
|
-
|
|
2810
|
+
useEffect6(() => {
|
|
2583
2811
|
if (isAuthenticated) {
|
|
2584
2812
|
setShouldRedirect(false);
|
|
2585
2813
|
tabJustBecameVisibleRef.current = false;
|
|
@@ -2594,13 +2822,13 @@ function ProtectedRoute({
|
|
|
2594
2822
|
sessionRestoration.hasTimedOut
|
|
2595
2823
|
]);
|
|
2596
2824
|
if (isRestoringSession) {
|
|
2597
|
-
return /* @__PURE__ */
|
|
2825
|
+
return /* @__PURE__ */ jsx22(SessionRestorationLoader, {});
|
|
2598
2826
|
}
|
|
2599
2827
|
if (requireEvent && eventLoading) {
|
|
2600
|
-
return /* @__PURE__ */
|
|
2828
|
+
return /* @__PURE__ */ jsx22(Outlet2, {});
|
|
2601
2829
|
}
|
|
2602
2830
|
if (isLoading && !sessionRestoration.hasTimedOut) {
|
|
2603
|
-
return loadingFallback || /* @__PURE__ */
|
|
2831
|
+
return loadingFallback || /* @__PURE__ */ jsx22("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh" }, children: /* @__PURE__ */ jsx22(LoadingSpinner, {}) });
|
|
2604
2832
|
}
|
|
2605
2833
|
if (!isAuthenticated) {
|
|
2606
2834
|
if (sessionRestoration.hasTimedOut || sessionRestoration.restorationError) {
|
|
@@ -2608,47 +2836,47 @@ function ProtectedRoute({
|
|
|
2608
2836
|
timedOut: sessionRestoration.hasTimedOut,
|
|
2609
2837
|
error: sessionRestoration.restorationError?.message
|
|
2610
2838
|
});
|
|
2611
|
-
return /* @__PURE__ */
|
|
2839
|
+
return /* @__PURE__ */ jsx22(Navigate, { to: loginPath, replace: true });
|
|
2612
2840
|
}
|
|
2613
2841
|
if (!wasAuthenticatedRef.current) {
|
|
2614
|
-
return /* @__PURE__ */
|
|
2842
|
+
return /* @__PURE__ */ jsx22(Navigate, { to: loginPath, replace: true });
|
|
2615
2843
|
}
|
|
2616
2844
|
const isTabVisible = typeof document !== "undefined" && !document.hidden;
|
|
2617
2845
|
if (tabJustBecameVisibleRef.current || isTabVisible && wasAuthenticatedRef.current && isLoading) {
|
|
2618
|
-
return loadingFallback || /* @__PURE__ */
|
|
2846
|
+
return loadingFallback || /* @__PURE__ */ jsx22("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh" }, children: /* @__PURE__ */ jsx22(LoadingSpinner, {}) });
|
|
2619
2847
|
}
|
|
2620
2848
|
if (shouldRedirect) {
|
|
2621
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ jsx22(Navigate, { to: loginPath, replace: true });
|
|
2622
2850
|
}
|
|
2623
2851
|
if (isLoading) {
|
|
2624
|
-
return loadingFallback || /* @__PURE__ */
|
|
2852
|
+
return loadingFallback || /* @__PURE__ */ jsx22("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh" }, children: /* @__PURE__ */ jsx22(LoadingSpinner, {}) });
|
|
2625
2853
|
}
|
|
2626
|
-
return /* @__PURE__ */
|
|
2854
|
+
return /* @__PURE__ */ jsx22(Navigate, { to: loginPath, replace: true });
|
|
2627
2855
|
}
|
|
2628
2856
|
if (!requireEvent) {
|
|
2629
|
-
return /* @__PURE__ */
|
|
2857
|
+
return /* @__PURE__ */ jsx22(Outlet2, {});
|
|
2630
2858
|
}
|
|
2631
2859
|
if (!events || events.length === 0) {
|
|
2632
|
-
return noEventsFallback || /* @__PURE__ */
|
|
2633
|
-
/* @__PURE__ */
|
|
2634
|
-
/* @__PURE__ */
|
|
2860
|
+
return noEventsFallback || /* @__PURE__ */ jsx22("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh", padding: "2rem" }, children: /* @__PURE__ */ jsxs16(Alert, { variant: "destructive", className: "max-w-md", children: [
|
|
2861
|
+
/* @__PURE__ */ jsx22(AlertTitle, { children: "No Events Available" }),
|
|
2862
|
+
/* @__PURE__ */ jsx22(AlertDescription, { children: "You don't have access to any events. Please contact your administrator if you believe this is an error." })
|
|
2635
2863
|
] }) });
|
|
2636
2864
|
}
|
|
2637
2865
|
if (!selectedEvent) {
|
|
2638
2866
|
logger.debug("ProtectedRoute", "Events available but none selected - allowing render so selector is visible");
|
|
2639
|
-
return /* @__PURE__ */
|
|
2867
|
+
return /* @__PURE__ */ jsx22(Outlet2, {});
|
|
2640
2868
|
}
|
|
2641
|
-
return /* @__PURE__ */
|
|
2869
|
+
return /* @__PURE__ */ jsx22(Outlet2, {});
|
|
2642
2870
|
}
|
|
2643
2871
|
|
|
2644
2872
|
// src/hooks/useFileReference.ts
|
|
2645
|
-
import { useState as
|
|
2873
|
+
import { useState as useState10, useCallback as useCallback6, useEffect as useEffect7, useRef as useRef5, useMemo as useMemo7 } from "react";
|
|
2646
2874
|
var log = createLogger("useFileReference");
|
|
2647
2875
|
function useFileReference(supabase) {
|
|
2648
|
-
const [isLoading, setIsLoading] =
|
|
2649
|
-
const [error, setError] =
|
|
2876
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
2877
|
+
const [error, setError] = useState10(null);
|
|
2650
2878
|
const service = useMemo7(() => createFileReferenceService(supabase), [supabase]);
|
|
2651
|
-
const uploadFile =
|
|
2879
|
+
const uploadFile = useCallback6(async (options, file) => {
|
|
2652
2880
|
setIsLoading(true);
|
|
2653
2881
|
setError(null);
|
|
2654
2882
|
try {
|
|
@@ -2662,7 +2890,7 @@ function useFileReference(supabase) {
|
|
|
2662
2890
|
setIsLoading(false);
|
|
2663
2891
|
}
|
|
2664
2892
|
}, [supabase]);
|
|
2665
|
-
const getFileReference =
|
|
2893
|
+
const getFileReference = useCallback6(async (table_name, record_id, organisation_id) => {
|
|
2666
2894
|
setIsLoading(true);
|
|
2667
2895
|
setError(null);
|
|
2668
2896
|
try {
|
|
@@ -2675,7 +2903,7 @@ function useFileReference(supabase) {
|
|
|
2675
2903
|
setIsLoading(false);
|
|
2676
2904
|
}
|
|
2677
2905
|
}, [service]);
|
|
2678
|
-
const getFileUrl =
|
|
2906
|
+
const getFileUrl = useCallback6(async (table_name, record_id, organisation_id) => {
|
|
2679
2907
|
setIsLoading(true);
|
|
2680
2908
|
setError(null);
|
|
2681
2909
|
try {
|
|
@@ -2688,7 +2916,7 @@ function useFileReference(supabase) {
|
|
|
2688
2916
|
setIsLoading(false);
|
|
2689
2917
|
}
|
|
2690
2918
|
}, [service]);
|
|
2691
|
-
const
|
|
2919
|
+
const getSignedUrl3 = useCallback6(async (table_name, record_id, organisation_id, expires_in) => {
|
|
2692
2920
|
setIsLoading(true);
|
|
2693
2921
|
setError(null);
|
|
2694
2922
|
try {
|
|
@@ -2701,7 +2929,7 @@ function useFileReference(supabase) {
|
|
|
2701
2929
|
setIsLoading(false);
|
|
2702
2930
|
}
|
|
2703
2931
|
}, [service]);
|
|
2704
|
-
const updateFileReference =
|
|
2932
|
+
const updateFileReference = useCallback6(async (id, updates) => {
|
|
2705
2933
|
setIsLoading(true);
|
|
2706
2934
|
setError(null);
|
|
2707
2935
|
try {
|
|
@@ -2714,7 +2942,7 @@ function useFileReference(supabase) {
|
|
|
2714
2942
|
setIsLoading(false);
|
|
2715
2943
|
}
|
|
2716
2944
|
}, [service]);
|
|
2717
|
-
const deleteFileReference =
|
|
2945
|
+
const deleteFileReference = useCallback6(async (table_name, record_id, organisation_id, delete_file) => {
|
|
2718
2946
|
setIsLoading(true);
|
|
2719
2947
|
setError(null);
|
|
2720
2948
|
try {
|
|
@@ -2727,7 +2955,7 @@ function useFileReference(supabase) {
|
|
|
2727
2955
|
setIsLoading(false);
|
|
2728
2956
|
}
|
|
2729
2957
|
}, [service]);
|
|
2730
|
-
const listFileReferences =
|
|
2958
|
+
const listFileReferences = useCallback6(async (table_name, record_id, organisation_id) => {
|
|
2731
2959
|
setIsLoading(true);
|
|
2732
2960
|
setError(null);
|
|
2733
2961
|
try {
|
|
@@ -2740,7 +2968,7 @@ function useFileReference(supabase) {
|
|
|
2740
2968
|
setIsLoading(false);
|
|
2741
2969
|
}
|
|
2742
2970
|
}, [service]);
|
|
2743
|
-
const getFileCount =
|
|
2971
|
+
const getFileCount = useCallback6(async (table_name, record_id, organisation_id) => {
|
|
2744
2972
|
setIsLoading(true);
|
|
2745
2973
|
setError(null);
|
|
2746
2974
|
try {
|
|
@@ -2753,7 +2981,7 @@ function useFileReference(supabase) {
|
|
|
2753
2981
|
setIsLoading(false);
|
|
2754
2982
|
}
|
|
2755
2983
|
}, [service]);
|
|
2756
|
-
const getFileReferenceById =
|
|
2984
|
+
const getFileReferenceById = useCallback6(async (id, organisation_id) => {
|
|
2757
2985
|
setIsLoading(true);
|
|
2758
2986
|
setError(null);
|
|
2759
2987
|
try {
|
|
@@ -2766,7 +2994,7 @@ function useFileReference(supabase) {
|
|
|
2766
2994
|
setIsLoading(false);
|
|
2767
2995
|
}
|
|
2768
2996
|
}, [service]);
|
|
2769
|
-
const getFilesByCategory =
|
|
2997
|
+
const getFilesByCategory = useCallback6(async (table_name, record_id, category, organisation_id) => {
|
|
2770
2998
|
setIsLoading(true);
|
|
2771
2999
|
setError(null);
|
|
2772
3000
|
try {
|
|
@@ -2779,7 +3007,7 @@ function useFileReference(supabase) {
|
|
|
2779
3007
|
setIsLoading(false);
|
|
2780
3008
|
}
|
|
2781
3009
|
}, [service]);
|
|
2782
|
-
const clearError =
|
|
3010
|
+
const clearError = useCallback6(() => {
|
|
2783
3011
|
setError(null);
|
|
2784
3012
|
}, []);
|
|
2785
3013
|
return {
|
|
@@ -2789,7 +3017,7 @@ function useFileReference(supabase) {
|
|
|
2789
3017
|
getFileReference,
|
|
2790
3018
|
getFileReferenceById,
|
|
2791
3019
|
getFileUrl,
|
|
2792
|
-
getSignedUrl:
|
|
3020
|
+
getSignedUrl: getSignedUrl3,
|
|
2793
3021
|
updateFileReference,
|
|
2794
3022
|
deleteFileReference,
|
|
2795
3023
|
listFileReferences,
|
|
@@ -2810,32 +3038,32 @@ function useFileReferenceForRecord(supabase, table_name, record_id, organisation
|
|
|
2810
3038
|
getFileCount,
|
|
2811
3039
|
clearError
|
|
2812
3040
|
} = useFileReference(supabase);
|
|
2813
|
-
const [fileUrl, setFileUrl] =
|
|
2814
|
-
const [fileReference, setFileReference] =
|
|
2815
|
-
const [fileReferences, setFileReferences] =
|
|
2816
|
-
const [fileCount, setFileCount] =
|
|
2817
|
-
const urlRefreshIntervalRef =
|
|
2818
|
-
const loadFileReference =
|
|
3041
|
+
const [fileUrl, setFileUrl] = useState10(null);
|
|
3042
|
+
const [fileReference, setFileReference] = useState10(null);
|
|
3043
|
+
const [fileReferences, setFileReferences] = useState10([]);
|
|
3044
|
+
const [fileCount, setFileCount] = useState10(0);
|
|
3045
|
+
const urlRefreshIntervalRef = useRef5(null);
|
|
3046
|
+
const loadFileReference = useCallback6(async () => {
|
|
2819
3047
|
const reference = await getFileReference(table_name, record_id, organisation_id);
|
|
2820
3048
|
setFileReference(reference);
|
|
2821
3049
|
return reference;
|
|
2822
3050
|
}, [getFileReference, table_name, record_id, organisation_id]);
|
|
2823
|
-
const loadFileUrl =
|
|
3051
|
+
const loadFileUrl = useCallback6(async () => {
|
|
2824
3052
|
const url = await getFileUrl(table_name, record_id, organisation_id);
|
|
2825
3053
|
setFileUrl(url);
|
|
2826
3054
|
return url;
|
|
2827
3055
|
}, [getFileUrl, table_name, record_id, organisation_id]);
|
|
2828
|
-
const loadFileReferences =
|
|
3056
|
+
const loadFileReferences = useCallback6(async () => {
|
|
2829
3057
|
const references = await listFileReferences(table_name, record_id, organisation_id);
|
|
2830
3058
|
setFileReferences(references);
|
|
2831
3059
|
return references;
|
|
2832
3060
|
}, [listFileReferences, table_name, record_id, organisation_id]);
|
|
2833
|
-
const loadFileCount =
|
|
3061
|
+
const loadFileCount = useCallback6(async () => {
|
|
2834
3062
|
const count = await getFileCount(table_name, record_id, organisation_id);
|
|
2835
3063
|
setFileCount(count);
|
|
2836
3064
|
return count;
|
|
2837
3065
|
}, [getFileCount, table_name, record_id, organisation_id]);
|
|
2838
|
-
const deleteFile =
|
|
3066
|
+
const deleteFile = useCallback6(async (delete_file) => {
|
|
2839
3067
|
const success = await deleteFileReference(table_name, record_id, organisation_id, delete_file);
|
|
2840
3068
|
if (success) {
|
|
2841
3069
|
setFileReference(null);
|
|
@@ -2844,7 +3072,7 @@ function useFileReferenceForRecord(supabase, table_name, record_id, organisation
|
|
|
2844
3072
|
}
|
|
2845
3073
|
return success;
|
|
2846
3074
|
}, [deleteFileReference, table_name, record_id, organisation_id, loadFileCount]);
|
|
2847
|
-
|
|
3075
|
+
useEffect7(() => {
|
|
2848
3076
|
if (!fileReference || fileReference.is_public) {
|
|
2849
3077
|
if (urlRefreshIntervalRef.current) {
|
|
2850
3078
|
clearInterval(urlRefreshIntervalRef.current);
|
|
@@ -2885,9 +3113,9 @@ function useFileReferenceById(supabase, fileReferenceId, organisationId) {
|
|
|
2885
3113
|
getFileReferenceById,
|
|
2886
3114
|
clearError
|
|
2887
3115
|
} = useFileReference(supabase);
|
|
2888
|
-
const [fileReference, setFileReference] =
|
|
2889
|
-
const [fileUrl, setFileUrl] =
|
|
2890
|
-
const loadFileReference =
|
|
3116
|
+
const [fileReference, setFileReference] = useState10(null);
|
|
3117
|
+
const [fileUrl, setFileUrl] = useState10(null);
|
|
3118
|
+
const loadFileReference = useCallback6(async () => {
|
|
2891
3119
|
if (!fileReferenceId || !organisationId) {
|
|
2892
3120
|
setFileReference(null);
|
|
2893
3121
|
setFileUrl(null);
|
|
@@ -2897,10 +3125,10 @@ function useFileReferenceById(supabase, fileReferenceId, organisationId) {
|
|
|
2897
3125
|
setFileReference(reference);
|
|
2898
3126
|
return reference;
|
|
2899
3127
|
}, [getFileReferenceById, fileReferenceId, organisationId]);
|
|
2900
|
-
|
|
3128
|
+
useEffect7(() => {
|
|
2901
3129
|
loadFileReference();
|
|
2902
3130
|
}, [loadFileReference]);
|
|
2903
|
-
|
|
3131
|
+
useEffect7(() => {
|
|
2904
3132
|
if (!fileReference || !fileReferenceId || !organisationId) {
|
|
2905
3133
|
setFileUrl(null);
|
|
2906
3134
|
return;
|
|
@@ -2932,9 +3160,9 @@ function useFilesByCategory(supabase, table_name, record_id, category, organisat
|
|
|
2932
3160
|
getFilesByCategory,
|
|
2933
3161
|
clearError
|
|
2934
3162
|
} = useFileReference(supabase);
|
|
2935
|
-
const [fileReferences, setFileReferences] =
|
|
2936
|
-
const [fileUrls, setFileUrls] =
|
|
2937
|
-
const loadFiles =
|
|
3163
|
+
const [fileReferences, setFileReferences] = useState10([]);
|
|
3164
|
+
const [fileUrls, setFileUrls] = useState10(/* @__PURE__ */ new Map());
|
|
3165
|
+
const loadFiles = useCallback6(async () => {
|
|
2938
3166
|
if (!category || !organisation_id) {
|
|
2939
3167
|
setFileReferences([]);
|
|
2940
3168
|
setFileUrls(/* @__PURE__ */ new Map());
|
|
@@ -2942,31 +3170,15 @@ function useFilesByCategory(supabase, table_name, record_id, category, organisat
|
|
|
2942
3170
|
}
|
|
2943
3171
|
const files = await getFilesByCategory(table_name, record_id, category, organisation_id);
|
|
2944
3172
|
setFileReferences(files);
|
|
2945
|
-
const urlMap =
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
url = getPublicUrl(supabase, fileRef.file_path, true);
|
|
2951
|
-
} else {
|
|
2952
|
-
const signedUrlResult = await getSignedUrl(supabase, fileRef.file_path, {
|
|
2953
|
-
appName: "file-reference",
|
|
2954
|
-
orgId: organisation_id,
|
|
2955
|
-
expiresIn: 3600
|
|
2956
|
-
});
|
|
2957
|
-
url = signedUrlResult?.url || null;
|
|
2958
|
-
}
|
|
2959
|
-
if (url) {
|
|
2960
|
-
urlMap.set(fileRef.id, url);
|
|
2961
|
-
}
|
|
2962
|
-
} catch (err) {
|
|
2963
|
-
log.error(`Failed to load URL for file ${fileRef.id}:`, err);
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
3173
|
+
const urlMap = await generateFileUrlsBatch(supabase, files, {
|
|
3174
|
+
appName: "file-reference",
|
|
3175
|
+
orgId: organisation_id,
|
|
3176
|
+
expiresIn: 3600
|
|
3177
|
+
});
|
|
2966
3178
|
setFileUrls(urlMap);
|
|
2967
3179
|
return files;
|
|
2968
3180
|
}, [table_name, record_id, category, organisation_id, supabase, getFilesByCategory]);
|
|
2969
|
-
|
|
3181
|
+
useEffect7(() => {
|
|
2970
3182
|
loadFiles();
|
|
2971
3183
|
}, [loadFiles]);
|
|
2972
3184
|
return {
|
|
@@ -2980,8 +3192,8 @@ function useFilesByCategory(supabase, table_name, record_id, category, organisat
|
|
|
2980
3192
|
}
|
|
2981
3193
|
|
|
2982
3194
|
// src/components/FileUpload/FileUpload.tsx
|
|
2983
|
-
import { useState as
|
|
2984
|
-
import { Fragment as Fragment5, jsx as
|
|
3195
|
+
import { useState as useState11, useCallback as useCallback7, useRef as useRef6, useEffect as useEffect8, useMemo as useMemo8 } from "react";
|
|
3196
|
+
import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2985
3197
|
function FileUpload({
|
|
2986
3198
|
supabase,
|
|
2987
3199
|
table_name,
|
|
@@ -3006,14 +3218,14 @@ function FileUpload({
|
|
|
3006
3218
|
onProgress,
|
|
3007
3219
|
children
|
|
3008
3220
|
}) {
|
|
3009
|
-
const [isDragging, setIsDragging] =
|
|
3010
|
-
const [uploadStates, setUploadStates] =
|
|
3011
|
-
const [resolvedAppId, setResolvedAppId] =
|
|
3012
|
-
const [isResolvingAppId, setIsResolvingAppId] =
|
|
3013
|
-
const [appIdError, setAppIdError] =
|
|
3014
|
-
const fileInputRef =
|
|
3221
|
+
const [isDragging, setIsDragging] = useState11(false);
|
|
3222
|
+
const [uploadStates, setUploadStates] = useState11(/* @__PURE__ */ new Map());
|
|
3223
|
+
const [resolvedAppId, setResolvedAppId] = useState11(app_id || null);
|
|
3224
|
+
const [isResolvingAppId, setIsResolvingAppId] = useState11(!app_id);
|
|
3225
|
+
const [appIdError, setAppIdError] = useState11(null);
|
|
3226
|
+
const fileInputRef = useRef6(null);
|
|
3015
3227
|
const { uploadFile, isLoading, error } = useFileReference(supabase);
|
|
3016
|
-
|
|
3228
|
+
useEffect8(() => {
|
|
3017
3229
|
if (app_id) {
|
|
3018
3230
|
setResolvedAppId(app_id);
|
|
3019
3231
|
setIsResolvingAppId(false);
|
|
@@ -3056,7 +3268,7 @@ function FileUpload({
|
|
|
3056
3268
|
const isDisabled = useMemo8(() => {
|
|
3057
3269
|
return disabled || isUploading || isResolvingAppId || !resolvedAppId;
|
|
3058
3270
|
}, [disabled, isUploading, isResolvingAppId, resolvedAppId]);
|
|
3059
|
-
const generatePreview =
|
|
3271
|
+
const generatePreview = useCallback7((file) => {
|
|
3060
3272
|
return new Promise((resolve) => {
|
|
3061
3273
|
if (!file.type.startsWith("image/")) {
|
|
3062
3274
|
resolve(null);
|
|
@@ -3070,7 +3282,7 @@ function FileUpload({
|
|
|
3070
3282
|
reader.readAsDataURL(file);
|
|
3071
3283
|
});
|
|
3072
3284
|
}, []);
|
|
3073
|
-
const validateFile =
|
|
3285
|
+
const validateFile = useCallback7((file) => {
|
|
3074
3286
|
if (file.size > maxSize) {
|
|
3075
3287
|
return `File "${file.name}" exceeds maximum size of ${Math.round(maxSize / 1024 / 1024)}MB`;
|
|
3076
3288
|
}
|
|
@@ -3094,7 +3306,7 @@ function FileUpload({
|
|
|
3094
3306
|
}
|
|
3095
3307
|
return null;
|
|
3096
3308
|
}, [accept, maxSize]);
|
|
3097
|
-
const handleFileSelect =
|
|
3309
|
+
const handleFileSelect = useCallback7(async (files) => {
|
|
3098
3310
|
if (!files || files.length === 0) return;
|
|
3099
3311
|
const fileArray = Array.from(files);
|
|
3100
3312
|
const validationErrors = [];
|
|
@@ -3269,19 +3481,19 @@ function FileUpload({
|
|
|
3269
3481
|
}
|
|
3270
3482
|
}
|
|
3271
3483
|
}, [uploadFile, table_name, record_id, organisation_id, resolvedAppId, category, folder, isPublic, maxSize, onUploadSuccess, onUploadError, onProgress, validateFile, generatePreview, showPreview, appIdError]);
|
|
3272
|
-
const handleDragOver =
|
|
3484
|
+
const handleDragOver = useCallback7((e) => {
|
|
3273
3485
|
e.preventDefault();
|
|
3274
3486
|
e.stopPropagation();
|
|
3275
3487
|
if (!isDisabled) {
|
|
3276
3488
|
setIsDragging(true);
|
|
3277
3489
|
}
|
|
3278
3490
|
}, [isDisabled]);
|
|
3279
|
-
const handleDragLeave =
|
|
3491
|
+
const handleDragLeave = useCallback7((e) => {
|
|
3280
3492
|
e.preventDefault();
|
|
3281
3493
|
e.stopPropagation();
|
|
3282
3494
|
setIsDragging(false);
|
|
3283
3495
|
}, []);
|
|
3284
|
-
const handleDrop =
|
|
3496
|
+
const handleDrop = useCallback7((e) => {
|
|
3285
3497
|
e.preventDefault();
|
|
3286
3498
|
e.stopPropagation();
|
|
3287
3499
|
setIsDragging(false);
|
|
@@ -3289,13 +3501,13 @@ function FileUpload({
|
|
|
3289
3501
|
const files = e.dataTransfer.files;
|
|
3290
3502
|
handleFileSelect(files);
|
|
3291
3503
|
}, [isDisabled, handleFileSelect]);
|
|
3292
|
-
const handleFileInputChange =
|
|
3504
|
+
const handleFileInputChange = useCallback7((e) => {
|
|
3293
3505
|
handleFileSelect(e.target.files);
|
|
3294
3506
|
if (e.target) {
|
|
3295
3507
|
e.target.value = "";
|
|
3296
3508
|
}
|
|
3297
3509
|
}, [handleFileSelect]);
|
|
3298
|
-
const handleClick =
|
|
3510
|
+
const handleClick = useCallback7(() => {
|
|
3299
3511
|
if (!isDisabled && fileInputRef.current) {
|
|
3300
3512
|
fileInputRef.current.click();
|
|
3301
3513
|
}
|
|
@@ -3309,8 +3521,8 @@ function FileUpload({
|
|
|
3309
3521
|
};
|
|
3310
3522
|
const dragClasses = isDragging ? "border-main-500 bg-main-50" : "border-sec-300 hover:border-sec-400";
|
|
3311
3523
|
const disabledClasses = isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer hover:bg-sec-50";
|
|
3312
|
-
return /* @__PURE__ */
|
|
3313
|
-
/* @__PURE__ */
|
|
3524
|
+
return /* @__PURE__ */ jsxs17("div", { className: `space-y-4 ${className}`, children: [
|
|
3525
|
+
/* @__PURE__ */ jsxs17(
|
|
3314
3526
|
"div",
|
|
3315
3527
|
{
|
|
3316
3528
|
role: "button",
|
|
@@ -3329,8 +3541,8 @@ function FileUpload({
|
|
|
3329
3541
|
}
|
|
3330
3542
|
} : void 0,
|
|
3331
3543
|
children: [
|
|
3332
|
-
children || /* @__PURE__ */
|
|
3333
|
-
/* @__PURE__ */
|
|
3544
|
+
children || /* @__PURE__ */ jsxs17("div", { className: "space-y-2", children: [
|
|
3545
|
+
/* @__PURE__ */ jsx23(
|
|
3334
3546
|
"input",
|
|
3335
3547
|
{
|
|
3336
3548
|
ref: fileInputRef,
|
|
@@ -3343,64 +3555,64 @@ function FileUpload({
|
|
|
3343
3555
|
"data-testid": "file-input"
|
|
3344
3556
|
}
|
|
3345
3557
|
),
|
|
3346
|
-
/* @__PURE__ */
|
|
3347
|
-
/* @__PURE__ */
|
|
3558
|
+
/* @__PURE__ */ jsx23("div", { className: "text-sec-600", children: isResolvingAppId ? "Resolving app configuration..." : isDragging ? "Drop files here..." : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
3559
|
+
/* @__PURE__ */ jsx23("span", { className: "font-medium", children: "Click to upload" }),
|
|
3348
3560
|
" ",
|
|
3349
3561
|
"or drag and drop"
|
|
3350
3562
|
] }) }),
|
|
3351
|
-
/* @__PURE__ */
|
|
3563
|
+
/* @__PURE__ */ jsxs17("div", { className: "text-sm text-sec-500", children: [
|
|
3352
3564
|
!isResolvingAppId && accept !== "*/*" && `Accepted formats: ${accept}`,
|
|
3353
3565
|
!isResolvingAppId && maxSize && ` \u2022 Max size: ${Math.round(maxSize / 1024 / 1024)}MB`,
|
|
3354
3566
|
!isResolvingAppId && multiple && " \u2022 Multiple files allowed"
|
|
3355
3567
|
] })
|
|
3356
3568
|
] }),
|
|
3357
|
-
isUploading && !showProgress && /* @__PURE__ */
|
|
3569
|
+
isUploading && !showProgress && /* @__PURE__ */ jsx23(
|
|
3358
3570
|
"div",
|
|
3359
3571
|
{
|
|
3360
3572
|
className: "absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center",
|
|
3361
3573
|
role: "status",
|
|
3362
3574
|
"aria-live": "polite",
|
|
3363
3575
|
"aria-label": "Uploading file",
|
|
3364
|
-
children: /* @__PURE__ */
|
|
3576
|
+
children: /* @__PURE__ */ jsx23("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main-500", "aria-hidden": "true" })
|
|
3365
3577
|
}
|
|
3366
3578
|
)
|
|
3367
3579
|
]
|
|
3368
3580
|
}
|
|
3369
3581
|
),
|
|
3370
|
-
showProgress && uploadStates.size > 0 && /* @__PURE__ */
|
|
3582
|
+
showProgress && uploadStates.size > 0 && /* @__PURE__ */ jsx23("div", { className: "space-y-2", children: Array.from(uploadStates.entries()).map(([fileId, uploadState]) => {
|
|
3371
3583
|
const { file, progress, preview, result } = uploadState;
|
|
3372
3584
|
const isError = progress.status === "error";
|
|
3373
3585
|
const isCompleted = progress.status === "completed";
|
|
3374
3586
|
const isUploading2 = progress.status === "uploading" || progress.status === "processing";
|
|
3375
|
-
return /* @__PURE__ */
|
|
3587
|
+
return /* @__PURE__ */ jsxs17(
|
|
3376
3588
|
"div",
|
|
3377
3589
|
{
|
|
3378
3590
|
className: `flex items-center space-x-3 p-3 rounded-lg border ${isError ? "bg-acc-50 border-acc-200" : isCompleted ? "bg-success-50 border-success-200" : "bg-sec-50 border-sec-200"}`,
|
|
3379
3591
|
children: [
|
|
3380
|
-
/* @__PURE__ */
|
|
3592
|
+
/* @__PURE__ */ jsx23("div", { className: "flex-shrink-0", children: preview ? /* @__PURE__ */ jsx23(
|
|
3381
3593
|
"img",
|
|
3382
3594
|
{
|
|
3383
3595
|
src: preview,
|
|
3384
3596
|
alt: file.name,
|
|
3385
3597
|
className: "w-12 h-12 object-cover rounded"
|
|
3386
3598
|
}
|
|
3387
|
-
) : /* @__PURE__ */
|
|
3388
|
-
/* @__PURE__ */
|
|
3389
|
-
/* @__PURE__ */
|
|
3390
|
-
/* @__PURE__ */
|
|
3599
|
+
) : /* @__PURE__ */ jsx23("div", { className: "w-12 h-12 flex items-center justify-center bg-sec-200 rounded", children: /* @__PURE__ */ jsx23("span", { className: "text-2xl", children: "\u{1F4C4}" }) }) }),
|
|
3600
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0", children: [
|
|
3601
|
+
/* @__PURE__ */ jsx23("div", { className: "font-medium text-sec-900 truncate", children: file.name }),
|
|
3602
|
+
/* @__PURE__ */ jsxs17("div", { className: "text-sm text-sec-500", children: [
|
|
3391
3603
|
formatFileSize(file.size),
|
|
3392
3604
|
isCompleted && result && " \u2022 Uploaded",
|
|
3393
3605
|
isError && progress.error && ` \u2022 ${progress.error}`
|
|
3394
3606
|
] }),
|
|
3395
|
-
showProgress && (isUploading2 || isError) && /* @__PURE__ */
|
|
3396
|
-
/* @__PURE__ */
|
|
3607
|
+
showProgress && (isUploading2 || isError) && /* @__PURE__ */ jsxs17("div", { className: "mt-2", children: [
|
|
3608
|
+
/* @__PURE__ */ jsx23("div", { className: "w-full bg-sec-200 rounded-full h-2", children: /* @__PURE__ */ jsx23(
|
|
3397
3609
|
"div",
|
|
3398
3610
|
{
|
|
3399
3611
|
className: `h-2 rounded-full transition-all duration-300 ${isError ? "bg-acc-500" : "bg-main-500"}`,
|
|
3400
3612
|
style: { width: `${progress.percentage}%` }
|
|
3401
3613
|
}
|
|
3402
3614
|
) }),
|
|
3403
|
-
isUploading2 && /* @__PURE__ */
|
|
3615
|
+
isUploading2 && /* @__PURE__ */ jsxs17("div", { className: "text-xs text-sec-500 mt-1", children: [
|
|
3404
3616
|
progress.percentage,
|
|
3405
3617
|
"% \u2022 ",
|
|
3406
3618
|
formatFileSize(progress.loaded),
|
|
@@ -3409,10 +3621,10 @@ function FileUpload({
|
|
|
3409
3621
|
] })
|
|
3410
3622
|
] })
|
|
3411
3623
|
] }),
|
|
3412
|
-
/* @__PURE__ */
|
|
3413
|
-
isCompleted && /* @__PURE__ */
|
|
3414
|
-
isError && /* @__PURE__ */
|
|
3415
|
-
isUploading2 && /* @__PURE__ */
|
|
3624
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-shrink-0", children: [
|
|
3625
|
+
isCompleted && /* @__PURE__ */ jsx23("span", { className: "text-success-500 text-xl", children: "\u2713" }),
|
|
3626
|
+
isError && /* @__PURE__ */ jsx23("span", { className: "text-acc-500 text-xl", children: "\u2715" }),
|
|
3627
|
+
isUploading2 && /* @__PURE__ */ jsx23(
|
|
3416
3628
|
"div",
|
|
3417
3629
|
{
|
|
3418
3630
|
className: "animate-spin rounded-full h-5 w-5 border-b-2 border-main-500",
|
|
@@ -3427,7 +3639,7 @@ function FileUpload({
|
|
|
3427
3639
|
fileId
|
|
3428
3640
|
);
|
|
3429
3641
|
}) }),
|
|
3430
|
-
appIdError && /* @__PURE__ */
|
|
3642
|
+
appIdError && /* @__PURE__ */ jsx23(
|
|
3431
3643
|
"div",
|
|
3432
3644
|
{
|
|
3433
3645
|
className: "p-3 bg-acc-50 border border-acc-200 rounded-lg text-sm text-acc-600",
|
|
@@ -3436,7 +3648,7 @@ function FileUpload({
|
|
|
3436
3648
|
children: appIdError
|
|
3437
3649
|
}
|
|
3438
3650
|
),
|
|
3439
|
-
error && /* @__PURE__ */
|
|
3651
|
+
error && /* @__PURE__ */ jsx23(
|
|
3440
3652
|
"div",
|
|
3441
3653
|
{
|
|
3442
3654
|
className: "p-3 bg-acc-50 border border-acc-200 rounded-lg text-sm text-acc-600",
|
|
@@ -3449,18 +3661,19 @@ function FileUpload({
|
|
|
3449
3661
|
}
|
|
3450
3662
|
|
|
3451
3663
|
// src/components/FileDisplay/FileDisplay.tsx
|
|
3452
|
-
import { useState as
|
|
3664
|
+
import { useState as useState13, useEffect as useEffect10, useRef as useRef8, useContext as useContext2, useMemo as useMemo9 } from "react";
|
|
3665
|
+
import { FileText, ExternalLink } from "lucide-react";
|
|
3453
3666
|
|
|
3454
3667
|
// src/hooks/useFileUrl.ts
|
|
3455
|
-
import { useState as
|
|
3668
|
+
import { useState as useState12, useEffect as useEffect9, useCallback as useCallback8, useRef as useRef7 } from "react";
|
|
3456
3669
|
var log2 = createLogger("useFileUrl");
|
|
3457
3670
|
function useFileUrl(fileReference, options) {
|
|
3458
3671
|
const { organisation_id, supabase, autoLoad = true } = options;
|
|
3459
|
-
const [url, setUrl] =
|
|
3460
|
-
const [isLoading, setIsLoading] =
|
|
3461
|
-
const [error, setError] =
|
|
3462
|
-
const fileReferenceIdRef =
|
|
3463
|
-
const loadUrl =
|
|
3672
|
+
const [url, setUrl] = useState12(null);
|
|
3673
|
+
const [isLoading, setIsLoading] = useState12(false);
|
|
3674
|
+
const [error, setError] = useState12(null);
|
|
3675
|
+
const fileReferenceIdRef = useRef7(null);
|
|
3676
|
+
const loadUrl = useCallback8(async () => {
|
|
3464
3677
|
if (!fileReference) {
|
|
3465
3678
|
setUrl(null);
|
|
3466
3679
|
setIsLoading(false);
|
|
@@ -3496,13 +3709,13 @@ function useFileUrl(fileReference, options) {
|
|
|
3496
3709
|
setIsLoading(false);
|
|
3497
3710
|
}
|
|
3498
3711
|
}, [fileReference, supabase, organisation_id, isLoading, url]);
|
|
3499
|
-
const clear =
|
|
3712
|
+
const clear = useCallback8(() => {
|
|
3500
3713
|
setUrl(null);
|
|
3501
3714
|
setError(null);
|
|
3502
3715
|
setIsLoading(false);
|
|
3503
3716
|
fileReferenceIdRef.current = null;
|
|
3504
3717
|
}, []);
|
|
3505
|
-
|
|
3718
|
+
useEffect9(() => {
|
|
3506
3719
|
if (autoLoad) {
|
|
3507
3720
|
if (fileReferenceIdRef.current !== fileReference?.id) {
|
|
3508
3721
|
setUrl(null);
|
|
@@ -3523,7 +3736,7 @@ function useFileUrl(fileReference, options) {
|
|
|
3523
3736
|
}
|
|
3524
3737
|
|
|
3525
3738
|
// src/components/FileDisplay/FileDisplay.tsx
|
|
3526
|
-
import { Fragment as Fragment6, jsx as
|
|
3739
|
+
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3527
3740
|
var fallbackSizeClasses = {
|
|
3528
3741
|
xs: "h-4 w-4 text-xs",
|
|
3529
3742
|
sm: "h-6 w-6 text-sm",
|
|
@@ -3562,10 +3775,10 @@ function FileDisplayContent({
|
|
|
3562
3775
|
fallbackText,
|
|
3563
3776
|
fallbackSize = "md"
|
|
3564
3777
|
}) {
|
|
3565
|
-
const [imageError, setImageError] =
|
|
3566
|
-
const [internalFileUrls, setInternalFileUrls] =
|
|
3567
|
-
const [deleteDialogOpen, setDeleteDialogOpen] =
|
|
3568
|
-
const fileReferencesRef =
|
|
3778
|
+
const [imageError, setImageError] = useState13(false);
|
|
3779
|
+
const [internalFileUrls, setInternalFileUrls] = useState13(new Map(fileUrls));
|
|
3780
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState13(false);
|
|
3781
|
+
const fileReferencesRef = useRef8([]);
|
|
3569
3782
|
const computedFallbackText = useMemo9(() => {
|
|
3570
3783
|
if (fallbackText) return fallbackText;
|
|
3571
3784
|
const fileName = fileReference?.file_metadata?.fileName;
|
|
@@ -3576,7 +3789,7 @@ function FileDisplayContent({
|
|
|
3576
3789
|
const baseClasses = "flex items-center justify-center bg-sec-100 text-sec-600 font-semibold rounded";
|
|
3577
3790
|
return `${baseClasses} ${sizeClass} ${className}`.trim();
|
|
3578
3791
|
}, [fallbackSize, className]);
|
|
3579
|
-
|
|
3792
|
+
useEffect10(() => {
|
|
3580
3793
|
const currentIds = fileReferences.map((f) => f.id).join(",");
|
|
3581
3794
|
const prevIds = fileReferencesRef.current.map((f) => f.id).join(",");
|
|
3582
3795
|
if (currentIds !== prevIds) {
|
|
@@ -3630,17 +3843,17 @@ function FileDisplayContent({
|
|
|
3630
3843
|
};
|
|
3631
3844
|
if (error) {
|
|
3632
3845
|
if (ErrorComponent) {
|
|
3633
|
-
return /* @__PURE__ */
|
|
3846
|
+
return /* @__PURE__ */ jsx24(ErrorComponent, { error, retry: clearError });
|
|
3634
3847
|
}
|
|
3635
3848
|
if (showFallback) {
|
|
3636
|
-
return /* @__PURE__ */
|
|
3849
|
+
return /* @__PURE__ */ jsx24("div", { className: fallbackClasses, title: "File unavailable", children: computedFallbackText });
|
|
3637
3850
|
}
|
|
3638
|
-
return /* @__PURE__ */
|
|
3639
|
-
/* @__PURE__ */
|
|
3851
|
+
return /* @__PURE__ */ jsxs18("div", { className: `p-4 bg-acc-50 border border-acc-200 rounded-lg ${className}`, children: [
|
|
3852
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-acc-600", children: [
|
|
3640
3853
|
"Error loading file: ",
|
|
3641
3854
|
error instanceof Error ? error.message : String(error)
|
|
3642
3855
|
] }),
|
|
3643
|
-
clearError && /* @__PURE__ */
|
|
3856
|
+
clearError && /* @__PURE__ */ jsx24(
|
|
3644
3857
|
"button",
|
|
3645
3858
|
{
|
|
3646
3859
|
onClick: clearError,
|
|
@@ -3653,38 +3866,38 @@ function FileDisplayContent({
|
|
|
3653
3866
|
}
|
|
3654
3867
|
if (fileCount === 0 && !isLoading) {
|
|
3655
3868
|
if (showFallback) {
|
|
3656
|
-
return /* @__PURE__ */
|
|
3869
|
+
return /* @__PURE__ */ jsxs18("div", { className: fallbackClasses, title: "No file", children: [
|
|
3657
3870
|
computedFallbackText,
|
|
3658
3871
|
children
|
|
3659
3872
|
] });
|
|
3660
3873
|
}
|
|
3661
|
-
return /* @__PURE__ */
|
|
3874
|
+
return /* @__PURE__ */ jsxs18("div", { className: `text-sec-500 text-center p-4 ${className}`, children: [
|
|
3662
3875
|
"No files found",
|
|
3663
3876
|
children
|
|
3664
3877
|
] });
|
|
3665
3878
|
}
|
|
3666
3879
|
if (isLoading && showFallback && fileCount === 0) {
|
|
3667
|
-
return /* @__PURE__ */
|
|
3880
|
+
return /* @__PURE__ */ jsxs18("div", { className: fallbackClasses, title: "Loading...", children: [
|
|
3668
3881
|
computedFallbackText,
|
|
3669
3882
|
children
|
|
3670
3883
|
] });
|
|
3671
3884
|
}
|
|
3672
3885
|
if (isLoading) {
|
|
3673
3886
|
if (LoadingComponent) {
|
|
3674
|
-
return /* @__PURE__ */
|
|
3887
|
+
return /* @__PURE__ */ jsx24(LoadingComponent, {});
|
|
3675
3888
|
}
|
|
3676
|
-
return /* @__PURE__ */
|
|
3889
|
+
return /* @__PURE__ */ jsx24("div", { className: `flex items-center justify-center p-4 ${className}`, children: /* @__PURE__ */ jsx24("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main-500" }) });
|
|
3677
3890
|
}
|
|
3678
3891
|
if ((category || displayOnly) && fileReference) {
|
|
3679
3892
|
const isImage = fileReference.file_metadata.fileType?.startsWith("image/");
|
|
3680
3893
|
if (displayOnly && isImage && !showDelete) {
|
|
3681
3894
|
if (imageError && showFallback) {
|
|
3682
|
-
return /* @__PURE__ */
|
|
3895
|
+
return /* @__PURE__ */ jsx24("div", { className: fallbackClasses, title: fileReference.file_metadata.fileName || "File", children: computedFallbackText });
|
|
3683
3896
|
}
|
|
3684
3897
|
if (!fileUrl) {
|
|
3685
|
-
return /* @__PURE__ */
|
|
3898
|
+
return /* @__PURE__ */ jsx24("div", { className: `bg-sec-100 rounded animate-pulse ${className || "max-w-full h-48"}`, children: /* @__PURE__ */ jsx24("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx24("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main-500" }) }) });
|
|
3686
3899
|
}
|
|
3687
|
-
return /* @__PURE__ */
|
|
3900
|
+
return /* @__PURE__ */ jsx24(
|
|
3688
3901
|
"img",
|
|
3689
3902
|
{
|
|
3690
3903
|
src: fileUrl,
|
|
@@ -3694,12 +3907,31 @@ function FileDisplayContent({
|
|
|
3694
3907
|
}
|
|
3695
3908
|
);
|
|
3696
3909
|
}
|
|
3910
|
+
if (displayOnly && !isImage && fileUrl && fileReference && !showDelete) {
|
|
3911
|
+
const fileName = fileReference.file_metadata?.fileName || "Document";
|
|
3912
|
+
const ariaLabel = `Open ${fileName} in new tab`;
|
|
3913
|
+
return /* @__PURE__ */ jsxs18(
|
|
3914
|
+
"a",
|
|
3915
|
+
{
|
|
3916
|
+
href: fileUrl,
|
|
3917
|
+
target: "_blank",
|
|
3918
|
+
rel: "noopener noreferrer",
|
|
3919
|
+
"aria-label": ariaLabel,
|
|
3920
|
+
className: `flex items-center gap-2 p-3 bg-sec-50 border border-sec-200 rounded-lg hover:bg-sec-100 transition-colors text-main-600 hover:text-main-700 focus:outline-none focus:ring-2 focus:ring-main-500 focus:ring-offset-2 ${className || ""}`.trim(),
|
|
3921
|
+
children: [
|
|
3922
|
+
/* @__PURE__ */ jsx24(FileText, { className: "h-5 w-5 shrink-0", "aria-hidden": "true" }),
|
|
3923
|
+
/* @__PURE__ */ jsx24("span", { className: "flex-1 font-medium truncate", children: fileName }),
|
|
3924
|
+
/* @__PURE__ */ jsx24(ExternalLink, { className: "h-5 w-5 shrink-0", "aria-hidden": "true" })
|
|
3925
|
+
]
|
|
3926
|
+
}
|
|
3927
|
+
);
|
|
3928
|
+
}
|
|
3697
3929
|
if (displayOnly && showFallback && (!fileUrl || imageError || !isImage)) {
|
|
3698
|
-
return /* @__PURE__ */
|
|
3930
|
+
return /* @__PURE__ */ jsx24("div", { className: fallbackClasses, title: fileReference.file_metadata.fileName || "File", children: computedFallbackText });
|
|
3699
3931
|
}
|
|
3700
|
-
return /* @__PURE__ */
|
|
3701
|
-
isImage && fileUrl && !imageError ? /* @__PURE__ */
|
|
3702
|
-
/* @__PURE__ */
|
|
3932
|
+
return /* @__PURE__ */ jsxs18("div", { className: `space-y-2 ${className}`, children: [
|
|
3933
|
+
isImage && fileUrl && !imageError ? /* @__PURE__ */ jsxs18("div", { className: "relative", children: [
|
|
3934
|
+
/* @__PURE__ */ jsx24(
|
|
3703
3935
|
"img",
|
|
3704
3936
|
{
|
|
3705
3937
|
src: fileUrl,
|
|
@@ -3708,8 +3940,8 @@ function FileDisplayContent({
|
|
|
3708
3940
|
onError: handleImageError
|
|
3709
3941
|
}
|
|
3710
3942
|
),
|
|
3711
|
-
showDelete && /* @__PURE__ */
|
|
3712
|
-
/* @__PURE__ */
|
|
3943
|
+
showDelete && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
3944
|
+
/* @__PURE__ */ jsx24(
|
|
3713
3945
|
"button",
|
|
3714
3946
|
{
|
|
3715
3947
|
onClick: handleDeleteClick,
|
|
@@ -3719,29 +3951,29 @@ function FileDisplayContent({
|
|
|
3719
3951
|
children: "\xD7"
|
|
3720
3952
|
}
|
|
3721
3953
|
),
|
|
3722
|
-
/* @__PURE__ */
|
|
3723
|
-
/* @__PURE__ */
|
|
3724
|
-
/* @__PURE__ */
|
|
3725
|
-
/* @__PURE__ */
|
|
3726
|
-
/* @__PURE__ */
|
|
3727
|
-
/* @__PURE__ */
|
|
3954
|
+
/* @__PURE__ */ jsx24(Dialog, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: /* @__PURE__ */ jsxs18(DialogContent, { size: "sm", children: [
|
|
3955
|
+
/* @__PURE__ */ jsx24(DialogHeader, { children: /* @__PURE__ */ jsx24(DialogTitle, { children: "Confirm Delete" }) }),
|
|
3956
|
+
/* @__PURE__ */ jsx24(DialogBody, { children: /* @__PURE__ */ jsx24("p", { children: "Are you sure you want to delete this file? This action cannot be undone." }) }),
|
|
3957
|
+
/* @__PURE__ */ jsxs18(DialogFooter, { children: [
|
|
3958
|
+
/* @__PURE__ */ jsx24(Button, { variant: "outline", onClick: () => setDeleteDialogOpen(false), children: "Cancel" }),
|
|
3959
|
+
/* @__PURE__ */ jsx24(Button, { variant: "destructive", onClick: handleDeleteConfirm, children: "Delete" })
|
|
3728
3960
|
] })
|
|
3729
3961
|
] }) })
|
|
3730
3962
|
] })
|
|
3731
3963
|
] }) : isImage && imageError && showFallback ? (
|
|
3732
3964
|
// Show fallback when image fails to load and fallback is enabled
|
|
3733
|
-
/* @__PURE__ */
|
|
3734
|
-
) : /* @__PURE__ */
|
|
3735
|
-
/* @__PURE__ */
|
|
3736
|
-
/* @__PURE__ */
|
|
3737
|
-
/* @__PURE__ */
|
|
3738
|
-
/* @__PURE__ */
|
|
3965
|
+
/* @__PURE__ */ jsx24("div", { className: fallbackClasses, title: fileReference.file_metadata.fileName || "File", children: computedFallbackText })
|
|
3966
|
+
) : /* @__PURE__ */ jsxs18("div", { className: "flex items-center space-x-3 p-3 bg-sec-50 rounded-lg border border-sec-200", children: [
|
|
3967
|
+
/* @__PURE__ */ jsx24("span", { className: "text-2xl", children: getFileIcon(fileReference.file_metadata.fileType || "") }),
|
|
3968
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1 min-w-0", children: [
|
|
3969
|
+
/* @__PURE__ */ jsx24("div", { className: "font-medium text-sec-900 truncate", children: fileReference.file_metadata.fileName || "Unknown file" }),
|
|
3970
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm text-sec-500", children: [
|
|
3739
3971
|
fileReference.file_metadata.fileSize && formatFileSize(fileReference.file_metadata.fileSize),
|
|
3740
3972
|
fileReference.file_metadata.fileType && ` \u2022 ${fileReference.file_metadata.fileType}`
|
|
3741
3973
|
] })
|
|
3742
3974
|
] }),
|
|
3743
|
-
showDelete && /* @__PURE__ */
|
|
3744
|
-
/* @__PURE__ */
|
|
3975
|
+
showDelete && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
3976
|
+
/* @__PURE__ */ jsx24(
|
|
3745
3977
|
"button",
|
|
3746
3978
|
{
|
|
3747
3979
|
onClick: handleDeleteClick,
|
|
@@ -3751,12 +3983,12 @@ function FileDisplayContent({
|
|
|
3751
3983
|
children: "\xD7"
|
|
3752
3984
|
}
|
|
3753
3985
|
),
|
|
3754
|
-
/* @__PURE__ */
|
|
3755
|
-
/* @__PURE__ */
|
|
3756
|
-
/* @__PURE__ */
|
|
3757
|
-
/* @__PURE__ */
|
|
3758
|
-
/* @__PURE__ */
|
|
3759
|
-
/* @__PURE__ */
|
|
3986
|
+
/* @__PURE__ */ jsx24(Dialog, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: /* @__PURE__ */ jsxs18(DialogContent, { size: "sm", children: [
|
|
3987
|
+
/* @__PURE__ */ jsx24(DialogHeader, { children: /* @__PURE__ */ jsx24(DialogTitle, { children: "Confirm Delete" }) }),
|
|
3988
|
+
/* @__PURE__ */ jsx24(DialogBody, { children: /* @__PURE__ */ jsx24("p", { children: "Are you sure you want to delete this file? This action cannot be undone." }) }),
|
|
3989
|
+
/* @__PURE__ */ jsxs18(DialogFooter, { children: [
|
|
3990
|
+
/* @__PURE__ */ jsx24(Button, { variant: "outline", onClick: () => setDeleteDialogOpen(false), children: "Cancel" }),
|
|
3991
|
+
/* @__PURE__ */ jsx24(Button, { variant: "destructive", onClick: handleDeleteConfirm, children: "Delete" })
|
|
3760
3992
|
] })
|
|
3761
3993
|
] }) })
|
|
3762
3994
|
] })
|
|
@@ -3764,13 +3996,13 @@ function FileDisplayContent({
|
|
|
3764
3996
|
children
|
|
3765
3997
|
] });
|
|
3766
3998
|
}
|
|
3767
|
-
return /* @__PURE__ */
|
|
3999
|
+
return /* @__PURE__ */ jsxs18("div", { className: `space-y-2 ${className}`, children: [
|
|
3768
4000
|
fileReferences.map((fileRef) => {
|
|
3769
4001
|
const isImage = fileRef.file_metadata.fileType?.startsWith("image/");
|
|
3770
4002
|
const fileUrl2 = internalFileUrls.get(fileRef.id) || null;
|
|
3771
4003
|
const canDownload = !isImage && fileUrl2;
|
|
3772
|
-
return /* @__PURE__ */
|
|
3773
|
-
isImage && fileUrl2 ? /* @__PURE__ */
|
|
4004
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex items-center space-x-3 p-3 bg-sec-50 rounded-lg border border-sec-200", children: [
|
|
4005
|
+
isImage && fileUrl2 ? /* @__PURE__ */ jsx24(
|
|
3774
4006
|
"img",
|
|
3775
4007
|
{
|
|
3776
4008
|
src: fileUrl2,
|
|
@@ -3778,17 +4010,17 @@ function FileDisplayContent({
|
|
|
3778
4010
|
className: "w-12 h-12 object-cover rounded",
|
|
3779
4011
|
onError: handleImageError
|
|
3780
4012
|
}
|
|
3781
|
-
) : /* @__PURE__ */
|
|
3782
|
-
/* @__PURE__ */
|
|
3783
|
-
/* @__PURE__ */
|
|
3784
|
-
/* @__PURE__ */
|
|
4013
|
+
) : /* @__PURE__ */ jsx24("span", { className: "text-2xl", children: getFileIcon(fileRef.file_metadata.fileType || "") }),
|
|
4014
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1 min-w-0", children: [
|
|
4015
|
+
/* @__PURE__ */ jsx24("div", { className: "font-medium text-sec-900 truncate", children: fileRef.file_metadata.fileName || "Unknown file" }),
|
|
4016
|
+
/* @__PURE__ */ jsxs18("div", { className: "text-sm text-sec-500", children: [
|
|
3785
4017
|
fileRef.file_metadata.fileSize && formatFileSize(fileRef.file_metadata.fileSize),
|
|
3786
4018
|
fileRef.file_metadata.fileType && ` \u2022 ${fileRef.file_metadata.fileType}`,
|
|
3787
4019
|
fileRef.file_metadata.category && ` \u2022 ${fileRef.file_metadata.category}`
|
|
3788
4020
|
] })
|
|
3789
4021
|
] }),
|
|
3790
|
-
/* @__PURE__ */
|
|
3791
|
-
canDownload && /* @__PURE__ */
|
|
4022
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center space-x-2", children: [
|
|
4023
|
+
canDownload && /* @__PURE__ */ jsx24(
|
|
3792
4024
|
"a",
|
|
3793
4025
|
{
|
|
3794
4026
|
href: fileRef.file_path,
|
|
@@ -3798,7 +4030,7 @@ function FileDisplayContent({
|
|
|
3798
4030
|
children: "\u2193"
|
|
3799
4031
|
}
|
|
3800
4032
|
),
|
|
3801
|
-
showDelete && onDelete && /* @__PURE__ */
|
|
4033
|
+
showDelete && onDelete && /* @__PURE__ */ jsx24(
|
|
3802
4034
|
"button",
|
|
3803
4035
|
{
|
|
3804
4036
|
onClick: handleDeleteClick,
|
|
@@ -3834,7 +4066,7 @@ function FileDisplayPublic({
|
|
|
3834
4066
|
const supabase = publicPageContext?.supabase ?? null;
|
|
3835
4067
|
if (!supabase) {
|
|
3836
4068
|
if (showFallback) {
|
|
3837
|
-
return /* @__PURE__ */
|
|
4069
|
+
return /* @__PURE__ */ jsx24(
|
|
3838
4070
|
FileDisplayContent,
|
|
3839
4071
|
{
|
|
3840
4072
|
isLoading: false,
|
|
@@ -3860,7 +4092,7 @@ function FileDisplayPublic({
|
|
|
3860
4092
|
}
|
|
3861
4093
|
);
|
|
3862
4094
|
}
|
|
3863
|
-
return /* @__PURE__ */
|
|
4095
|
+
return /* @__PURE__ */ jsx24("div", { className: `text-sec-500 text-center p-4 ${className}`, children: "Supabase client not available in public context" });
|
|
3864
4096
|
}
|
|
3865
4097
|
const {
|
|
3866
4098
|
fileUrl,
|
|
@@ -3904,7 +4136,7 @@ function FileDisplayPublic({
|
|
|
3904
4136
|
finalFileCount = 1;
|
|
3905
4137
|
finalFileUrl = fileUrls.get(targetFile.id) || null;
|
|
3906
4138
|
}
|
|
3907
|
-
return /* @__PURE__ */
|
|
4139
|
+
return /* @__PURE__ */ jsx24(
|
|
3908
4140
|
FileDisplayContent,
|
|
3909
4141
|
{
|
|
3910
4142
|
isLoading,
|
|
@@ -3948,7 +4180,7 @@ function FileDisplayAuthenticated({
|
|
|
3948
4180
|
}) {
|
|
3949
4181
|
const { supabase } = useUnifiedAuth();
|
|
3950
4182
|
if (!supabase) {
|
|
3951
|
-
return /* @__PURE__ */
|
|
4183
|
+
return /* @__PURE__ */ jsx24("div", { className: `text-sec-500 text-center p-4 ${className}`, children: "Supabase client not available in authenticated context" });
|
|
3952
4184
|
}
|
|
3953
4185
|
const {
|
|
3954
4186
|
fileUrl,
|
|
@@ -3966,7 +4198,7 @@ function FileDisplayAuthenticated({
|
|
|
3966
4198
|
category,
|
|
3967
4199
|
{ supabase }
|
|
3968
4200
|
);
|
|
3969
|
-
const [displayOnlyFileReference, setDisplayOnlyFileReference] =
|
|
4201
|
+
const [displayOnlyFileReference, setDisplayOnlyFileReference] = useState13(null);
|
|
3970
4202
|
const displayOnlyFileUrlFromMap = displayOnlyFileReference ? fileUrls.get(displayOnlyFileReference.id) : null;
|
|
3971
4203
|
const displayOnlyFileUrlHook = useFileUrl(
|
|
3972
4204
|
displayOnlyFileReference && !displayOnlyFileUrlFromMap ? displayOnlyFileReference : null,
|
|
@@ -3977,7 +4209,7 @@ function FileDisplayAuthenticated({
|
|
|
3977
4209
|
}
|
|
3978
4210
|
);
|
|
3979
4211
|
const displayOnlyFileUrl = displayOnlyFileUrlFromMap || displayOnlyFileUrlHook.url;
|
|
3980
|
-
|
|
4212
|
+
useEffect10(() => {
|
|
3981
4213
|
if (displayOnly && !category && fileReferences.length > 0) {
|
|
3982
4214
|
const imageFiles = fileReferences.filter(
|
|
3983
4215
|
(f) => f.file_metadata.fileType?.startsWith("image/")
|
|
@@ -4006,7 +4238,7 @@ function FileDisplayAuthenticated({
|
|
|
4006
4238
|
finalError = error || displayOnlyFileUrlHook.error;
|
|
4007
4239
|
}
|
|
4008
4240
|
}
|
|
4009
|
-
return /* @__PURE__ */
|
|
4241
|
+
return /* @__PURE__ */ jsx24(
|
|
4010
4242
|
FileDisplayContent,
|
|
4011
4243
|
{
|
|
4012
4244
|
isLoading: finalIsLoading,
|
|
@@ -4051,7 +4283,7 @@ function FileDisplay({
|
|
|
4051
4283
|
}) {
|
|
4052
4284
|
const isPublicPage = useIsPublicPage();
|
|
4053
4285
|
if (isPublicPage) {
|
|
4054
|
-
return /* @__PURE__ */
|
|
4286
|
+
return /* @__PURE__ */ jsx24(
|
|
4055
4287
|
FileDisplayPublic,
|
|
4056
4288
|
{
|
|
4057
4289
|
table_name,
|
|
@@ -4071,7 +4303,7 @@ function FileDisplay({
|
|
|
4071
4303
|
}
|
|
4072
4304
|
);
|
|
4073
4305
|
}
|
|
4074
|
-
return /* @__PURE__ */
|
|
4306
|
+
return /* @__PURE__ */ jsx24(
|
|
4075
4307
|
FileDisplayAuthenticated,
|
|
4076
4308
|
{
|
|
4077
4309
|
table_name,
|
|
@@ -4093,9 +4325,9 @@ function FileDisplay({
|
|
|
4093
4325
|
}
|
|
4094
4326
|
|
|
4095
4327
|
// src/components/Table/Table.tsx
|
|
4096
|
-
import * as
|
|
4097
|
-
import { jsx as
|
|
4098
|
-
var Table =
|
|
4328
|
+
import * as React21 from "react";
|
|
4329
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
4330
|
+
var Table = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4099
4331
|
"table",
|
|
4100
4332
|
{
|
|
4101
4333
|
ref,
|
|
@@ -4104,9 +4336,9 @@ var Table = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
4104
4336
|
}
|
|
4105
4337
|
));
|
|
4106
4338
|
Table.displayName = "Table";
|
|
4107
|
-
var TableHeader =
|
|
4339
|
+
var TableHeader = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
4108
4340
|
TableHeader.displayName = "TableHeader";
|
|
4109
|
-
var TableBody =
|
|
4341
|
+
var TableBody = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4110
4342
|
"tbody",
|
|
4111
4343
|
{
|
|
4112
4344
|
ref,
|
|
@@ -4115,7 +4347,7 @@ var TableBody = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
4115
4347
|
}
|
|
4116
4348
|
));
|
|
4117
4349
|
TableBody.displayName = "TableBody";
|
|
4118
|
-
var TableFooter =
|
|
4350
|
+
var TableFooter = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4119
4351
|
"tfoot",
|
|
4120
4352
|
{
|
|
4121
4353
|
ref,
|
|
@@ -4127,7 +4359,7 @@ var TableFooter = React20.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
4127
4359
|
}
|
|
4128
4360
|
));
|
|
4129
4361
|
TableFooter.displayName = "TableFooter";
|
|
4130
|
-
var TableRow =
|
|
4362
|
+
var TableRow = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4131
4363
|
"tr",
|
|
4132
4364
|
{
|
|
4133
4365
|
ref,
|
|
@@ -4139,7 +4371,7 @@ var TableRow = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
4139
4371
|
}
|
|
4140
4372
|
));
|
|
4141
4373
|
TableRow.displayName = "TableRow";
|
|
4142
|
-
var TableHead =
|
|
4374
|
+
var TableHead = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4143
4375
|
"th",
|
|
4144
4376
|
{
|
|
4145
4377
|
ref,
|
|
@@ -4151,7 +4383,7 @@ var TableHead = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
4151
4383
|
}
|
|
4152
4384
|
));
|
|
4153
4385
|
TableHead.displayName = "TableHead";
|
|
4154
|
-
var TableCell =
|
|
4386
|
+
var TableCell = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4155
4387
|
"td",
|
|
4156
4388
|
{
|
|
4157
4389
|
ref,
|
|
@@ -4160,7 +4392,7 @@ var TableCell = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
4160
4392
|
}
|
|
4161
4393
|
));
|
|
4162
4394
|
TableCell.displayName = "TableCell";
|
|
4163
|
-
var TableCaption =
|
|
4395
|
+
var TableCaption = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx25(
|
|
4164
4396
|
"caption",
|
|
4165
4397
|
{
|
|
4166
4398
|
ref,
|
|
@@ -4171,7 +4403,7 @@ var TableCaption = React20.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
4171
4403
|
TableCaption.displayName = "TableCaption";
|
|
4172
4404
|
|
|
4173
4405
|
// src/components/PublicLayout/PublicPageLayout.tsx
|
|
4174
|
-
import { Fragment as Fragment7, jsx as
|
|
4406
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4175
4407
|
function PublicPageHeader({
|
|
4176
4408
|
event,
|
|
4177
4409
|
eventCode,
|
|
@@ -4184,11 +4416,11 @@ function PublicPageHeader({
|
|
|
4184
4416
|
customEventLogo
|
|
4185
4417
|
}) {
|
|
4186
4418
|
const { appName } = useAppConfig();
|
|
4187
|
-
return /* @__PURE__ */
|
|
4419
|
+
return /* @__PURE__ */ jsxs19("header", { className: cn(
|
|
4188
4420
|
"w-full px-[max(0rem,calc((100vw-var(--app-width))/2-0.5rem))] grid grid-cols-[auto_1fr_auto] place-items-center gap-2",
|
|
4189
4421
|
className
|
|
4190
4422
|
), children: [
|
|
4191
|
-
showAppLogo && appName && /* @__PURE__ */
|
|
4423
|
+
showAppLogo && appName && /* @__PURE__ */ jsx26(
|
|
4192
4424
|
"img",
|
|
4193
4425
|
{
|
|
4194
4426
|
className: "ml-4 max-w-36 object-contain row-span-2",
|
|
@@ -4196,9 +4428,9 @@ function PublicPageHeader({
|
|
|
4196
4428
|
alt: appName
|
|
4197
4429
|
}
|
|
4198
4430
|
),
|
|
4199
|
-
event && /* @__PURE__ */
|
|
4200
|
-
/* @__PURE__ */
|
|
4201
|
-
showEventLogo && event && /* @__PURE__ */
|
|
4431
|
+
event && /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
4432
|
+
/* @__PURE__ */ jsx26("h1", { children: event.event_name }),
|
|
4433
|
+
showEventLogo && event && /* @__PURE__ */ jsx26(Fragment7, { children: customEventLogo || /* @__PURE__ */ jsx26(
|
|
4202
4434
|
FileDisplay,
|
|
4203
4435
|
{
|
|
4204
4436
|
table_name: "event",
|
|
@@ -4215,13 +4447,13 @@ function PublicPageHeader({
|
|
|
4215
4447
|
}
|
|
4216
4448
|
}
|
|
4217
4449
|
) }),
|
|
4218
|
-
event.event_venue && /* @__PURE__ */
|
|
4450
|
+
event.event_venue && /* @__PURE__ */ jsx26("h4", { children: event.event_venue })
|
|
4219
4451
|
] }),
|
|
4220
|
-
title && /* @__PURE__ */
|
|
4221
|
-
/* @__PURE__ */
|
|
4222
|
-
description && /* @__PURE__ */
|
|
4452
|
+
title && /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
4453
|
+
/* @__PURE__ */ jsx26("h1", { children: title }),
|
|
4454
|
+
description && /* @__PURE__ */ jsx26("p", { className: "text-lg text-sec-600 max-w-3xl mx-auto", children: description })
|
|
4223
4455
|
] }),
|
|
4224
|
-
children && /* @__PURE__ */
|
|
4456
|
+
children && /* @__PURE__ */ jsx26(Fragment7, { children })
|
|
4225
4457
|
] });
|
|
4226
4458
|
}
|
|
4227
4459
|
function PublicPageFooter({
|
|
@@ -4235,11 +4467,11 @@ function PublicPageFooter({
|
|
|
4235
4467
|
children
|
|
4236
4468
|
}) {
|
|
4237
4469
|
const copyrightText = copyright || `\xA9 Copyright 2022\u2013${year} all rights reserved, ${companyName}.`;
|
|
4238
|
-
return /* @__PURE__ */
|
|
4239
|
-
logo && /* @__PURE__ */
|
|
4240
|
-
children && /* @__PURE__ */
|
|
4241
|
-
/* @__PURE__ */
|
|
4242
|
-
links && links.length > 0 && /* @__PURE__ */
|
|
4470
|
+
return /* @__PURE__ */ jsx26("footer", { className: cn("mt-8 py-6 flex justify-center", className), children: /* @__PURE__ */ jsxs19("section", { className: "px-4 w-[min(var(--app-width),100%)] mx-auto text-center", children: [
|
|
4471
|
+
logo && /* @__PURE__ */ jsx26("img", { src: logo, alt: "Logo", className: "h-8 w-auto" }),
|
|
4472
|
+
children && /* @__PURE__ */ jsx26(Fragment7, { children }),
|
|
4473
|
+
/* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: copyrightText }),
|
|
4474
|
+
links && links.length > 0 && /* @__PURE__ */ jsx26("ul", { className: "flex gap-4 mt-2 md:mt-0", children: links.map((link, index) => /* @__PURE__ */ jsx26("li", { children: /* @__PURE__ */ jsx26("a", { href: link.href, className: "text-muted-foreground hover:text-foreground", children: link.label }) }, index)) })
|
|
4243
4475
|
] }) });
|
|
4244
4476
|
}
|
|
4245
4477
|
function PublicPageLayout({
|
|
@@ -4263,48 +4495,49 @@ function PublicPageLayout({
|
|
|
4263
4495
|
});
|
|
4264
4496
|
if (isLoading) {
|
|
4265
4497
|
if (LoadingFallback) {
|
|
4266
|
-
return /* @__PURE__ */
|
|
4498
|
+
return /* @__PURE__ */ jsx26(LoadingFallback, {});
|
|
4267
4499
|
}
|
|
4268
|
-
return /* @__PURE__ */
|
|
4269
|
-
/* @__PURE__ */
|
|
4270
|
-
loadingMessage && /* @__PURE__ */
|
|
4500
|
+
return /* @__PURE__ */ jsx26("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ jsxs19("div", { className: "max-w-md mx-auto text-center px-4", children: [
|
|
4501
|
+
/* @__PURE__ */ jsx26(LoadingSpinner, { size: "lg", className: "mx-auto mb-4" }),
|
|
4502
|
+
loadingMessage && /* @__PURE__ */ jsx26("p", { className: "text-sec-600", children: loadingMessage })
|
|
4271
4503
|
] }) });
|
|
4272
4504
|
}
|
|
4273
4505
|
if (error && showValidationErrors) {
|
|
4274
4506
|
if (ErrorFallback) {
|
|
4275
|
-
return /* @__PURE__ */
|
|
4507
|
+
return /* @__PURE__ */ jsx26(ErrorFallback, { error, retry: handleRefetch });
|
|
4276
4508
|
}
|
|
4277
|
-
return /* @__PURE__ */
|
|
4278
|
-
/* @__PURE__ */
|
|
4279
|
-
/* @__PURE__ */
|
|
4509
|
+
return /* @__PURE__ */ jsxs19("main", { className: "flex flex-col items-center justify-center px-4 w-[min(var(--app-width),100%)] mx-auto py-8", children: [
|
|
4510
|
+
/* @__PURE__ */ jsx26("h1", { children: "Event Not Found" }),
|
|
4511
|
+
/* @__PURE__ */ jsxs19("p", { children: [
|
|
4280
4512
|
'The event code "',
|
|
4281
4513
|
eventCode,
|
|
4282
4514
|
'" is invalid or the event is not available for public viewing.'
|
|
4283
4515
|
] }),
|
|
4284
|
-
/* @__PURE__ */
|
|
4516
|
+
/* @__PURE__ */ jsx26(Button, { onClick: handleRefetch, children: "Try Again" })
|
|
4285
4517
|
] });
|
|
4286
4518
|
}
|
|
4287
4519
|
if (!event && showValidationErrors) {
|
|
4288
|
-
return /* @__PURE__ */
|
|
4289
|
-
/* @__PURE__ */
|
|
4290
|
-
/* @__PURE__ */
|
|
4291
|
-
handleRefetch && /* @__PURE__ */
|
|
4520
|
+
return /* @__PURE__ */ jsxs19("main", { className: "flex flex-col items-center justify-center px-4 w-[min(var(--app-width),100%)] mx-auto py-8", children: [
|
|
4521
|
+
/* @__PURE__ */ jsx26("h1", { children: "Event Not Available" }),
|
|
4522
|
+
/* @__PURE__ */ jsx26("p", { children: "This event is not available for public viewing." }),
|
|
4523
|
+
handleRefetch && /* @__PURE__ */ jsx26(Button, { onClick: handleRefetch, children: "Try Again" })
|
|
4292
4524
|
] });
|
|
4293
4525
|
}
|
|
4294
|
-
return /* @__PURE__ */
|
|
4295
|
-
customHeader || /* @__PURE__ */
|
|
4526
|
+
return /* @__PURE__ */ jsx26(ErrorBoundary, { componentName: "PublicPageLayout", children: /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
4527
|
+
customHeader || /* @__PURE__ */ jsx26(
|
|
4296
4528
|
PublicPageHeader,
|
|
4297
4529
|
{
|
|
4298
4530
|
event: event || void 0,
|
|
4299
4531
|
eventCode
|
|
4300
4532
|
}
|
|
4301
4533
|
),
|
|
4302
|
-
/* @__PURE__ */
|
|
4303
|
-
showFooter && event && (customFooter || /* @__PURE__ */
|
|
4534
|
+
/* @__PURE__ */ jsx26("main", { className: "px-4 w-[min(var(--app-width),100%)] mx-auto py-8", children }),
|
|
4535
|
+
showFooter && event && (customFooter || /* @__PURE__ */ jsx26(PublicPageFooter, { event }))
|
|
4304
4536
|
] }) });
|
|
4305
4537
|
}
|
|
4306
4538
|
|
|
4307
4539
|
export {
|
|
4540
|
+
AddressField,
|
|
4308
4541
|
Label,
|
|
4309
4542
|
Textarea,
|
|
4310
4543
|
Avatar,
|
|
@@ -4357,4 +4590,4 @@ export {
|
|
|
4357
4590
|
PublicPageFooter,
|
|
4358
4591
|
PublicPageLayout
|
|
4359
4592
|
};
|
|
4360
|
-
//# sourceMappingURL=chunk-
|
|
4593
|
+
//# sourceMappingURL=chunk-LBBUPSSC.js.map
|