@gen-epix/ui-client-common 4.4.1 → 4.5.0
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/README.md +9 -9
- package/dist/_chunks/Breadcrumbs.js.map +1 -1
- package/dist/_chunks/CrudPage.js.map +1 -1
- package/dist/_chunks/Notifications.js.map +1 -1
- package/dist/_chunks/QueryClientProvider.js +1 -1
- package/dist/_chunks/QueryClientProvider.js.map +1 -1
- package/dist/_chunks/Table.js +7 -7
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
- package/dist/_chunks/middleware.js +1 -1
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/react.js +1 -1
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/useColumnsMenu.js +2 -2
- package/dist/_chunks/useColumnsMenu.js.map +1 -1
- package/dist/_chunks/useMutation.js +1 -1
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +4 -4
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -1
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -2
- package/dist/_chunks/yup.js.map +1 -1
- package/dist/components/app/App/index.js +9 -9
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
- package/dist/components/app/AuthenticationWrapper/index.js.map +1 -1
- package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
- package/dist/components/app/RouterRoot/index.js.map +1 -1
- package/dist/components/epi/EpiContactDetailsDialog/index.js.map +1 -1
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/GenericErrorMessage/index.js.map +1 -1
- package/dist/components/ui/LicensesDialog/index.js.map +1 -1
- package/dist/components/ui/MyPermissionsDialog/index.js.map +1 -1
- package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/UserFeedbackDialog/index.js.map +1 -1
- package/dist/components/ui/UserInactivityConfirmation/index.js.map +1 -1
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContext.d.ts +9 -0
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContextProvider.d.ts +6 -0
- package/dist/context/ClientCommonConfigContext/index.d.ts +3 -0
- package/dist/context/{uiClientCommonConfigContext → ClientCommonConfigContext}/index.js +5 -5
- package/dist/context/ClientCommonConfigContext/index.js.map +1 -0
- package/dist/context/ClientCommonConfigContext/useClientCommonConfigContext.d.ts +3 -0
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js.map +1 -1
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js.map +1 -1
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationsQuery/index.js.map +1 -1
- package/dist/dataHooks/useUsersQuery/index.js.map +1 -1
- package/dist/hoc/withPermissions/index.js.map +1 -1
- package/dist/hooks/useConfig/index.js +1 -1
- package/dist/hooks/useConfig/index.js.map +1 -1
- package/dist/hooks/useCreateMutation/index.js.map +1 -1
- package/dist/hooks/useDeleteMutation/index.js.map +1 -1
- package/dist/hooks/useEditMutation/index.js.map +1 -1
- package/dist/hooks/useItemQuery/index.js.map +1 -1
- package/dist/hooks/useUpdateBreadcrumb/index.js.map +1 -1
- package/dist/pages/AcceptInvitationPage/index.js.map +1 -1
- package/dist/pages/AdminPage/index.js.map +1 -1
- package/dist/pages/ChooseIdentityProviderPage/index.js.map +1 -1
- package/dist/pages/IdentifierIssuersAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationContactsAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationSitesAdminPage/index.js.map +1 -1
- package/dist/pages/OrganizationsAdminPage/index.js.map +1 -1
- package/dist/pages/OutagesAdminPage/index.js.map +1 -1
- package/dist/pages/PostLoginPage/index.js.map +1 -1
- package/dist/pages/PostLogoutPage/index.js.map +1 -1
- package/dist/pages/UsersAdminPage/index.js.map +1 -1
- package/dist/setup/setup.d.ts +1 -1
- package/dist/setup/setup.js +1 -1
- package/dist/setup/setup.js.map +1 -1
- package/dist/utils/DependencyContainerUtil/DependencyContainerUtil.d.ts +2 -2
- package/dist/utils/DependencyContainerUtil/index.js +3 -4
- package/dist/utils/DependencyContainerUtil/index.js.map +1 -1
- package/package.json +13 -13
- package/dist/context/uiClientCommonConfigContext/UiClientCommonConfigContext.d.ts +0 -9
- package/dist/context/uiClientCommonConfigContext/UiClientCommonConfigContextProvider.d.ts +0 -6
- package/dist/context/uiClientCommonConfigContext/index.d.ts +0 -3
- package/dist/context/uiClientCommonConfigContext/index.js.map +0 -1
- package/dist/context/uiClientCommonConfigContext/useUiClientCommonConfigContext.d.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["rootContainer","yupResolver","o","OrganizationSwitcherDialog","withDialog","useTranslation","organizationOptionsQuery","useOrganizationOptionsQuery","user","container","AuthorizationService","isChanging","setIsChanging","useState","newOrganizationId","setNewOrganizationId","loadables","useArray","schema","useMemo","object","string","formMethods","useForm","onRefreshPageClick","useCallback","onFormSubmit","formValues","onClose","notificationKey","NotificationService","API_ORGANIZATION_TOKEN","t","useEffect","onTitleChange","onActionsChange","TestIdUtil","handleSubmit","ResponseHandler","Alert","option","FormProvider","Box","Typography","Autocomplete"],"sources":["../../../../src/components/ui/OrganizationSwitcherDialog/OrganizationSwitcherDialog.tsx"],"sourcesContent":["import { container as rootContainer } from 'tsyringe';\nimport { useTranslation } from 'react-i18next';\nimport {\n Alert,\n Box,\n Typography,\n} from '@mui/material';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { yupResolver } from '@hookform/resolvers/yup';\nimport type { Resolver } from 'react-hook-form';\nimport {\n FormProvider,\n useForm,\n} from 'react-hook-form';\nimport {\n object,\n string,\n} from 'yup';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\nimport { Autocomplete } from '@gen-epix/ui-core-form/components/fields/Autocomplete';\nimport type {\n WithDialogRefMethods,\n WithDialogRenderProps,\n} from '@gen-epix/ui-core-components/hoc/withDialog';\nimport { withDialog } from '@gen-epix/ui-core-components/hoc/withDialog';\n\nimport { API_ORGANIZATION_TOKEN } from '../../../constants/api.constants';\nimport { ResponseHandler } from '../ResponseHandler';\nimport { AuthorizationService } from '../../../classes/services/AuthorizationService';\nimport { NotificationService } from '../../../classes/services/NotificationService';\nimport { useOrganizationOptionsQuery } from '../../../dataHooks/useOrganizationsQuery';\n\nexport interface OrganizationSwitcherDialogOpenProps {\n //\n}\n\nexport interface OrganizationSwitcherDialogProps extends WithDialogRenderProps<OrganizationSwitcherDialogOpenProps> {\n //\n}\n\nexport type OrganizationSwitcherDialogRefMethods = WithDialogRefMethods<OrganizationSwitcherDialogProps, OrganizationSwitcherDialogOpenProps>;\n\ntype FormFields = {\n organization_id?: string;\n};\n\nexport const OrganizationSwitcherDialog = withDialog<OrganizationSwitcherDialogProps, OrganizationSwitcherDialogOpenProps>((\n {\n onActionsChange,\n onClose,\n onTitleChange,\n }: OrganizationSwitcherDialogProps,\n): ReactElement => {\n const { t } = useTranslation();\n const organizationOptionsQuery = useOrganizationOptionsQuery();\n const user = rootContainer.resolve(AuthorizationService).user;\n const [isChanging, setIsChanging] = useState(false);\n const [newOrganizationId, setNewOrganizationId] = useState<string>(null);\n\n const loadables = useArray([organizationOptionsQuery]);\n\n const schema = useMemo(() => {\n return object().shape({\n organization_id: string().uuid4().required(),\n });\n }, []);\n\n const formMethods = useForm<FormFields>({\n resolver: yupResolver(schema) as Resolver<FormFields>,\n values: {\n organization_id: user.organization_id,\n },\n });\n const { handleSubmit } = formMethods;\n\n const onRefreshPageClick = useCallback(() => {\n WindowService.getInstance().window.location.reload();\n }, []);\n\n const onFormSubmit = useCallback((formValues: FormFields): void => {\n if (formValues.organization_id === user.organization_id) {\n onClose();\n }\n const perform = async () => {\n const notificationKey = rootContainer.resolve(NotificationService).showNotification({\n isLoading: true,\n message: t`Changing organization...`,\n severity: 'info',\n });\n try {\n setIsChanging(true);\n await rootContainer.resolve(API_ORGANIZATION_TOKEN).updateUserOwnOrganization({\n organization_id: formValues.organization_id,\n }, {});\n setNewOrganizationId(formValues.organization_id);\n setIsChanging(false);\n rootContainer.resolve(NotificationService).fulfillNotification(notificationKey, t`Successfully changed organization.`, 'success');\n } catch (_error: unknown) {\n rootContainer.resolve(NotificationService).fulfillNotification(notificationKey, t`Could not change organization.`, 'error');\n onClose();\n }\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n perform();\n }, [onClose, t, user.organization_id]);\n\n useEffect(() => {\n onTitleChange(t`Switch organization`);\n }, [onTitleChange, t]);\n\n useEffect(() => {\n if (isChanging) {\n onActionsChange([]);\n return;\n }\n\n if (newOrganizationId) {\n onActionsChange([\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-refresh'),\n autoFocus: true,\n color: 'primary',\n label: t`Refresh page`,\n onClick: onRefreshPageClick,\n variant: 'outlined',\n },\n ]);\n return;\n }\n\n onActionsChange(\n [\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-close'),\n autoFocus: true,\n color: 'primary',\n disabled: isChanging,\n label: t`Cancel`,\n onClick: onClose,\n variant: 'outlined',\n },\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-submit'),\n autoFocus: true,\n color: 'secondary',\n disabled: isChanging,\n label: t`Change`,\n onClick: handleSubmit(onFormSubmit),\n variant: 'contained',\n },\n ],\n );\n }, [handleSubmit, newOrganizationId, isChanging, onActionsChange, onClose, onFormSubmit, onRefreshPageClick, t]);\n\n return (\n <ResponseHandler\n isLoading={isChanging}\n loadables={loadables}\n >\n {newOrganizationId && (\n <Alert severity={'success'}>\n {t('Your organization has been changed. You are now a member of \"{{organization}}\". You will need to refresh the page for changes to take effect.', {\n organization: organizationOptionsQuery.options.find((option) => option.value === newOrganizationId)?.label,\n })}\n </Alert>\n )}\n {!newOrganizationId && (\n <FormProvider {...formMethods}>\n <form\n autoComplete={'off'}\n onSubmit={handleSubmit(onFormSubmit)}\n >\n <Box\n sx={{\n marginBottom: 2,\n }}\n >\n <Typography component={'p'}>\n {t`For demo purposes, it is possible to switch your organization. Choose your organization from the list below and click 'Change'.`}\n </Typography>\n </Box>\n <Box>\n <Autocomplete\n label={t`Organization`}\n name={'organization_id'}\n options={organizationOptionsQuery.options}\n />\n </Box>\n </form>\n </FormProvider>\n )}\n </ResponseHandler>\n );\n}, {\n defaultTitle: '',\n disableBackdropClick: true,\n fullWidth: true,\n maxWidth: 'md',\n noCloseButton: true,\n testId: 'OrganizationSwitcherDialog',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,IAAaG,IAA6BC,GACxC,EACE,oBACA,YACA,uBAEe;CACjB,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAA2BC,EAA4B,GACvDC,IAAOR,EAAc,QAAQU,CAAoB,CAAC,CAAC,MACnD,CAACC,GAAYC,KAAiBC,EAAS,EAAK,GAC5C,CAACC,GAAmBC,KAAwBF,EAAiB,IAAI,GAEjEG,IAAYC,EAAS,CAACX,CAAwB,CAAC,GAE/CY,IAASC,QACNC,EAAO,CAAC,CAAC,MAAM,EACpB,iBAAiBC,EAAO,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAC7C,CAAC,GACA,CAAC,CAAC,GAECC,IAAcC,EAAoB;E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ASiB;GACT,SAAS;EACX,GACA;GACE,GAAGQ,EAAW,iBAAiB,mCAAmC;GAClE,WAAW;GACX,OAAO;GACP,UAAUzB;GACV,OAAO,CAAC;GACR,SAAS0B,EAAaX,CAAY;GAClC,SAAS;EACX,CACF,CApCF;CAsCF,GAAG;EAACW;EAAcvB;EAAmBH;EAAYwB;EAAiBP;EAASF;EAAcF;EAAoBQ;CAAC,CAAC,GAG7G,kBAACM,GAAD;EACE,WAAW3B;EACA;EAFb,UAAA,CAIGG,KACC,kBAACyB,GAAD;GAAO,UAAU;GACd,UAAAP,EAAE,mJAAiJ,EAClJ,cAAc1B,EAAyB,QAAQ,MAAM,MAAWkC,EAAO,UAAU1B,CAAiB,CAAC,EAAE,MACvG,CAAC;EACI,CAAA,GAER,CAACA,KACA,kBAAC2B,GAAD;GAAc,GAAInB;GAChB,UAAA,kBAAC,QAAD;IACE,cAAc;IACd,UAAUe,EAAaX,CAAY;IAFrC,UAAA,CAIE,kBAACgB,GAAD;KACE,IAAI,EACF,cAAc,EAChB;KAEA,UAAA,kBAACC,GAAD;MAAY,WAAW;MACpB,UAAA,CAAC;KACQ,CAAA;IACT,CAAA,GACL,kBAACD,GAAD,EAAA,UACE,kBAACE,GAAD;KACE,OAAO,CAAC;KACR,MAAM;KACN,SAAStC,EAAyB;IACnC,CAAA,EACE,CAAA,CACD;;EACM,CAAA,CAED;;AAErB,GAAG;CACD,cAAc;CACd,sBAAsB;CACtB,WAAW;CACX,UAAU;CACV,eAAe;CACf,QAAQ;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["yupResolver","o","OrganizationSwitcherDialog","withDialog","useTranslation","organizationOptionsQuery","useOrganizationOptionsQuery","user","container","AuthorizationService","isChanging","setIsChanging","useState","newOrganizationId","setNewOrganizationId","loadables","useArray","schema","useMemo","object","string","formMethods","useForm","onRefreshPageClick","useCallback","onFormSubmit","formValues","onClose","notificationKey","NotificationService","API_ORGANIZATION_TOKEN","t","useEffect","onTitleChange","onActionsChange","TestIdUtil","handleSubmit","ResponseHandler","Alert","option","FormProvider","Box","Typography","Autocomplete"],"sources":["../../../../src/components/ui/OrganizationSwitcherDialog/OrganizationSwitcherDialog.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useTranslation } from 'react-i18next';\nimport {\n Alert,\n Box,\n Typography,\n} from '@mui/material';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { yupResolver } from '@hookform/resolvers/yup';\nimport type { Resolver } from 'react-hook-form';\nimport {\n FormProvider,\n useForm,\n} from 'react-hook-form';\nimport {\n object,\n string,\n} from 'yup';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\nimport { Autocomplete } from '@gen-epix/ui-core-form/components/fields/Autocomplete';\nimport type {\n WithDialogRefMethods,\n WithDialogRenderProps,\n} from '@gen-epix/ui-core-components/hoc/withDialog';\nimport { withDialog } from '@gen-epix/ui-core-components/hoc/withDialog';\n\nimport { API_ORGANIZATION_TOKEN } from '../../../constants/api.constants';\nimport { ResponseHandler } from '../ResponseHandler';\nimport { AuthorizationService } from '../../../classes/services/AuthorizationService';\nimport { NotificationService } from '../../../classes/services/NotificationService';\nimport { useOrganizationOptionsQuery } from '../../../dataHooks/useOrganizationsQuery';\n\nexport interface OrganizationSwitcherDialogOpenProps {\n //\n}\n\nexport interface OrganizationSwitcherDialogProps extends WithDialogRenderProps<OrganizationSwitcherDialogOpenProps> {\n //\n}\n\nexport type OrganizationSwitcherDialogRefMethods = WithDialogRefMethods<OrganizationSwitcherDialogProps, OrganizationSwitcherDialogOpenProps>;\n\ntype FormFields = {\n organization_id?: string;\n};\n\nexport const OrganizationSwitcherDialog = withDialog<OrganizationSwitcherDialogProps, OrganizationSwitcherDialogOpenProps>((\n {\n onActionsChange,\n onClose,\n onTitleChange,\n }: OrganizationSwitcherDialogProps,\n): ReactElement => {\n const { t } = useTranslation();\n const organizationOptionsQuery = useOrganizationOptionsQuery();\n const user = container.resolve(AuthorizationService).user;\n const [isChanging, setIsChanging] = useState(false);\n const [newOrganizationId, setNewOrganizationId] = useState<string>(null);\n\n const loadables = useArray([organizationOptionsQuery]);\n\n const schema = useMemo(() => {\n return object().shape({\n organization_id: string().uuid4().required(),\n });\n }, []);\n\n const formMethods = useForm<FormFields>({\n resolver: yupResolver(schema) as Resolver<FormFields>,\n values: {\n organization_id: user.organization_id,\n },\n });\n const { handleSubmit } = formMethods;\n\n const onRefreshPageClick = useCallback(() => {\n WindowService.getInstance().window.location.reload();\n }, []);\n\n const onFormSubmit = useCallback((formValues: FormFields): void => {\n if (formValues.organization_id === user.organization_id) {\n onClose();\n }\n const perform = async () => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: t`Changing organization...`,\n severity: 'info',\n });\n try {\n setIsChanging(true);\n await container.resolve(API_ORGANIZATION_TOKEN).updateUserOwnOrganization({\n organization_id: formValues.organization_id,\n }, {});\n setNewOrganizationId(formValues.organization_id);\n setIsChanging(false);\n container.resolve(NotificationService).fulfillNotification(notificationKey, t`Successfully changed organization.`, 'success');\n } catch (_error: unknown) {\n container.resolve(NotificationService).fulfillNotification(notificationKey, t`Could not change organization.`, 'error');\n onClose();\n }\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n perform();\n }, [onClose, t, user.organization_id]);\n\n useEffect(() => {\n onTitleChange(t`Switch organization`);\n }, [onTitleChange, t]);\n\n useEffect(() => {\n if (isChanging) {\n onActionsChange([]);\n return;\n }\n\n if (newOrganizationId) {\n onActionsChange([\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-refresh'),\n autoFocus: true,\n color: 'primary',\n label: t`Refresh page`,\n onClick: onRefreshPageClick,\n variant: 'outlined',\n },\n ]);\n return;\n }\n\n onActionsChange(\n [\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-close'),\n autoFocus: true,\n color: 'primary',\n disabled: isChanging,\n label: t`Cancel`,\n onClick: onClose,\n variant: 'outlined',\n },\n {\n ...TestIdUtil.createAttributes('OrganizationSwitcherDialog-submit'),\n autoFocus: true,\n color: 'secondary',\n disabled: isChanging,\n label: t`Change`,\n onClick: handleSubmit(onFormSubmit),\n variant: 'contained',\n },\n ],\n );\n }, [handleSubmit, newOrganizationId, isChanging, onActionsChange, onClose, onFormSubmit, onRefreshPageClick, t]);\n\n return (\n <ResponseHandler\n isLoading={isChanging}\n loadables={loadables}\n >\n {newOrganizationId && (\n <Alert severity={'success'}>\n {t('Your organization has been changed. You are now a member of \"{{organization}}\". You will need to refresh the page for changes to take effect.', {\n organization: organizationOptionsQuery.options.find((option) => option.value === newOrganizationId)?.label,\n })}\n </Alert>\n )}\n {!newOrganizationId && (\n <FormProvider {...formMethods}>\n <form\n autoComplete={'off'}\n onSubmit={handleSubmit(onFormSubmit)}\n >\n <Box\n sx={{\n marginBottom: 2,\n }}\n >\n <Typography component={'p'}>\n {t`For demo purposes, it is possible to switch your organization. Choose your organization from the list below and click 'Change'.`}\n </Typography>\n </Box>\n <Box>\n <Autocomplete\n label={t`Organization`}\n name={'organization_id'}\n options={organizationOptionsQuery.options}\n />\n </Box>\n </form>\n </FormProvider>\n )}\n </ResponseHandler>\n );\n}, {\n defaultTitle: '',\n disableBackdropClick: true,\n fullWidth: true,\n maxWidth: 'md',\n noCloseButton: true,\n testId: 'OrganizationSwitcherDialog',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,IAAaE,IAA6BC,GACxC,EACE,oBACA,YACA,uBAEe;CACjB,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAA2BC,EAA4B,GACvDC,IAAOC,EAAU,QAAQC,CAAoB,CAAC,CAAC,MAC/C,CAACC,GAAYC,KAAiBC,EAAS,EAAK,GAC5C,CAACC,GAAmBC,KAAwBF,EAAiB,IAAI,GAEjEG,IAAYC,EAAS,CAACX,CAAwB,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;GACP,OAAO,CAAC;GACR,SAASZ;GACT,SAAS;EACX,CACF,IAKA,CACE;GACE,GAAGY,EAAW,iBAAiB,kCAAkC;GACjE,WAAW;GACX,OAAO;GACP,UAAUzB;GACV,OAAO,CAAC;GACR,SAASiB;GACT,SAAS;EACX,GACA;GACE,GAAGQ,EAAW,iBAAiB,mCAAmC;GAClE,WAAW;GACX,OAAO;GACP,UAAUzB;GACV,OAAO,CAAC;GACR,SAAS0B,EAAaX,CAAY;GAClC,SAAS;EACX,CACF,CApCF;CAsCF,GAAG;EAACW;EAAcvB;EAAmBH;EAAYwB;EAAiBP;EAASF;EAAcF;EAAoBQ;CAAC,CAAC,GAG7G,kBAACM,GAAD;EACE,WAAW3B;EACA;EAFb,UAAA,CAIGG,KACC,kBAACyB,GAAD;GAAO,UAAU;GACd,UAAAP,EAAE,mJAAiJ,EAClJ,cAAc1B,EAAyB,QAAQ,MAAM,MAAWkC,EAAO,UAAU1B,CAAiB,CAAC,EAAE,MACvG,CAAC;EACI,CAAA,GAER,CAACA,KACA,kBAAC2B,GAAD;GAAc,GAAInB;GAChB,UAAA,kBAAC,QAAD;IACE,cAAc;IACd,UAAUe,EAAaX,CAAY;IAFrC,UAAA,CAIE,kBAACgB,GAAD;KACE,IAAI,EACF,cAAc,EAChB;KAEA,UAAA,kBAACC,GAAD;MAAY,WAAW;MACpB,UAAA,CAAC;KACQ,CAAA;IACT,CAAA,GACL,kBAACD,GAAD,EAAA,UACE,kBAACE,GAAD;KACE,OAAO,CAAC;KACR,MAAM;KACN,SAAStC,EAAyB;IACnC,CAAA,EACE,CAAA,CACD;;EACM,CAAA,CAED;;AAErB,GAAG;CACD,cAAc;CACd,sBAAsB;CACtB,WAAW;CACX,UAAU;CACV,eAAe;CACf,QAAQ;AACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Breadcrumbs","ApplicationFooter","Fragment$1","PageContainer","title","theme","useTheme","useTranslation","config","useConfig","hasContentHeaderArea","contentHeader","contentActions","hasFooterArea","fullHeight","singleAction","useEffect","pageName","testIdAttributes","container","PageEventBusService","WindowService","ignorePageEvent","Box","Link","ApplicationHeader","showBreadcrumbs","Container","fullWidth","Breadcrumbs$1","Typography","children"],"sources":["../../../../src/components/ui/PageContainer/PageContainer.tsx"],"sourcesContent":["import { container
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Breadcrumbs","ApplicationFooter","Fragment$1","PageContainer","title","theme","useTheme","useTranslation","config","useConfig","hasContentHeaderArea","contentHeader","contentActions","hasFooterArea","fullHeight","singleAction","useEffect","pageName","testIdAttributes","container","PageEventBusService","WindowService","ignorePageEvent","Box","Link","ApplicationHeader","showBreadcrumbs","Container","fullWidth","Breadcrumbs$1","Typography","children"],"sources":["../../../../src/components/ui/PageContainer/PageContainer.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n Box,\n Container,\n Link,\n Typography,\n useTheme,\n} from '@mui/material';\nimport { useEffect } from 'react';\nimport type {\n ReactElement,\n ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\nimport type { PropsWithTestIdAttributes } from '@gen-epix/ui-core/models/test-id.models';\n\nimport { Breadcrumbs } from '../Breadcrumbs';\nimport { PageEventBusService } from '../../../classes/services/PageEventBusService';\nimport { useConfig } from '../../../hooks/useConfig';\nimport { useUpdateDocumentTitle } from '../../../hooks/useUpdateDocumentTitle';\nimport { ApplicationFooter } from '../ApplicationFooter/ApplicationFooter';\n\nexport type PageContainerProps = PropsWithTestIdAttributes<{\n readonly children: ReactNode;\n readonly contentActions?: ReactElement;\n readonly contentHeader?: ReactElement | string;\n readonly fullHeight?: boolean;\n readonly fullWidth?: boolean;\n readonly ignorePageEvent?: boolean;\n readonly showBreadcrumbs?: boolean;\n readonly singleAction?: boolean;\n readonly title: string;\n}>;\n\nexport const PageContainer = ({\n children,\n contentActions,\n contentHeader,\n fullHeight,\n fullWidth,\n ignorePageEvent,\n showBreadcrumbs,\n singleAction,\n testIdAttributes,\n title,\n}: PageContainerProps): ReactElement => {\n useUpdateDocumentTitle(title);\n const theme = useTheme();\n const { t } = useTranslation();\n const config = useConfig();\n\n const hasContentHeaderArea = contentHeader || contentActions;\n const hasFooterArea = !fullHeight && !singleAction;\n const { ApplicationHeader } = config;\n\n useEffect(() => {\n const pageName = testIdAttributes['data-testid'];\n if (ignorePageEvent || !pageName) {\n return;\n }\n\n if (config.enablePageEvents) {\n container.resolve(PageEventBusService).emit('changePage', {\n location: WindowService.getInstance().window.location,\n pageName: testIdAttributes['data-testid'],\n });\n }\n }, [config.enablePageEvents, ignorePageEvent, testIdAttributes]);\n\n return (\n <>\n <Box\n component={'nav'}\n sx={{\n background: theme.palette.background.default,\n marginTop: '-1px',\n position: 'absolute',\n top: 0,\n zIndex: theme.zIndex.appBar + 10,\n }}\n >\n <Link\n component={'a'}\n href={'#main-content'}\n sx={{\n '&:focus, &:active': {\n clip: 'auto',\n height: 'auto',\n overflow: 'visible',\n position: 'static',\n whiteSpace: 'normal',\n width: 'auto',\n },\n border: 0,\n height: '1px',\n left: 0,\n overflow: 'hidden',\n position: 'absolute',\n top: 0,\n whiteSpace: 'nowrap',\n\n width: '1px',\n }}\n >\n {t`Skip to main content`}\n </Link>\n </Box>\n <Box\n data-page-container\n {...testIdAttributes}\n sx={{\n display: 'grid',\n gridTemplateRows: `max-content auto ${hasFooterArea ? 'max-content' : ''}`,\n height: '100%',\n }}\n >\n <ApplicationHeader\n fullHeight={fullHeight}\n fullWidth={fullWidth}\n singleAction={singleAction}\n />\n <Box\n id={config.layout.MAIN_CONTENT_ID}\n sx={{\n display: 'grid',\n gridTemplateRows: `${showBreadcrumbs ? 'max-content' : ''} auto`,\n height: '100%',\n }}\n >\n {showBreadcrumbs && (\n <Container\n maxWidth={fullWidth ? false : 'xl'}\n sx={{\n paddingLeft: `${theme.spacing(fullWidth ? 1 : 2)} !important`,\n paddingRight: `${theme.spacing(fullWidth ? 1 : 2)} !important`,\n }}\n >\n <Breadcrumbs />\n </Container>\n )}\n <Container\n maxWidth={fullWidth ? false : 'xl'}\n sx={{\n display: 'grid',\n gridTemplateRows: `${hasContentHeaderArea ? 'max-content' : ''} auto`,\n height: '100%',\n paddingLeft: `${theme.spacing(fullWidth ? 1 : 2)} !important`,\n paddingRight: `${theme.spacing(fullWidth ? 1 : 2)} !important`,\n position: 'relative',\n }}\n >\n {hasContentHeaderArea && (\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n marginBottom: theme.spacing(1),\n }}\n >\n {contentHeader && typeof contentHeader === 'string' && (\n <Box>\n <Typography variant={'h2'}>\n {contentHeader}\n </Typography>\n </Box>\n )}\n {contentHeader && typeof contentHeader !== 'string' && contentHeader}\n {contentActions && (\n <Box>\n {contentActions}\n </Box>\n )}\n </Box>\n )}\n {singleAction && (\n <Box\n sx={{\n marginY: 1,\n }}\n >\n <Box\n component={'a'}\n href={'#main-content'}\n id={'main-content'}\n style={{ display: 'none' }}\n tabIndex={-1}\n />\n {children}\n </Box>\n )}\n {!singleAction && (\n <>\n <Box\n component={'a'}\n href={'#main-content'}\n id={'main-content'}\n style={{ display: 'none' }}\n tabIndex={-1}\n />\n {children}\n </>\n )}\n </Container>\n </Box>\n {hasFooterArea && (\n <ApplicationFooter fullWidth={fullWidth} />\n )}\n </Box>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAmCA,IAAaI,KAAiB,EAC5B,aACA,mBACA,kBACA,eACA,cACA,oBACA,oBACA,iBACA,qBACA,eACsC;CACtC,EAAuBC,CAAK;CAC5B,IAAMC,IAAQC,EAAS,GACjB,EAAE,SAAMC,EAAe,GACvBC,IAASC,EAAU,GAEnBC,IAAuBC,KAAiBC,GACxCC,IAAgB,CAACC,KAAc,CAACC,GAChC,EAAE,yBAAsBP;CAgB9B,OAdAQ,QAAgB;EACd,IAAMC,IAAWC,EAAiB;EAClC,AAAI,MAAoBD,K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AU,MAAoB;KAC9B,IAAI;MACF,SAAS;MACT,kBAAkB,GAAGjB,IAAuB,gBAAgB,GAAG;MAC/D,QAAQ;MACR,aAAa,GAAGL,EAAM,QAAQuB,IAAY,IAAI,CAAC,EAAE;MACjD,cAAc,GAAGvB,EAAM,QAAQuB,IAAY,IAAI,CAAC,EAAE;MAClD,UAAU;KACZ;KATF,UAAA;MAWGlB,KACC,kBAACa,GAAD;OACE,IAAI;QACF,SAAS;QACT,eAAe;QACf,gBAAgB;QAChB,cAAclB,EAAM,QAAQ,CAAC;OAC/B;OANF,UAAA;QAQGM,KAAiB,OAAOA,KAAkB,YACzC,kBAACY,GAAD,EAAA,UACE,kBAACO,GAAD;SAAY,SAAS;SAClB,UAAAnB;QACS,CAAA,EACT,CAAA;QAENA,KAAiB,OAAOA,KAAkB,YAAYA;QACtDC,KACC,kBAACW,GAAD,EAAA,UACGX,EACE,CAAA;OAEJ;;MAENG,KACC,kBAACQ,GAAD;OACE,IAAI,EACF,SAAS,EACX;OAHF,UAAA,CAKE,kBAACA,GAAD;QACE,WAAW;QACX,MAAM;QACN,IAAI;QACJ,OAAO,EAAE,SAAS,OAAO;QACzB,UAAU;OACX,CAAA,GACAQ,CACE;;MAEN,CAAChB,KACA,kBAAAhB,GAAA,EAAA,UAAA,CACE,kBAACwB,GAAD;OACE,WAAW;OACX,MAAM;OACN,IAAI;OACJ,OAAO,EAAE,SAAS,OAAO;OACzB,UAAU;MACX,CAAA,GACAQ,CACD,EAAA,CAAA;KAEK;IACR,CAAA,CAAA;;GACJlB,KACC,kBAACZ,GAAD,EAA8B,aAAY,CAAA;EAEzC;CACL,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["yupResolver","
|
|
1
|
+
{"version":3,"file":"index.js","names":["yupResolver","o","UserFeedbackDialog","withDialog","useTranslation","config","useConfig","schema","useMemo","object","string","SchemaUtil","formMethods","useForm","container","AuthorizationService","UserSettingsService","formFieldDefinitions","FORM_FIELD_DEFINITION_TYPE","t","onTitleChange","onFormSubmit","useCallback","navigationHistory","NavigationHistoryService","LogService","formValues","NotificationService","onClose","useEffect","TestIdUtil","handleSubmit","onActionsChange","Box","Typography","GenericForm"],"sources":["../../../../src/components/ui/UserFeedbackDialog/UserFeedbackDialog.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useTranslation } from 'react-i18next';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useEffect,\n useMemo,\n} from 'react';\nimport type { Resolver } from 'react-hook-form';\nimport { useForm } from 'react-hook-form';\nimport { yupResolver } from '@hookform/resolvers/yup';\nimport {\n object,\n string,\n} from 'yup';\nimport {\n Box,\n Typography,\n} from '@mui/material';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { SchemaUtil } from '@gen-epix/ui-core-form/utils/SchemaUtil';\nimport { GenericForm } from '@gen-epix/ui-core-form/components/helpers/GenericForm';\nimport type { FormFieldDefinition } from '@gen-epix/ui-core-form/models/form.models';\nimport { FORM_FIELD_DEFINITION_TYPE } from '@gen-epix/ui-core-form/models/form.models';\nimport type {\n WithDialogRefMethods,\n WithDialogRenderProps,\n} from '@gen-epix/ui-core-components/hoc/withDialog';\nimport { withDialog } from '@gen-epix/ui-core-components/hoc/withDialog';\n\nimport { LogService } from '../../../classes/services/LogService';\nimport { NavigationHistoryService } from '../../../classes/services/NavigationHistoryService';\nimport { NotificationService } from '../../../classes/services/NotificationService';\nimport { UserSettingsService } from '../../../classes/services/UserSettingsService';\nimport { AuthorizationService } from '../../../classes/services/AuthorizationService';\nimport { useConfig } from '../../../hooks/useConfig';\n\nexport interface UserFeedbackDialogOpenProps {\n //\n}\n\nexport interface UserFeedbackDialogProps extends WithDialogRenderProps<UserFeedbackDialogOpenProps> {\n //\n}\n\nexport type UserFeedbackDialogRefMethods = WithDialogRefMethods<UserFeedbackDialogProps, UserFeedbackDialogOpenProps>;\n\ntype FormFields = {\n email: string;\n message: string;\n name: string;\n};\n\nexport const UserFeedbackDialog = withDialog<UserFeedbackDialogProps, UserFeedbackDialogOpenProps>((\n {\n onActionsChange,\n onClose,\n onTitleChange,\n }: UserFeedbackDialogProps,\n): ReactElement => {\n const { t } = useTranslation();\n const config = useConfig();\n\n const schema = useMemo(() => object<FormFields>().shape({\n email: string().email().required().max(200),\n message: string().freeFormText().required().max(5000),\n name: SchemaUtil.name,\n }), []);\n\n const formMethods = useForm<FormFields>({\n resolver: yupResolver(schema) as Resolver<FormFields>,\n values: {\n email: container.resolve(AuthorizationService).user?.email ?? container.resolve(AuthorizationService).user?.key ?? '',\n message: '',\n name: container.resolve(AuthorizationService).user?.name ?? '',\n },\n });\n const { handleSubmit } = formMethods;\n\n useEffect(() => {\n container.resolve(UserSettingsService).showShowUserFeedbackTooltip = false;\n }, []);\n\n const formFieldDefinitions = useMemo<FormFieldDefinition<FormFields>[]>(() => [\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Name`,\n name: 'name',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Email`,\n name: 'email',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Your message`,\n multiline: true,\n name: 'message',\n rows: 15,\n } as const satisfies FormFieldDefinition<FormFields>,\n ] as const, [t]);\n\n useEffect(() => {\n onTitleChange(t`Feedback`);\n }, [onTitleChange, t]);\n\n const onFormSubmit = useCallback((formValues: FormFields): void => {\n const navigationHistory = container.resolve(NavigationHistoryService).navigationHistory;\n container.resolve(LogService).log([{\n detail: {\n ...formValues,\n navigationHistory: navigationHistory.slice(navigationHistory.length - 50).reverse(),\n },\n level: 'INFO',\n topic: 'USER_FEEDBACK',\n }]);\n container.resolve(LogService).flushLog();\n container.resolve(NotificationService).showNotification({\n message: t`Thank you for sharing your feedback with us`,\n severity: 'success',\n });\n onClose();\n }, [onClose, t]);\n\n useEffect(() => {\n onActionsChange(\n [\n {\n ...TestIdUtil.createAttributes('UserFeedbackDialog-close'),\n autoFocus: true,\n color: 'primary',\n label: t`Cancel`,\n onClick: onClose,\n variant: 'outlined',\n },\n {\n ...TestIdUtil.createAttributes('UserFeedbackDialog-send'),\n autoFocus: true,\n color: 'secondary',\n label: t`Send`,\n onClick: handleSubmit(onFormSubmit),\n variant: 'contained',\n },\n ],\n );\n }, [handleSubmit, onActionsChange, onClose, onFormSubmit, t]);\n\n return (\n <Box>\n <Box\n sx={{\n marginBottom: 2,\n }}\n >\n <Typography component={'p'}>\n {t('Please help make {{applicationName}} better by sharing your feedback with us. You may use this form as many times as you like.', { applicationName: config.applicationName })}\n </Typography>\n </Box>\n <GenericForm<FormFields>\n formFieldDefinitions={formFieldDefinitions}\n formMethods={formMethods}\n onSubmit={handleSubmit(onFormSubmit)}\n schema={schema}\n />\n </Box>\n );\n}, {\n defaultTitle: '',\n disableBackdropClick: false,\n fullWidth: true,\n maxWidth: 'md',\n noCloseButton: false,\n testId: 'UserFeedbackDialog',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqDA,IAAaE,IAAqBC,GAChC,EACE,oBACA,YACA,uBAEe;CACjB,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAASC,EAAU,GAEnBC,IAASC,QAAcC,EAAmB,CAAC,CAAC,MAAM;EACtD,OAAOC,EAAO,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,GAAG;EAC1C,SAASA,EAAO,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,GAAI;EACpD,MAAMC,EAAW;CACnB,CAAC,GAAG,CAAC,CAAC,GAEAC,IAAcC,EAAoB;EACtC,UAAUb,EAAYO,CAAM;EAC5B,QAAQ;GACN,OAAOO,EAAU,QAAQC,CAAoB,CAAC,CAAC,MAAM,SAASD,EAAU,QAAQC,CAAoB,CAAC,CAAC,MAAM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AClC,SAAS;EACX,CACF,CACF;CACF,GAAG;EAACU;EAAcC;EAAiBJ;EAASP;EAAcF;CAAC,CAAC,GAG1D,kBAACc,GAAD,EAAA,UAAA,CACE,kBAACA,GAAD;EACE,IAAI,EACF,cAAc,EAChB;EAEA,UAAA,kBAACC,GAAD;GAAY,WAAW;GACpB,UAAAf,EAAE,kIAAkI,EAAE,iBAAiBd,EAAO,gBAAgB,CAAC;EACtK,CAAA;CACT,CAAA,GACL,kBAAC8B,GAAD;EACwB;EACT;EACb,UAAUJ,EAAaV,CAAY;EAC3B;CACT,CAAA,CACE,EAAA,CAAA;AAET,GAAG;CACD,cAAc;CACd,sBAAsB;CACtB,WAAW;CACX,UAAU;CACV,eAAe;CACf,QAAQ;AACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["UserInactivityConfirmation","useTranslation","confirmationRef","useRef","idleState","setIdleState","useState","container","InactivityService","unsubscribe","data","onCancel","useCallback","onClose","Confirmation","t"],"sources":["../../../../src/components/ui/UserInactivityConfirmation/UserInactivityConfirmation.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport type { ConfirmationRefMethods } from '@gen-epix/ui-core-components/components/Confirmation';\nimport { Confirmation } from '@gen-epix/ui-core-components/components/Confirmation';\n\nimport type { InactivityState } from '../../../classes/services/InactivityService';\nimport { InactivityService } from '../../../classes/services/InactivityService';\n\nexport const UserInactivityConfirmation = () => {\n const { t } = useTranslation();\n const confirmationRef = useRef<ConfirmationRefMethods>(null);\n const [idleState, setIdleState] = useState<InactivityState>(container.resolve(InactivityService).data);\n\n\n useEffect(() => {\n const unsubscribe = container.resolve(InactivityService).subscribe((data) => {\n if (data.isIdle) {\n setIdleState(data);\n confirmationRef.current?.open();\n } else {\n confirmationRef.current?.close();\n }\n });\n return () => {\n unsubscribe();\n };\n }, []);\n\n const onCancel = useCallback(() => {\n container.resolve(InactivityService).logout();\n }, []);\n\n const onClose = useCallback(() => {\n container.resolve(InactivityService).reset();\n }, []);\n\n\n return (\n <Confirmation\n body={t('Because you were inactive for the last {{formattedTimeInactive}}, you will be automatically logged out in {{formattedTimeUntilLogout}}.', {\n formattedTimeInactive: idleState.readableIdleDiff,\n formattedTimeUntilLogout: idleState.readableNotificationDiff,\n })}\n cancelLabel={'Logout'}\n confirmLabel={t`Stay logged in`}\n maxWidth={'xs'}\n onCancel={onCancel}\n onClose={onClose}\n onConfirm={onClose}\n ref={confirmationRef}\n title={t`Your session is about to expire`}\n />\n );\n};\n"],"mappings":";;;;;;;AAcA,IAAaA,UAAmC;CAC9C,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAAkBC,EAA+B,IAAI,GACrD,CAACC,GAAWC,KAAgBC,EAA0BC,EAAU,QAAQC,CAAiB,CAAC,CAAC,IAAI;CAGrG,QAAgB;EACd,IAAMC,IAAcF,EAAU,QAAQC,CAAiB,CAAC,CAAC,WAAW,MAAS;GAC3E,AAAIE,EAAK,UACPL,EAAaK,CAAI,GACjBR,EAAgB,SAAS,KAAK,KAE9BA,EAAgB,SAAS,MAAM;EAEnC,CAAC;EACD,aAAa;GACX,EAAY;EACd;CACF,GAAG,CAAC,CAAC;CAEL,IAAMS,IAAWC,QAAkB;EACjC,EAAU,QAAQJ,CAAiB,CAAC,CAAC,OAAO;CAC9C,GAAG,CAAC,CAAC,GAECK,IAAUD,QAAkB;EAChC,EAAU,QAAQJ,CAAiB,CAAC,CAAC,MAAM;CAC7C,GAAG,CAAC,CAAC;CAGL,OACE,kBAACM,GAAD;EACE,MAAMC,EAAE,2IAA2I;GACjJ,uBAAuBX,EAAU;GACjC,0BAA0BA,EAAU;EACtC,CAAC;EACD,aAAa;EACb,cAAc,CAAC;EACf,UAAU;EACA;EACD;EACT,WAAWS;EACX,KAAKX;EACL,OAAO,CAAC;CACT,CAAA;AAEL"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreComponentsConfig } from '@gen-epix/ui-core-components/context/CoreComponentsConfigContext';
|
|
2
|
+
import { DependencyContainer } from 'tsyringe';
|
|
3
|
+
import { ConfigBase } from '../../models/config.models';
|
|
4
|
+
export type ClientCommonConfig<TConfig extends ConfigBase = ConfigBase> = {
|
|
5
|
+
config: TConfig;
|
|
6
|
+
container: DependencyContainer;
|
|
7
|
+
coreComponentsConfig: CoreComponentsConfig;
|
|
8
|
+
};
|
|
9
|
+
export declare const ClientCommonConfigContext: import('react').Context<ClientCommonConfig<ConfigBase>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { DependencyContainer } from 'tsyringe';
|
|
3
|
+
export type ClientCommonConfigContextProviderProps = PropsWithChildren<{
|
|
4
|
+
readonly container: DependencyContainer;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const ClientCommonConfigContextProvider: (props: ClientCommonConfigContextProviderProps) => import('react').JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DependencyContainerUtil as e } from "../../utils/DependencyContainerUtil/index.js";
|
|
2
2
|
import { createContext as t, use as n, useMemo as r } from "react";
|
|
3
3
|
import { jsx as i } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
-
//#region src/context/
|
|
4
|
+
import { CoreComponentsConfigContext as a } from "@gen-epix/ui-core-components/context/CoreComponentsConfigContext";
|
|
5
|
+
//#region src/context/ClientCommonConfigContext/ClientCommonConfigContext.tsx
|
|
6
6
|
var o = t(null), s = (t) => {
|
|
7
7
|
let { children: n, container: s } = t, c = e.resolveConfig(s), l = r(() => ({ spinner: {
|
|
8
8
|
defaultCircularProgressSize: c.spinner.DEFAULT_CIRCULAR_PROGRESS_SIZE,
|
|
@@ -10,7 +10,7 @@ var o = t(null), s = (t) => {
|
|
|
10
10
|
} }), [c.spinner]), u = r(() => ({
|
|
11
11
|
config: c,
|
|
12
12
|
container: s,
|
|
13
|
-
|
|
13
|
+
coreComponentsConfig: l
|
|
14
14
|
}), [
|
|
15
15
|
c,
|
|
16
16
|
s,
|
|
@@ -25,10 +25,10 @@ var o = t(null), s = (t) => {
|
|
|
25
25
|
});
|
|
26
26
|
}, c = () => {
|
|
27
27
|
let e = n(o);
|
|
28
|
-
if (!e) throw Error("
|
|
28
|
+
if (!e) throw Error("ClientCommonConfigContext is not available");
|
|
29
29
|
return e;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
|
-
export { o as
|
|
32
|
+
export { o as ClientCommonConfigContext, s as ClientCommonConfigContextProvider, c as useClientCommonConfigContext };
|
|
33
33
|
|
|
34
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ClientCommonConfigContext","createContext","ClientCommonConfigContextProvider","props","config","DependencyContainerUtil","container","coreComponentsConfig","useMemo","uiClientCommonConfig","CoreComponentsConfigContext","useClientCommonConfigContext","use"],"sources":["../../../src/context/ClientCommonConfigContext/ClientCommonConfigContext.tsx","../../../src/context/ClientCommonConfigContext/ClientCommonConfigContextProvider.tsx","../../../src/context/ClientCommonConfigContext/useClientCommonConfigContext.tsx"],"sourcesContent":["import type { CoreComponentsConfig } from '@gen-epix/ui-core-components/context/CoreComponentsConfigContext';\nimport { createContext } from 'react';\nimport type { DependencyContainer } from 'tsyringe';\n\nimport type { ConfigBase } from '../../models/config.models';\n\nexport type ClientCommonConfig<TConfig extends ConfigBase = ConfigBase> = {\n config: TConfig;\n container: DependencyContainer;\n coreComponentsConfig: CoreComponentsConfig;\n};\n\nexport const ClientCommonConfigContext = createContext<ClientCommonConfig>(null);\n","import { useMemo } from 'react';\nimport type { PropsWithChildren } from 'react';\nimport { CoreComponentsConfigContext } from '@gen-epix/ui-core-components/context/CoreComponentsConfigContext';\nimport type { DependencyContainer } from 'tsyringe';\n\nimport { DependencyContainerUtil } from '../../utils/DependencyContainerUtil';\nimport type { ConfigBase } from '../../models/config.models';\n\nimport type { ClientCommonConfig } from './ClientCommonConfigContext';\nimport { ClientCommonConfigContext } from './ClientCommonConfigContext';\n\n\nexport type ClientCommonConfigContextProviderProps = PropsWithChildren<{\n readonly container: DependencyContainer;\n}>;\n\nexport const ClientCommonConfigContextProvider = (\n props: ClientCommonConfigContextProviderProps,\n) => {\n const { children, container } = props;\n const config = DependencyContainerUtil.resolveConfig<ConfigBase>(container);\n const coreComponentsConfig = useMemo<ClientCommonConfig['coreComponentsConfig']>(() => ({\n spinner: {\n defaultCircularProgressSize: config.spinner.DEFAULT_CIRCULAR_PROGRESS_SIZE,\n defaultTakingLongerTimeoutMs: config.spinner.DEFAULT_TAKING_LONGER_TIMEOUT_MS,\n },\n }), [config.spinner]);\n const uiClientCommonConfig = useMemo(() => ({ config, container, coreComponentsConfig }), [config, container, coreComponentsConfig]);\n\n return (\n <CoreComponentsConfigContext value={coreComponentsConfig}>\n <ClientCommonConfigContext value={uiClientCommonConfig}>\n {children}\n </ClientCommonConfigContext>\n </CoreComponentsConfigContext>\n );\n};\n","import { use } from 'react';\n\nimport type { ConfigBase } from '../../models/config.models';\n\nimport type { ClientCommonConfig } from './ClientCommonConfigContext';\nimport { ClientCommonConfigContext } from './ClientCommonConfigContext';\n\nexport const useClientCommonConfigContext = <TConfig extends ConfigBase = ConfigBase>(): ClientCommonConfig<TConfig> => {\n const config = use(ClientCommonConfigContext);\n if (!config) {\n throw new Error('ClientCommonConfigContext is not available');\n }\n return config as ClientCommonConfig<TConfig>;\n};\n"],"mappings":";;;;;AAYA,IAAaA,IAA4BC,EAAkC,IAAI,GCIlEC,KACX,MACG;CACH,IAAM,EAAE,aAAU,iBAAcC,GAC1BC,IAASC,EAAwB,cAA0BC,CAAS,GACpEC,IAAuBC,SAA2D,EACtF,SAAS;EACP,6BAA6BJ,EAAO,QAAQ;EAC5C,8BAA8BA,EAAO,QAAQ;CAC/C,EACF,IAAI,CAACA,EAAO,OAAO,CAAC,GACdK,IAAuBD,SAAe;EAAE;EAAQ;EAAW;CAAqB,IAAI;EAACJ;EAAQE;EAAWC;CAAoB,CAAC;CAEnI,OACE,kBAACG,GAAD;EAA6B,OAAOH;EAClC,UAAA,kBAACP,GAAD;GAA2B,OAAOS;GAC/B;EACwB,CAAA;CACA,CAAA;AAEjC,GC7BaE,UAA2G;CACtH,IAAMP,IAASQ,EAAIZ,CAAyB;CAC5C,IAAI,CAACI,GACH,MAAU,MAAM,4CAA4C;CAE9D,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useIdentifierIssuerOwnOrganizationQuery","useQueryMemo","links","container","API_ORGANIZATION_TOKEN","AuthorizationService","x","COMMON_QUERY_KEY","useIdentifierIssuerOwnOrganizationOptionsQuery","response","useMemo","DataHookUtil","item"],"sources":["../../../src/dataHooks/useIdentifierIssuerOwnOrganizationQuery/useIdentifierIssuerOwnOrganizationQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMemo } from 'react';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { CommonDbIdentifierIssuer } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type { UseOptions } from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\nexport const useIdentifierIssuerOwnOrganizationQuery = (): UseQueryResult<CommonDbIdentifierIssuer[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const links = (await container.resolve(API_ORGANIZATION_TOKEN).organizationIdentifierIssuerLinksPostQuery({\n key: 'organization_id',\n type: 'EQUALS_UUID',\n value: container.resolve(AuthorizationService).user.organization_id,\n }, null, null, { signal })).data;\n const response = await container.resolve(API_ORGANIZATION_TOKEN).identifierIssuersGetSome(links.map(x => x.identifier_issuer_id).join(','), { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.IDENTIFIER_ISSUERS_OWN_ORGANIZATION),\n });\n};\n\nexport const useIdentifierIssuerOwnOrganizationOptionsQuery = (): UseOptions<string> => {\n const response = useIdentifierIssuerOwnOrganizationQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbIdentifierIssuer>(response, item => item.id, (item: CommonDbIdentifierIssuer) => item.name);\n }, [response]);\n};\n"],"mappings":";;;;;;;;;AAaA,IAAaC,UACJC,EAAa;CAClB,SAAS,OAAO,EAAE,gBAAa;EAC7B,IAAMC,KAAS,MAAMC,EAAU,QAAQC,CAAsB,CAAC,CAAC,2CAA2C;GACxG,KAAK;GACL,MAAM;GACN,OAAOD,EAAU,QAAQE,CAAoB,CAAC,CAAC,KAAK;EACtD,GAAG,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CAAG;EAE5B,QAAO,MADgBF,EAAU,QAAQC,CAAsB,CAAC,CAAC,yBAAyBF,EAAM,KAAI,MAAKI,EAAE,oBAAoB,CAAC,CAAC,KAAK,GAAG,GAAG,EAAE,UAAO,CAAC,EAAA,CACtI;CAClB;CACA,UAAUH,EAAU,QAAQJ,CAAkB,CAAC,CAAC,cAAcQ,EAAiB,mCAAmC;AACpH,CAAC,GAGUC,UAA2E;CACtF,IAAMC,IAAWT,EAAwC;CAEzD,OAAOU,QACEC,EAAa,yBAAmDF,IAAU,MAAQG,EAAK,KAAK,MAAmCA,EAAK,IAAI,GAC9I,CAACH,CAAQ,CAAC;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useIdentifierIssuersQuery","useQueryMemo","container","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY","select","data","useIdentifierIssuerMapQuery","response","useMemo","DataHookUtil","item","useIdentifierIssuerOptionsQuery"],"sources":["../../../src/dataHooks/useIdentifierIssuerQuery/useIdentifierIssuerQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMemo } from 'react';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { CommonDbIdentifierIssuer } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\ntype Select = (data: CommonDbIdentifierIssuer[]) => CommonDbIdentifierIssuer[];\n\nexport const useIdentifierIssuersQuery = (select?: Select): UseQueryResult<CommonDbIdentifierIssuer[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).identifierIssuersGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.IDENTIFIER_ISSUERS),\n select: select ? (data) => select(data) : undefined,\n });\n};\n\nexport const useIdentifierIssuerMapQuery = (select?: Select): UseMap<CommonDbIdentifierIssuer> => {\n const response = useIdentifierIssuersQuery(select);\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbIdentifierIssuer>(response, item => item.id);\n }, [response]);\n};\n\nexport const useIdentifierIssuerOptionsQuery = (select?: Select): UseOptions<string> => {\n const response = useIdentifierIssuersQuery(select);\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbIdentifierIssuer>(response, item => item.id, (item: CommonDbIdentifierIssuer) => item.name);\n }, [response]);\n};\n"],"mappings":";;;;;;;;AAiBA,IAAaC,KAA6B,MACjCC,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBC,EAAU,QAAQC,CAAsB,CAAC,CAAC,wBAAwB,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CAC/F;CAElB,UAAUD,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcK,EAAiB,kBAAkB;CACjG,QAAQC,KAAU,MAASA,EAAOC,CAAI,IAAI,KAAA;AAC5C,CAAC,GAGUC,KAA+B,MAAsD;CAChG,IAAMC,IAAWR,EAA0BK,CAAM;CAEjD,OAAOI,QACEC,EAAa,qBAA+CF,IAAU,MAAQG,EAAK,EAAE,GAC3F,CAACH,CAAQ,CAAC;AACf,GAEaI,KAAmC,MAAwC;CACtF,IAAMJ,IAAWR,EAA0BK,CAAM;CAEjD,OAAOI,QACEC,EAAa,yBAAmDF,IAAU,MAAQG,EAAK,KAAK,MAAmCA,EAAK,IAAI,GAC9I,CAACH,CAAQ,CAAC;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useInviteUserConstraintsQuery","useQueryMemo","container","AuthorizationService","CommonDbCommandName","CommonDbPermissionType","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY"],"sources":["../../../src/dataHooks/useInviteUserConstraintsQuery/useInviteUserConstraintsQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { CommonDbUserInvitationConstraints } from '@gen-epix/api-commondb';\nimport {\n CommonDbCommandName,\n CommonDbPermissionType,\n} from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\n\nexport const useInviteUserConstraintsQuery = (): UseQueryResult<CommonDbUserInvitationConstraints> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n if (!container.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.RetrieveInviteUserConstraintsCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n return {\n organization_ids: [],\n roles: [],\n };\n }\n\n const response = await container.resolve(API_ORGANIZATION_TOKEN).inviteUserConstraints({ signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.INVITE_USER_CONSTRAINTS),\n });\n};\n"],"mappings":";;;;;;;;AAeA,IAAaC,UACJC,EAAa;CAClB,SAAS,OAAO,EAAE,gBACXC,EAAU,QAAQC,CAAoB,CAAC,CAAC,uBAAuB,CAClE;EAAE,cAAcC,EAAoB;EAAsC,iBAAiBC,EAAuB;CAAQ,CAC5H,CAAC,KAQM,MADgBH,EAAU,QAAQI,CAAsB,CAAC,CAAC,sBAAsB,EAAE,UAAO,CAAC,EAAA,CACjF,OAPP;EACL,kBAAkB,CAAC;EACnB,OAAO,CAAC;CACV;CAMJ,UAAUJ,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcQ,EAAiB,uBAAuB;AACxG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useQueryMemo","useOrganizationAdminPoliciesQuery","container","API_ABAC_TOKEN","QueryClientService","COMMON_QUERY_KEY","useOrganizationAdminPolicyMapQuery","organizationAdminPoliciesQuery","useMemo","DataHookUtil","item","useOrganizationAdminPolicyNameFactory","useTranslation","organizationMapQuery","useOrganizationMapQuery","usersMapQuery","useUsersMapQuery","UserUtil","useOrganizationAdminPolicyOptionsQuery","organizationAdminPolicyNameFactory"],"sources":["../../../src/dataHooks/useOrganizationAdminPoliciesQuery/useOrganizationAdminPoliciesQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport type { CommonDbOrganizationAdminPolicy } from '@gen-epix/api-commondb';\n\nimport { API_ABAC_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseNameFactory,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useOrganizationMapQuery } from '../useOrganizationsQuery';\nimport { useUsersMapQuery } from '../useUsersQuery';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { UserUtil } from '../../utils/UserUtil';\n\nexport const useOrganizationAdminPoliciesQuery = (): UseQueryResult<CommonDbOrganizationAdminPolicy[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ABAC_TOKEN).organizationAdminPoliciesGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.ORGANIZATION_ADMIN_POLICIES),\n });\n};\n\nexport const useOrganizationAdminPolicyMapQuery = (): UseMap<CommonDbOrganizationAdminPolicy> => {\n const organizationAdminPoliciesQuery = useOrganizationAdminPoliciesQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbOrganizationAdminPolicy>(organizationAdminPoliciesQuery, item => item.id);\n\n }, [organizationAdminPoliciesQuery]);\n};\n\nexport const useOrganizationAdminPolicyNameFactory = (): UseNameFactory<CommonDbOrganizationAdminPolicy> => {\n const { t } = useTranslation();\n\n const organizationMapQuery = useOrganizationMapQuery();\n const usersMapQuery = useUsersMapQuery();\n\n return useMemo(() => {\n const getName = (item: CommonDbOrganizationAdminPolicy) => {\n return `${organizationMapQuery.map.get(item.organization_id)?.name ?? item.organization_id} -> ${UserUtil.getUserDisplayValue(usersMapQuery.map.get(item.user_id), t)}`;\n };\n return DataHookUtil.createUseNameFactoryHook(getName, [organizationMapQuery, usersMapQuery]);\n }, [organizationMapQuery, t, usersMapQuery]);\n};\n\nexport const useOrganizationAdminPolicyOptionsQuery = (): UseOptions<string> => {\n const organizationAdminPoliciesQuery = useOrganizationAdminPoliciesQuery();\n const organizationAdminPolicyNameFactory = useOrganizationAdminPolicyNameFactory();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbOrganizationAdminPolicy>(organizationAdminPoliciesQuery, item => item.id, organizationAdminPolicyNameFactory.getName, [organizationAdminPolicyNameFactory]);\n }, [organizationAdminPolicyNameFactory, organizationAdminPoliciesQuery]);\n};\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAaC,UACJD,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBE,EAAU,QAAQC,CAAc,CAAC,CAAC,gCAAgC,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CAC/F;CAElB,UAAUD,EAAU,QAAQE,CAAkB,CAAC,CAAC,cAAcC,EAAiB,2BAA2B;AAC5G,CAAC,GAGUC,UAAoF;CAC/F,IAAMC,IAAiCN,EAAkC;CAEzE,OAAOO,QACEC,EAAa,qBAAsDF,IAAgC,MAAQG,EAAK,EAAE,GAExH,CAACH,CAA8B,CAAC;AACrC,GAEaI,UAA+F;CAC1G,IAAM,EAAE,MAAMC,EAAe,GAEvBC,IAAuBC,EAAwB,GAC/CC,IAAgBC,EAAiB;CAEvC,OAAOR,QAIEC,EAAa,0BAHH,MACR,GAAGI,EAAqB,IAAI,IAAIH,EAAK,eAAe,CAAC,EAAE,QAAQA,EAAK,gBAAgB,MAAMO,EAAS,oBAAoBF,EAAc,IAAI,IAAIL,EAAK,OAAO,GAAG,CAAC,KAEhH,CAACG,GAAsBE,CAAa,CAAC,GAC1F;EAACF;EAAsB;EAAGE;CAAa,CAAC;AAC7C,GAEaG,UAAmE;CAC9E,IAAMX,IAAiCN,EAAkC,GACnEkB,IAAqCR,EAAsC;CAEjF,OAAOH,QACEC,EAAa,yBAA0DF,IAAgC,MAAQG,EAAK,IAAIS,EAAmC,SAAS,CAACA,CAAkC,CAAC,GAC9M,CAACA,GAAoCZ,CAA8B,CAAC;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useOrganizationIdentifierIssuerLinksQuery","useQueryMemo","container","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY"],"sources":["../../../src/dataHooks/useOrganizationIdentifierIssuerLinksQuery/useOrganizationIdentifierIssuerLinksQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { CommonDbOrganizationIdentifierIssuerLink } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\n\nexport const useOrganizationIdentifierIssuerLinksQuery = (): UseQueryResult<CommonDbOrganizationIdentifierIssuerLink[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).organizationIdentifierIssuerLinksGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.IDENTIFIER_ISSUER_LINKS),\n });\n};\n"],"mappings":";;;;;;AAUA,IAAaC,UACJC,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBC,EAAU,QAAQC,CAAsB,CAAC,CAAC,wCAAwC,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CAC/G;CAElB,UAAUD,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcK,EAAiB,uBAAuB;AACxG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useOrganizationsQuery","useQueryMemo","container","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY","useOrganizationMapQuery","organizationsQuery","useMemo","DataHookUtil","item","useOrganizationOptionsQuery","StringUtil","a","b"],"sources":["../../../src/dataHooks/useOrganizationsQuery/useOrganizationsQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport type { CommonDbOrganization } from '@gen-epix/api-commondb';\nimport { StringUtil } from '@gen-epix/ui-core/utils/StringUtil';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\n\nexport const useOrganizationsQuery = (): UseQueryResult<CommonDbOrganization[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).organizationsGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.ORGANIZATIONS),\n });\n};\n\nexport const useOrganizationMapQuery = (): UseMap<CommonDbOrganization> => {\n const organizationsQuery = useOrganizationsQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbOrganization>(organizationsQuery, item => item.id);\n }, [organizationsQuery]);\n};\n\nexport const useOrganizationOptionsQuery = (): UseOptions<string> => {\n const organizationsQuery = useOrganizationsQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbOrganization>(organizationsQuery, item => item.id, item => item.name, [], (a, b) => StringUtil.advancedSortComperator(a.name, b.name));\n }, [organizationsQuery]);\n};\n"],"mappings":";;;;;;;;;AAgBA,IAAaC,UACJC,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBC,EAAU,QAAQC,CAAsB,CAAC,CAAC,oBAAoB,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CAC3F;CAElB,UAAUD,EAAU,QAAQH,CAAkB,CAAC,CAAC,cAAcK,EAAiB,aAAa;AAC9F,CAAC,GAGUC,UAA8D;CACzE,IAAMC,IAAqBN,EAAsB;CAEjD,OAAOO,QACEC,EAAa,qBAA2CF,IAAoB,MAAQG,EAAK,EAAE,GACjG,CAACH,CAAkB,CAAC;AACzB,GAEaI,UAAwD;CACnE,IAAMJ,IAAqBN,EAAsB;CAEjD,OAAOO,QACEC,EAAa,yBAA+CF,IAAoB,MAAQG,EAAK,KAAI,MAAQA,EAAK,MAAM,CAAC,IAAI,GAAG,MAAME,EAAW,uBAAuBC,EAAE,MAAMC,EAAE,IAAI,CAAC,GACzL,CAACP,CAAkB,CAAC;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useQueryMemo","useUsersQuery","container","API_ORGANIZATION_TOKEN","QueryClientService","COMMON_QUERY_KEY","useUsersMapQuery","usersQuery","useMemo","DataHookUtil","item","useUserOptionsQuery","useTranslation","UserUtil","t"],"sources":["../../../src/dataHooks/useUsersQuery/useUsersQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useTranslation } from 'react-i18next';\nimport { useMemo } from 'react';\nimport type { CommonDbUser } from '@gen-epix/api-commondb';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport type {\n UseMap,\n UseOptions,\n} from '../../models/data-hooks.models';\nimport { DataHookUtil } from '../../utils/DataHookUtil';\nimport { useQueryMemo } from '../../hooks/useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { UserUtil } from '../../utils/UserUtil';\n\nexport const useUsersQuery = (): UseQueryResult<CommonDbUser[]> => {\n return useQueryMemo({\n queryFn: async ({ signal }) => {\n const response = await container.resolve(API_ORGANIZATION_TOKEN).usersGetAll(null, null, { signal });\n return response.data;\n },\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USERS),\n });\n};\n\nexport const useUsersMapQuery = (): UseMap<CommonDbUser> => {\n const usersQuery = useUsersQuery();\n\n return useMemo(() => {\n return DataHookUtil.createUseMapDataHook<CommonDbUser>(usersQuery, item => item.id);\n }, [usersQuery]);\n};\n\nexport const useUserOptionsQuery = (): UseOptions<string> => {\n const usersQuery = useUsersQuery();\n const { t } = useTranslation();\n\n return useMemo(() => {\n return DataHookUtil.createUseOptionsDataHook<CommonDbUser>(usersQuery, item => item.id, item => UserUtil.getUserDisplayValue(item, t));\n }, [t, usersQuery]);\n};\n"],"mappings":";;;;;;;;;;AAiBA,IAAaC,UACJD,EAAa;CAClB,SAAS,OAAO,EAAE,iBAET,MADgBE,EAAU,QAAQC,CAAsB,CAAC,CAAC,YAAY,MAAM,MAAM,EAAE,UAAO,CAAC,EAAA,CACnF;CAElB,UAAUD,EAAU,QAAQE,CAAkB,CAAC,CAAC,cAAcC,EAAiB,KAAK;AACtF,CAAC,GAGUC,UAA+C;CAC1D,IAAMC,IAAaN,EAAc;CAEjC,OAAOO,QACEC,EAAa,qBAAmCF,IAAY,MAAQG,EAAK,EAAE,GACjF,CAACH,CAAU,CAAC;AACjB,GAEaI,UAAgD;CAC3D,IAAMJ,IAAaN,EAAc,GAC3B,EAAE,SAAMW,EAAe;CAE7B,OAAOJ,QACEC,EAAa,yBAAuCF,IAAY,MAAQG,EAAK,KAAI,MAAQG,EAAS,oBAAoBH,GAAMI,CAAC,CAAC,GACpI,CAACA,GAAGP,CAAU,CAAC;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["withPermissions","WrappedComponent","useMemo","container","AuthorizationService","options","FallbackComponent","Component","props"],"sources":["../../../src/hoc/withPermissions/withPermissions.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMemo } from 'react';\nimport type { ComponentType } from 'react';\nimport type { CommonDbApiPermission } from '@gen-epix/api-commondb';\n\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\n\nexport interface WithPermissionsOptions<TApiPermission = CommonDbApiPermission> {\n readonly fallback?: ComponentType | null;\n readonly requiredPermissions: TApiPermission[];\n}\n\nexport const withPermissions = <TApiPermission = CommonDbApiPermission, TProps extends object = Record<string, never>>(\n Component: ComponentType<TProps>,\n options: WithPermissionsOptions<TApiPermission>,\n) => {\n const WrappedComponent = (props: TProps) => {\n const authorizationService = useMemo(() => container.resolve(AuthorizationService), []);\n\n if (!authorizationService.doesUserHavePermission(options.requiredPermissions as CommonDbApiPermission[])) {\n if (options.fallback) {\n const FallbackComponent = options.fallback;\n return <FallbackComponent />;\n }\n return null;\n }\n\n return <Component {...props} />;\n };\n\n // Set display name for better debugging\n WrappedComponent.displayName = `withPermissions(${Component.displayName || Component.name})`;\n\n return WrappedComponent;\n};\n"],"mappings":";;;;;AAYA,IAAaA,KACX,GACA,MACG;CACH,IAAMC,KAAoB,MAAkB;EAG1C,IAAI,CAFyBC,QAAcC,EAAU,QAAQC,CAAoB,GAAG,CAAC,CAEhF,CAAA,CAAqB,uBAAuBC,EAAQ,mBAA8C,GAAG;GACxG,IAAIA,EAAQ,UAAU;IACpB,IAAMC,IAAoBD,EAAQ;IAClC,OAAO,kBAACC,GAAD,CAAoB,CAAA;GAC7B;GACA,OAAO;EACT;EAEA,OAAO,kBAACC,GAAD,EAAW,GAAIC,EAAQ,CAAA;CAChC;CAKA,OAFA,EAAiB,cAAc,mBAAmBD,EAAU,eAAeA,EAAU,KAAK,IAEnFN;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useClientCommonConfigContext as e } from "../../context/ClientCommonConfigContext/index.js";
|
|
2
2
|
//#region src/hooks/useConfig/useConfig.ts
|
|
3
3
|
var t = () => e().config;
|
|
4
4
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useConfig","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useConfig","useClientCommonConfigContext"],"sources":["../../../src/hooks/useConfig/useConfig.ts"],"sourcesContent":["import type { ConfigBase } from '../../models/config.models';\nimport { useClientCommonConfigContext } from '../../context/ClientCommonConfigContext';\n\nexport const useConfig = <TConfig extends ConfigBase = ConfigBase>(): TConfig => {\n return useClientCommonConfigContext<TConfig>().config;\n};\n"],"mappings":";;AAGA,IAAaA,UACJC,EAAsC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useCreateMutation","queryClient","container","createMutation","useMutation","queryFn","ObjectUtil","item","resourceQueryKey","oldItems","context","associationQueryKeys","onError","error","variables","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","temporaryId","StringUtil","x","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useCreateMutation/useCreateMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\nimport { StringUtil } from '@gen-epix/ui-core/utils/StringUtil';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextCreate<TData> = { notificationKey?: string; previousData?: TData[]; temporaryId?: string };\n\nexport type UseCreateMutationProps<TData extends GenericData | GenericData[], TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TVariables, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextCreate<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextCreate<TData>) => Promise<void> | void;\n readonly queryFn?: (item: TVariables) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useCreateMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseCreateMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const createMutation = useMutation<TData, Error, TVariables, MutationContextCreate<TData>>({\n mutationFn: async (item) => {\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(item));\n },\n onError: async (error, variables, context) => {\n if (resourceQueryKey) {\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems.filter(item => (item as GenericData)?.id !== context.temporaryId)];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(variables, error), error), 'error');\n },\n onMutate: async (variables) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n if (Array.isArray(previousData)) {\n const temporaryId = StringUtil.createUuid();\n queryClient.setQueryData<TData[]>(resourceQueryKey, (oldItems: TData[]) => {\n return [\n {\n ...variables,\n id: temporaryId,\n },\n ...oldItems,\n ] as TData[];\n });\n return { notificationKey, previousData, temporaryId };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n if (resourceQueryKey && Array.isArray(context?.previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return [\n item,\n ...oldItems.filter(x => x.id !== context.temporaryId),\n ];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => createMutation.mutate, [createMutation.mutate]);\n const isMutating = useMemo(() => createMutation.isPending, [createMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;;;AA0BA,IAAaC,KAAoF,EAC/F,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BAC+C;CAC/C,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,IAAiBC,EAAoE;EACzF,YAAY,OAAO,MACVC,EAAQC,EAAW,wBAAwBC,CAAI,CAAC;EAEzD,SAAS,OAAO,GAAO,GAAW,MAAY;GAa5C,AAZIC,KACFP,EAAY,aAAsBO,IAAmB,MAC9C,MAAM,QAAQC,CAAQ,IAGpB,CAAC,GAAGA,EAAS,QAAO,MAASF,GAAsB,OAAOG,EAAQ,WAAW,CAAC,IAF5ED,CAGV,GAEH,MAAMP,EAAU,QAAQH,CAAkB,CAAC,CAAC,oBAAoBY,CAAoB,GAChFC,KACF,MAAMA,EAAQC,GAAOC,GAAWJ,CAAO,GAEzCR,EAAU,QAAQa,CAAmB,CAAC,CAAC,oBAAoBL,EAAQ,iBAAiBM,EAAiB,6BAA6BC,EAA4BH,GAAWD,CAAK,GAAGA,C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","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useDeleteMutation","queryClient","container","deleteMutation","useMutation","queryFn","item","resourceQueryKey","oldItems","associationQueryKeys","onError","error","context","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","i","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useDeleteMutation/useDeleteMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\n\nexport type MutationContextDelete<TData> = { notificationKey?: string; previousData?: TData[] };\n\nexport type UseDeleteMutationProps<TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage?: (data: TData, error: unknown) => ReactElement | string;\n readonly getProgressNotificationMessage: (data: TData) => ReactElement | string;\n readonly getSuccessNotificationMessage?: (data: TData, context: MutationContextDelete<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, context: MutationContextDelete<TData>) => Promise<void> | void;\n readonly queryFn?: (data: TData) => Promise<unknown>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useDeleteMutation = <TData extends GenericData | GenericData[]>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseDeleteMutationProps<TData>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n\n const deleteMutation = useMutation<unknown, Error, TData, MutationContextDelete<TData>>({\n mutationFn: async (item) => {\n return queryFn(item);\n },\n onError: async (error, item, context) => {\n if (resourceQueryKey) {\n queryClient.setQueryData(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems, item];\n });\n }\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onError) {\n await onError(error, item, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(item, error), error), 'error');\n },\n onMutate: async (item) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(item),\n severity: 'info',\n });\n if (resourceQueryKey) {\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n\n if (Array.isArray(previousData) && !Array.isArray(item)) {\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return oldItems.filter(i => i.id !== item.id);\n });\n return { notificationKey, previousData };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (_data, item, context) => {\n if (associationQueryKeys) {\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n }\n if (onSuccess) {\n await onSuccess(item, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => deleteMutation.mutate, [deleteMutation.mutate]);\n const isMutating = useMemo(() => deleteMutation.isPending, [deleteMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate }), [isMutating, mutate]);\n};\n"],"mappings":";;;;;;;AAwBA,IAAaC,KAAgE,EAC3E,yBACA,gCACA,mCACA,kCACA,YACA,cACA,YACA,0BACmC;CACnC,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aAEpDI,IAAiBC,EAAiE;EACtF,YAAY,OAAO,MACVC,EAAQC,CAAI;EAErB,SAAS,OAAO,GAAO,GAAM,MAAY;GAevC,AAdIC,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rF,OAAOoB,SAAe;EAAE;EAAY;CAAO,IAAI,CAACC,GAAYF,CAAM,CAAC;AACrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","useEditMutation","queryClient","container","previousItemRef","useRef","setPreviousItem","useCallback","item","mutationFn","queryFn","ObjectUtil","variables","editMutation","useMutation","resourceQueryKey","context","oldItems","x","associationQueryKeys","onError","error","NotificationService","NotificationUtil","getErrorNotificationMessage","notificationKey","getProgressNotificationMessage","previousData","intermediateItem","getIntermediateItem","onSuccess","getSuccessNotificationMessage","mutate","useMemo","isMutating"],"sources":["../../../src/hooks/useEditMutation/useEditMutation.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMutation } from '@tanstack/react-query';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { ObjectUtil } from '@gen-epix/ui-core/utils/ObjectUtil';\n\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport type { GenericData } from '../../models/data.models';\nimport { NotificationUtil } from '../../utils/NotificationUtil';\n\nexport type MutationContextEdit<TData> = { item?: TData; notificationKey?: string; previousData?: TData[] };\n\nexport type UseEditMutationProps<TData, TVariables = TData> = {\n readonly associationQueryKeys?: string[][];\n readonly getErrorNotificationMessage: (data: TData, variables: TVariables, error: unknown) => ReactElement | string;\n // Optional function to get an intermediate item to be set in the query cache before the mutation is completed.\n // This is useful for optimistic updates where you want to show a temporary state before the mutation is confirmed.\n // The function receives the variables and the previous item, and should return the intermediate item.\n // Only needed if the variables are different from the previous item.\n readonly getIntermediateItem?: (variables: TVariables, previousItem: TData) => TData;\n readonly getProgressNotificationMessage: (data: TData, variables: TVariables) => ReactElement | string;\n readonly getSuccessNotificationMessage: (data: TData, context: MutationContextEdit<TData>) => ReactElement | string;\n readonly onError?: (error: unknown, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly onSuccess?: (item: TData, variables: TVariables, context: MutationContextEdit<TData>) => Promise<void> | void;\n readonly queryFn?: (variables: TVariables, previousData: TData) => Promise<TData>;\n readonly resourceQueryKey?: string[];\n};\n\nexport const useEditMutation = <TData extends GenericData | GenericData[], TVariables = TData>({\n associationQueryKeys,\n getErrorNotificationMessage,\n getIntermediateItem,\n getProgressNotificationMessage,\n getSuccessNotificationMessage,\n onError,\n onSuccess,\n queryFn,\n resourceQueryKey,\n}: UseEditMutationProps<TData, TVariables>) => {\n const queryClient = container.resolve(QueryClientService).queryClient;\n const previousItemRef = useRef<TData>(undefined);\n\n const setPreviousItem = useCallback((item: TData) => {\n previousItemRef.current = item;\n }, []);\n\n const mutationFn = useCallback(async (variables: TVariables) => {\n return queryFn(ObjectUtil.deepNullifyEmptyStrings(variables), previousItemRef.current);\n }, [previousItemRef, queryFn]);\n\n const editMutation = useMutation<TData, Error, TVariables, MutationContextEdit<TData>>({\n mutationFn,\n onError: async (error, variables, context) => {\n previousItemRef.current = undefined;\n if (resourceQueryKey && Array.isArray(context.previousData)) {\n queryClient.setQueryData(resourceQueryKey, (oldItems: TData[]) => {\n if (!Array.isArray(oldItems)) {\n return oldItems;\n }\n return [...oldItems.filter(x => (x as GenericData).id !== (context.item as GenericData).id), context.item];\n });\n }\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onError) {\n await onError(error, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, NotificationUtil.wrapErrorNotificationMessage(getErrorNotificationMessage(context.item, variables, error), error), 'error');\n },\n onMutate: async (variables) => {\n const notificationKey = container.resolve(NotificationService).showNotification({\n isLoading: true,\n message: getProgressNotificationMessage(previousItemRef.current, variables),\n severity: 'info',\n });\n if (resourceQueryKey) {\n if (!previousItemRef.current) {\n throw new Error('previousItem is not set');\n }\n await queryClient.cancelQueries({ queryKey: resourceQueryKey });\n const previousData = queryClient.getQueryData<TData[]>(resourceQueryKey);\n if (Array.isArray(previousData) && !Array.isArray(variables)) {\n const intermediateItem = getIntermediateItem ? getIntermediateItem(variables, previousItemRef.current) : {\n ...variables,\n id: (previousItemRef.current as GenericData).id,\n } as GenericData;\n queryClient.setQueryData<GenericData[]>(resourceQueryKey, (oldItems) => {\n return [...oldItems.filter(x => x.id !== (previousItemRef.current as GenericData).id), intermediateItem] as GenericData[];\n });\n return { item: previousItemRef.current, notificationKey, previousData };\n }\n }\n return { notificationKey };\n },\n onSuccess: async (item, variables, context) => {\n previousItemRef.current = undefined;\n await container.resolve(QueryClientService).invalidateQueryKeys(associationQueryKeys);\n if (onSuccess) {\n await onSuccess(item, variables, context);\n }\n container.resolve(NotificationService).fulfillNotification(context.notificationKey, getSuccessNotificationMessage(item, context), 'success');\n },\n });\n\n // Note: must be done in useMemo to avoid render loops (useMutation returns a new object every time)\n const mutate = useMemo(() => editMutation.mutate, [editMutation.mutate]);\n const isMutating = useMemo(() => editMutation.isPending, [editMutation.isPending]);\n return useMemo(() => ({ isMutating, mutate, setPreviousItem }), [isMutating, mutate, setPreviousItem]);\n};\n"],"mappings":";;;;;;;;AAiCA,IAAaC,KAAkF,EAC7F,yBACA,gCACA,wBACA,mCACA,kCACA,YACA,cACA,YACA,0BAC6C;CAC7C,IAAMC,IAAcC,EAAU,QAAQH,CAAkB,CAAC,CAAC,aACpDI,IAAkBC,EAAc,KAAA,CAAS,GAEzCC,IAAkBC,GAAa,MAAgB;EACnD,EAAgB,UAAUC;CAC5B,GAAG,CAAC,CAAC,GAECC,IAAaF,EAAY,OAAO,MAC7BG,EAAQC,EAAW,wBAAwBC,CAAS,GAAGR,EAAgB,OAAO,GACpF,CAACA,GAAiBM,CAAO,CAAC,GAEvBG,IAAeC,EAAkE;EACrF;EACA,SAAS,OAAO,GAAO,GAAW,MAAY;GAc5C,AAbA,EAAgB,UAAU,KAAA,GACtBC,KAAoB,MAAM,QAAQC,EAAQ,YAAY,KACxDd,EAAY,aAAaa,IAAmB,MACrC,MAA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CAAC,CAAC,oBAAoBmB,CAAoB,GAChFW,KACF,MAAMA,EAAUtB,GAAMI,GAAWI,CAAO,GAE1Cb,EAAU,QAAQmB,CAAmB,CAAC,CAAC,oBAAoBN,EAAQ,iBAAiBe,EAA8BvB,GAAMQ,CAAO,GAAG,SAAS;EAC7I;CACF,CAAC,GAGKgB,IAASC,QAAcpB,EAAa,QAAQ,CAACA,EAAa,MAAM,CAAC,GACjEqB,IAAaD,QAAcpB,EAAa,WAAW,CAACA,EAAa,SAAS,CAAC;CACjF,OAAOoB,SAAe;EAAE;EAAY;EAAQ;CAAgB,IAAI;EAACC;EAAYF;EAAQ1B;CAAe,CAAC;AACvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["QueryClientService","eventTypes","useItemQuery","container","itemFromCache","setItemFromCache","useState","baseQueryKey","itemId","useQueryResult","useQueryMemo","useQueryOptions","useEffect","removeListener","queryCache","event","list","newValue","item","useMemo"],"sources":["../../../src/hooks/useItemQuery/useItemQuery.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport type {\n QueryCacheNotifyEvent,\n UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport type { GenericData } from '../../models/data.models';\nimport { useQueryMemo } from '../useQueryMemo';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\nexport type UseItemQueryProps<T extends GenericData, TQueryKey extends string = string> = {\n readonly baseQueryKey: TQueryKey;\n readonly itemId: string;\n readonly useQueryOptions: Omit<UseQueryOptions<T>, 'queryKey'>;\n};\n\nconst eventTypes: QueryCacheNotifyEvent['type'][] = ['added', 'removed', 'updated'];\n\nexport const useItemQuery = <T extends GenericData>({\n baseQueryKey,\n itemId,\n useQueryOptions,\n}: UseItemQueryProps<T>) => {\n const { queryCache } = container.resolve(QueryClientService);\n const [itemFromCache, setItemFromCache] = useState<T>(container.resolve(QueryClientService).getItemFromCache<T>(baseQueryKey, itemId));\n\n const useQueryResult = useQueryMemo({\n ...useQueryOptions,\n enabled: !itemFromCache && useQueryOptions.enabled,\n queryKey: container.resolve(QueryClientService).getGenericKey(baseQueryKey, itemId),\n });\n\n useEffect(() => {\n const handleQueryCacheEvent = (event: QueryCacheNotifyEvent) => {\n if (Array.isArray(event.query.queryKey) && event.query.queryKey[0] === baseQueryKey && eventTypes.includes(event.type)) {\n if (event.query.queryKey.length === 1) {\n const list = (event.query.state.data as T[]);\n if (event.type === 'removed') {\n setItemFromCache(undefined);\n return;\n }\n if (!list) {\n return;\n }\n const newValue = list?.find(item => item.id === itemId);\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n } else if (event.query.queryKey.length === 2 && (event.query.state.data as T)?.id === itemId) {\n const newValue = event.query.state.data as T;\n if (JSON.stringify(itemFromCache) !== JSON.stringify(newValue)) {\n setItemFromCache(newValue);\n }\n }\n }\n };\n\n const removeListener = queryCache.subscribe(handleQueryCacheEvent);\n return () => {\n removeListener();\n };\n }, [baseQueryKey, itemId, queryCache, itemFromCache]);\n\n\n const result = useMemo(() => {\n return {\n data: itemFromCache || useQueryResult.data,\n error: itemFromCache ? false : useQueryResult.error,\n isEnabled: itemFromCache ? true : useQueryResult.isEnabled,\n isFetching: itemFromCache ? false : useQueryResult.isFetching,\n isLoading: itemFromCache ? false : useQueryResult.isLoading,\n isPending: itemFromCache ? false : useQueryResult.isPending,\n };\n }, [itemFromCache, useQueryResult.data, useQueryResult.isLoading, useQueryResult.isPending, useQueryResult.isFetching, useQueryResult.isEnabled, useQueryResult.error]);\n\n return result;\n};\n"],"mappings":";;;;;AAqBA,IAAMC,IAA8C;CAAC;CAAS;CAAW;AAAS,GAErEC,KAAuC,EAClD,iBACA,WACA,yBAC0B;CAC1B,IAAM,EAAE,kBAAeC,EAAU,QAAQH,CAAkB,GACrD,CAACI,GAAeC,KAAoBC,EAAYH,EAAU,QAAQH,CAAk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AAWA,EAAe;EAAWA,EAAe;EAAYA,EAAe;EAAWA,EAAe;CAAK,CAE9J;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useUpdateBreadcrumb","update","useCallback","BreadcrumbService","position","title","useEffect"],"sources":["../../../src/hooks/useUpdateBreadcrumb/useUpdateBreadcrumb.ts"],"sourcesContent":["import { container
|
|
1
|
+
{"version":3,"file":"index.js","names":["useUpdateBreadcrumb","update","useCallback","BreadcrumbService","position","title","useEffect"],"sources":["../../../src/hooks/useUpdateBreadcrumb/useUpdateBreadcrumb.ts"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useCallback,\n useEffect,\n} from 'react';\n\nimport { BreadcrumbService } from '../../classes/services/BreadcrumbService';\n\n\nexport const useUpdateBreadcrumb = (position: string) => {\n const update = useCallback((title: string) => {\n container.resolve(BreadcrumbService).update(position, title);\n }, [position]);\n\n useEffect(() => {\n return () => {\n container.resolve(BreadcrumbService).remove(position);\n };\n }, [position]);\n\n return update;\n};\n"],"mappings":";;;;AASA,IAAaA,KAAuB,MAAqB;CACvD,IAAMC,IAASC,GAAa,MAAkB;EAC5C,EAAU,QAAQC,CAAiB,CAAC,CAAC,OAAOC,GAAUC,CAAK;CAC7D,GAAG,CAACD,CAAQ,CAAC;CAQb,OANAE,cACe;EACX,EAAU,QAAQH,CAAiB,CAAC,CAAC,OAAOC,CAAQ;CACtD,GACC,CAACA,CAAQ,CAAC,GAENH;AACT"}
|