@greatapps/common 1.1.429 → 1.1.430
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/components/account/AccountModals.mjs +18 -0
- package/dist/components/account/AccountModals.mjs.map +1 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +129 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +45 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
- package/dist/components/account/DeleteAccountModal.mjs +123 -0
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +42 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/TwoFactorAuthModal.mjs +182 -0
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/constants.mjs +29 -0
- package/dist/components/account/constants.mjs.map +1 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs +91 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs +34 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +80 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs +181 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs +192 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
- package/dist/components/account/sections/MyProfileSection.mjs +317 -0
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
- package/dist/components/account/sections/PreferencesSection.mjs +227 -0
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
- package/dist/components/account/sections/SecuritySection.mjs +31 -0
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
- package/dist/components/embeds/CrispEmbed.mjs +89 -0
- package/dist/components/embeds/CrispEmbed.mjs.map +1 -0
- package/dist/components/embeds/FrillEmbed.mjs +107 -0
- package/dist/components/embeds/FrillEmbed.mjs.map +1 -0
- package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
- package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
- package/dist/components/layouts/AppMobileNavBar.mjs +60 -0
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
- package/dist/components/layouts/AppNavBar.mjs +37 -0
- package/dist/components/layouts/AppNavBar.mjs.map +1 -0
- package/dist/components/layouts/CollapsibleSidebar.mjs +65 -0
- package/dist/components/layouts/CollapsibleSidebar.mjs.map +1 -0
- package/dist/components/layouts/MainLayout.mjs +60 -0
- package/dist/components/layouts/MainLayout.mjs.map +1 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/NavBar.mjs +152 -0
- package/dist/components/layouts/NavBar.mjs.map +1 -0
- package/dist/components/layouts/NavBarItem.mjs +23 -0
- package/dist/components/layouts/NavBarItem.mjs.map +1 -0
- package/dist/components/layouts/NotificationsPopover.mjs +97 -0
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
- package/dist/components/layouts/ProfilePopover.mjs +152 -0
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
- package/dist/components/layouts/SideBarNavigation.mjs +63 -0
- package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs +210 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
- package/dist/components/layouts/WhitelabelCodes.mjs +50 -0
- package/dist/components/layouts/WhitelabelCodes.mjs.map +1 -0
- package/dist/components/modals/BuyCreditsModal.mjs +281 -0
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -0
- package/dist/components/modals/ModalManager.mjs +19 -0
- package/dist/components/modals/ModalManager.mjs.map +1 -0
- package/dist/components/modals/Modals.mjs +20 -0
- package/dist/components/modals/Modals.mjs.map +1 -0
- package/dist/components/modals/PaidPlanRequiredModal.mjs +46 -0
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -0
- package/dist/components/modals/cards/AddCardModal.mjs +215 -0
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -0
- package/dist/components/modals/cards/CardFormFields.mjs +268 -0
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -0
- package/dist/components/navigation/AppNavigation.mjs +33 -0
- package/dist/components/navigation/AppNavigation.mjs.map +1 -0
- package/dist/components/navigation/AppNavigationContext.mjs +13 -0
- package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +52 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
- package/dist/components/navigation/NavItem.mjs +41 -0
- package/dist/components/navigation/NavItem.mjs.map +1 -0
- package/dist/components/navigation/NavItemsContext.mjs +16 -0
- package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs +147 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
- package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
- package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MdShell.mjs +11 -0
- package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MobileShell.mjs +27 -0
- package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs +61 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +35 -0
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +33 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +145 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
- package/dist/components/navigation/types.mjs +1 -0
- package/dist/components/navigation/types.mjs.map +1 -0
- package/dist/components/pages/NotFoundPage.mjs +47 -0
- package/dist/components/pages/NotFoundPage.mjs.map +1 -0
- package/dist/components/pages/notifications/Notifications.mjs +159 -0
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
- package/dist/components/ui/buttons/Button.mjs +52 -0
- package/dist/components/ui/buttons/Button.mjs.map +1 -0
- package/dist/components/ui/buttons/CancelButton.mjs +17 -0
- package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
- package/dist/components/ui/buttons/CopyButton.mjs +42 -0
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
- package/dist/components/ui/data-display/Accordion.mjs +76 -0
- package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
- package/dist/components/ui/data-display/Badge.mjs +42 -0
- package/dist/components/ui/data-display/Badge.mjs.map +1 -0
- package/dist/components/ui/data-display/Card.mjs +92 -0
- package/dist/components/ui/data-display/Card.mjs.map +1 -0
- package/dist/components/ui/data-display/CardBrandIcons.mjs +484 -0
- package/dist/components/ui/data-display/CardBrandIcons.mjs.map +1 -0
- package/dist/components/ui/data-display/CardItem.mjs +67 -0
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -0
- package/dist/components/ui/data-display/Pagination.mjs +118 -0
- package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +161 -0
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -0
- package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
- package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
- package/dist/components/ui/data-display/Separator.mjs +28 -0
- package/dist/components/ui/data-display/Separator.mjs.map +1 -0
- package/dist/components/ui/data-display/Table.mjs +116 -0
- package/dist/components/ui/data-display/Table.mjs.map +1 -0
- package/dist/components/ui/data-display/Tabs.mjs +69 -0
- package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
- package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
- package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
- package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +63 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
- package/dist/components/ui/feedback/Progress.mjs +37 -0
- package/dist/components/ui/feedback/Progress.mjs.map +1 -0
- package/dist/components/ui/feedback/Skeleton.mjs +9 -0
- package/dist/components/ui/feedback/Skeleton.mjs.map +1 -0
- package/dist/components/ui/feedback/Toast.mjs +77 -0
- package/dist/components/ui/feedback/Toast.mjs.map +1 -0
- package/dist/components/ui/form/Calendar.mjs +204 -0
- package/dist/components/ui/form/Calendar.mjs.map +1 -0
- package/dist/components/ui/form/Checkbox.mjs +33 -0
- package/dist/components/ui/form/Checkbox.mjs.map +1 -0
- package/dist/components/ui/form/ComboboxField.mjs +130 -0
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
- package/dist/components/ui/form/DatePicker.mjs +82 -0
- package/dist/components/ui/form/DatePicker.mjs.map +1 -0
- package/dist/components/ui/form/DateRangePicker.mjs +92 -0
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
- package/dist/components/ui/form/FormField.mjs +103 -0
- package/dist/components/ui/form/FormField.mjs.map +1 -0
- package/dist/components/ui/form/Input.mjs +21 -0
- package/dist/components/ui/form/Input.mjs.map +1 -0
- package/dist/components/ui/form/InputOtp.mjs +70 -0
- package/dist/components/ui/form/InputOtp.mjs.map +1 -0
- package/dist/components/ui/form/PhoneInput.mjs +176 -0
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
- package/dist/components/ui/form/RadioGroup.mjs +37 -0
- package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
- package/dist/components/ui/form/Select.mjs +179 -0
- package/dist/components/ui/form/Select.mjs.map +1 -0
- package/dist/components/ui/form/SelectField.mjs +80 -0
- package/dist/components/ui/form/SelectField.mjs.map +1 -0
- package/dist/components/ui/form/Switch.mjs +33 -0
- package/dist/components/ui/form/Switch.mjs.map +1 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
- package/dist/components/ui/form/TextAreaField.mjs +56 -0
- package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
- package/dist/components/ui/form/Textarea.mjs +20 -0
- package/dist/components/ui/form/Textarea.mjs.map +1 -0
- package/dist/components/ui/overlay/Command.mjs +178 -0
- package/dist/components/ui/overlay/Command.mjs.map +1 -0
- package/dist/components/ui/overlay/Dialog.mjs +142 -0
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
- package/dist/components/ui/overlay/Popover.mjs +46 -0
- package/dist/components/ui/overlay/Popover.mjs.map +1 -0
- package/dist/components/ui/overlay/Sheet.mjs +149 -0
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
- package/dist/components/ui/overlay/Tooltip.mjs +57 -0
- package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
- package/dist/enums/AccountSectionType.mjs +11 -0
- package/dist/enums/AccountSectionType.mjs.map +1 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
- package/dist/hooks/useCountdownTimer.mjs +29 -0
- package/dist/hooks/useCountdownTimer.mjs.map +1 -0
- package/dist/hooks/useDebounce.mjs +19 -0
- package/dist/hooks/useDebounce.mjs.map +1 -0
- package/dist/hooks/useDebounceState.mjs +12 -0
- package/dist/hooks/useDebounceState.mjs.map +1 -0
- package/dist/hooks/useDebouncedEffect.mjs +44 -0
- package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
- package/dist/hooks/useIsMobile.mjs +18 -0
- package/dist/hooks/useIsMobile.mjs.map +1 -0
- package/dist/hooks/usePasswordVisibility.mjs +13 -0
- package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
- package/dist/index.mjs +528 -0
- package/dist/index.mjs.map +1 -0
- package/dist/infra/api/client.mjs +162 -0
- package/dist/infra/api/client.mjs.map +1 -0
- package/dist/infra/api/types.mjs +31 -0
- package/dist/infra/api/types.mjs.map +1 -0
- package/dist/infra/utils/client-info.mjs +27 -0
- package/dist/infra/utils/client-info.mjs.map +1 -0
- package/dist/infra/utils/clsx.mjs +9 -0
- package/dist/infra/utils/clsx.mjs.map +1 -0
- package/dist/infra/utils/date.mjs +11 -0
- package/dist/infra/utils/date.mjs.map +1 -0
- package/dist/infra/utils/params.mjs +21 -0
- package/dist/infra/utils/params.mjs.map +1 -0
- package/dist/infra/utils/parser.mjs +24 -0
- package/dist/infra/utils/parser.mjs.map +1 -0
- package/dist/infra/utils/percentage.mjs +20 -0
- package/dist/infra/utils/percentage.mjs.map +1 -0
- package/dist/middleware.mjs +10 -0
- package/dist/middleware.mjs.map +1 -0
- package/dist/middlewares/chain.mjs +37 -0
- package/dist/middlewares/chain.mjs.map +1 -0
- package/dist/middlewares/create-auth-middleware.mjs +32 -0
- package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
- package/dist/middlewares/types.mjs +11 -0
- package/dist/middlewares/types.mjs.map +1 -0
- package/dist/modules/accounts/actions/account-management.action.mjs +98 -0
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useViaCep.mjs +19 -0
- package/dist/modules/accounts/hooks/useViaCep.mjs.map +1 -0
- package/dist/modules/accounts/services/account.service.mjs +182 -0
- package/dist/modules/accounts/services/account.service.mjs.map +1 -0
- package/dist/modules/accounts/services/currency.service.mjs +24 -0
- package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
- package/dist/modules/accounts/services/timezone.service.mjs +65 -0
- package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
- package/dist/modules/accounts/services/two-factor.service.mjs +78 -0
- package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
- package/dist/modules/accounts/types.mjs +1 -0
- package/dist/modules/accounts/types.mjs.map +1 -0
- package/dist/modules/auth/actions/login.action.mjs +14 -0
- package/dist/modules/auth/actions/login.action.mjs.map +1 -0
- package/dist/modules/auth/actions/logout.action.mjs +14 -0
- package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
- package/dist/modules/auth/actions/register.action.mjs +14 -0
- package/dist/modules/auth/actions/register.action.mjs.map +1 -0
- package/dist/modules/auth/actions/validate-session.action.mjs +48 -0
- package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
- package/dist/modules/auth/hooks/login.hook.mjs +13 -0
- package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
- package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/register.hook.mjs +13 -0
- package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/useManagementPermissions.mjs +41 -0
- package/dist/modules/auth/hooks/useManagementPermissions.mjs.map +1 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
- package/dist/modules/auth/schema.mjs +1 -0
- package/dist/modules/auth/schema.mjs.map +1 -0
- package/dist/modules/auth/services/auth.service.mjs +341 -0
- package/dist/modules/auth/services/auth.service.mjs.map +1 -0
- package/dist/modules/auth/types/management-permission.type.mjs +1 -0
- package/dist/modules/auth/types/management-permission.type.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-management-permission.mjs +42 -0
- package/dist/modules/auth/utils/assert-management-permission.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-management-subscription.mjs +33 -0
- package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-paid-subscription.mjs +40 -0
- package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -0
- package/dist/modules/auth/utils/assert-subscription-addon.mjs +35 -0
- package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -0
- package/dist/modules/auth/utils/build-wl-override.mjs +27 -0
- package/dist/modules/auth/utils/build-wl-override.mjs.map +1 -0
- package/dist/modules/auth/utils/get-user-context.mjs +25 -0
- package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
- package/dist/modules/cards/actions/create-card.action.mjs +10 -0
- package/dist/modules/cards/actions/create-card.action.mjs.map +1 -0
- package/dist/modules/cards/actions/list-cards.action.mjs +10 -0
- package/dist/modules/cards/actions/list-cards.action.mjs.map +1 -0
- package/dist/modules/cards/hooks/cards.hook.mjs +16 -0
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/create-card.hook.mjs +18 -0
- package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -0
- package/dist/modules/cards/services/cards.service.mjs +44 -0
- package/dist/modules/cards/services/cards.service.mjs.map +1 -0
- package/dist/modules/cards/types.mjs +27 -0
- package/dist/modules/cards/types.mjs.map +1 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
- package/dist/modules/ia-credits/types.mjs +25 -0
- package/dist/modules/ia-credits/types.mjs.map +1 -0
- package/dist/modules/plans/actions/find-plan-by-id.action.mjs +10 -0
- package/dist/modules/plans/actions/find-plan-by-id.action.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs +13 -0
- package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +15 -0
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -0
- package/dist/modules/plans/services/plans.service.mjs +34 -0
- package/dist/modules/plans/services/plans.service.mjs.map +1 -0
- package/dist/modules/plans/types/plan.type.mjs +20 -0
- package/dist/modules/plans/types/plan.type.mjs.map +1 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-all-account-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-all-account-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/hooks/add-project-user.hook.mjs +61 -0
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +35 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs +61 -0
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -0
- package/dist/modules/projects/services/project-users.service.mjs +96 -0
- package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
- package/dist/modules/projects/types.mjs +23 -0
- package/dist/modules/projects/types.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +12 -0
- package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs +24 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs +5 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs +13 -0
- package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +17 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +17 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +22 -0
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs +37 -0
- package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs.map +1 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +75 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
- package/dist/modules/subscriptions/types/billing-period.type.mjs +1 -0
- package/dist/modules/subscriptions/types/billing-period.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +72 -0
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs +57 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/build-plan-extras.mjs +37 -0
- package/dist/modules/subscriptions/utils/build-plan-extras.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs +10 -0
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs +48 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs +14 -0
- package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs.map +1 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
- package/dist/modules/users/action/list-messages.action.mjs +13 -0
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +57 -0
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
- package/dist/modules/users/schema/messages.schema.mjs +21 -0
- package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
- package/dist/modules/users/schema.mjs +11 -0
- package/dist/modules/users/schema.mjs.map +1 -0
- package/dist/modules/users/services/messages.service.mjs +35 -0
- package/dist/modules/users/services/messages.service.mjs.map +1 -0
- package/dist/modules/users/services/user.service.mjs +52 -0
- package/dist/modules/users/services/user.service.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs +19 -0
- package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs.map +1 -0
- package/dist/modules/whitelabel/schema.mjs +1 -0
- package/dist/modules/whitelabel/schema.mjs.map +1 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs +146 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
- package/dist/modules/whitelabel/utils/normalize-hostname.mjs +35 -0
- package/dist/modules/whitelabel/utils/normalize-hostname.mjs.map +1 -0
- package/dist/providers/auth.provider.mjs +114 -0
- package/dist/providers/auth.provider.mjs.map +1 -0
- package/dist/providers/query.provider.mjs +99 -0
- package/dist/providers/query.provider.mjs.map +1 -0
- package/dist/providers/whitelabel.provider.mjs +42 -0
- package/dist/providers/whitelabel.provider.mjs.map +1 -0
- package/dist/server.mjs +111 -0
- package/dist/server.mjs.map +1 -0
- package/dist/store/useAccountModals.mjs +18 -0
- package/dist/store/useAccountModals.mjs.map +1 -0
- package/dist/store/useBuyCreditsModal.mjs +16 -0
- package/dist/store/useBuyCreditsModal.mjs.map +1 -0
- package/dist/store/useDesktopSidebarStore.mjs +39 -0
- package/dist/store/useDesktopSidebarStore.mjs.map +1 -0
- package/dist/store/useMdSidebarStore.mjs +28 -0
- package/dist/store/useMdSidebarStore.mjs.map +1 -0
- package/dist/store/useMobileNavbarSheet.mjs +14 -0
- package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
- package/dist/store/useModalManager.mjs +75 -0
- package/dist/store/useModalManager.mjs.map +1 -0
- package/dist/store/usePaidPlanRequiredModal.mjs +14 -0
- package/dist/store/usePaidPlanRequiredModal.mjs.map +1 -0
- package/dist/utils/browser/clipboard.mjs +36 -0
- package/dist/utils/browser/clipboard.mjs.map +1 -0
- package/dist/utils/constants/br-states.mjs +33 -0
- package/dist/utils/constants/br-states.mjs.map +1 -0
- package/dist/utils/countries.mjs +219 -0
- package/dist/utils/countries.mjs.map +1 -0
- package/dist/utils/file/index.mjs +9 -0
- package/dist/utils/file/index.mjs.map +1 -0
- package/dist/utils/format/masks.mjs +67 -0
- package/dist/utils/format/masks.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +12 -0
- package/dist/utils/intl/locales.mjs.map +1 -0
- package/dist/utils/safeServerAction.mjs +16 -0
- package/dist/utils/safeServerAction.mjs.map +1 -0
- package/dist/utils/validators/account.mjs +27 -0
- package/dist/utils/validators/account.mjs.map +1 -0
- package/dist/utils/validators/common.mjs +47 -0
- package/dist/utils/validators/common.mjs.map +1 -0
- package/dist/utils/withAction.mjs +13 -0
- package/dist/utils/withAction.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
const IaCreditOperationSchema = z.object({
|
|
3
|
+
id: z.union([z.number(), z.string()]),
|
|
4
|
+
deleted: z.number(),
|
|
5
|
+
datetime_add: z.coerce.date().nullable(),
|
|
6
|
+
id_wl: z.number(),
|
|
7
|
+
id_subscription: z.union([z.number(), z.string()]),
|
|
8
|
+
id_addon: z.number(),
|
|
9
|
+
operation: z.string(),
|
|
10
|
+
// 'add' | 'subtract'
|
|
11
|
+
operation_value: z.union([z.number(), z.string()]).transform((v) => Number(v)),
|
|
12
|
+
balance_after_operation: z.union([z.number(), z.string()]).optional(),
|
|
13
|
+
balance_before_operation: z.union([z.number(), z.string()]).optional(),
|
|
14
|
+
operation_ref: z.string().nullable().optional(),
|
|
15
|
+
operation_origin: z.string().nullable().optional(),
|
|
16
|
+
expiration_time: z.string().nullable(),
|
|
17
|
+
has_expired: z.boolean(),
|
|
18
|
+
consumed_from_add_id: z.union([z.number(), z.string()]).nullable(),
|
|
19
|
+
id_user_add: z.union([z.number(), z.string()]).nullable(),
|
|
20
|
+
user_name: z.string().nullable().optional()
|
|
21
|
+
}).passthrough();
|
|
22
|
+
export {
|
|
23
|
+
IaCreditOperationSchema
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/ia-credits/types.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const IaCreditOperationSchema = z\r\n .object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_add: z.coerce.date().nullable(),\r\n id_wl: z.number(),\r\n id_subscription: z.union([z.number(), z.string()]),\r\n id_addon: z.number(),\r\n operation: z.string(), // 'add' | 'subtract'\r\n operation_value: z.union([z.number(), z.string()]).transform((v) => Number(v)),\r\n balance_after_operation: z.union([z.number(), z.string()]).optional(),\r\n balance_before_operation: z.union([z.number(), z.string()]).optional(),\r\n operation_ref: z.string().nullable().optional(),\r\n operation_origin: z.string().nullable().optional(),\r\n expiration_time: z.string().nullable(),\r\n has_expired: z.boolean(),\r\n consumed_from_add_id: z.union([z.number(), z.string()]).nullable(),\r\n id_user_add: z.union([z.number(), z.string()]).nullable(),\r\n user_name: z.string().nullable().optional(),\r\n })\r\n .passthrough();\r\n\r\nexport type IaCreditOperation = z.infer<typeof IaCreditOperationSchema>;\r\n\r\nexport type IaCreditsSummary = {\r\n totalCredits: number;\r\n usedCredits: number;\r\n availableCredits: number;\r\n nextExpiringCredits: number | null;\r\n nextExpirationInDays: number | null;\r\n};\r\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,0BAA0B,EACpC,OAAO;AAAA,EACN,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,SAAS,EAAE,OAAO;AAAA,EAClB,cAAc,EAAE,OAAO,KAAK,EAAE,SAAS;AAAA,EACvC,OAAO,EAAE,OAAO;AAAA,EAChB,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACjD,UAAU,EAAE,OAAO;AAAA,EACnB,WAAW,EAAE,OAAO;AAAA;AAAA,EACpB,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA,EAC7E,yBAAyB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACpE,0BAA0B,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACrE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAC9C,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACjD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,aAAa,EAAE,QAAQ;AAAA,EACvB,sBAAsB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACjE,aAAa,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACxD,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAC5C,CAAC,EACA,YAAY;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { plansService } from "../services/plans.service";
|
|
4
|
+
async function findPlanByIdAction(idPlan) {
|
|
5
|
+
return safeServerAction(() => plansService.findById(idPlan));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
findPlanByIdAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=find-plan-by-id.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/actions/find-plan-by-id.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { plansService } from '../services/plans.service';\n\nexport async function findPlanByIdAction(idPlan: number | string) {\n return safeServerAction(() => plansService.findById(idPlan));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,mBAAmB,QAAyB;AAChE,SAAO,iBAAiB,MAAM,aAAa,SAAS,MAAM,CAAC;AAC7D;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useActiveSubscription } from "../../subscriptions/hooks/find-active-subscription.hook";
|
|
3
|
+
function useHasPlanAddon(addonId) {
|
|
4
|
+
const { data: subscriptionData, isLoading: isLoadingSubscription } = useActiveSubscription();
|
|
5
|
+
const activeSubscription = subscriptionData?.data?.[0] ?? null;
|
|
6
|
+
const hasAddon = !!activeSubscription?.items?.find((i) => i.id_addon === addonId);
|
|
7
|
+
const isLoading = isLoadingSubscription;
|
|
8
|
+
return { hasAddon, isLoading };
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
useHasPlanAddon
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-has-plan-addon.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-has-plan-addon.hook.ts"],"sourcesContent":["'use client';\n\nimport type { AddonKindEnum } from '../../subscriptions/constants/addons.constants';\nimport { useActiveSubscription } from '../../subscriptions/hooks/find-active-subscription.hook';\n\nexport function useHasPlanAddon(addonId: AddonKindEnum) {\n const { data: subscriptionData, isLoading: isLoadingSubscription } = useActiveSubscription();\n const activeSubscription = subscriptionData?.data?.[0] ?? null;\n\n const hasAddon = !!activeSubscription?.items?.find((i) => i.id_addon === addonId);\n const isLoading = isLoadingSubscription;\n\n return { hasAddon, isLoading };\n}\n"],"mappings":";AAGA,SAAS,6BAA6B;AAE/B,SAAS,gBAAgB,SAAwB;AACtD,QAAM,EAAE,MAAM,kBAAkB,WAAW,sBAAsB,IAAI,sBAAsB;AAC3F,QAAM,qBAAqB,kBAAkB,OAAO,CAAC,KAAK;AAE1D,QAAM,WAAW,CAAC,CAAC,oBAAoB,OAAO,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO;AAChF,QAAM,YAAY;AAElB,SAAO,EAAE,UAAU,UAAU;AAC/B;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { findPlanByIdAction } from "../actions/find-plan-by-id.action";
|
|
5
|
+
function usePlanById(idPlan) {
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: ["plan", idPlan],
|
|
8
|
+
queryFn: withAction(() => findPlanByIdAction(idPlan)),
|
|
9
|
+
enabled: !!idPlan
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
usePlanById
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-plan-by-id.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-plan-by-id.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { findPlanByIdAction } from '../actions/find-plan-by-id.action';\n\nexport function usePlanById(idPlan: number | string | undefined) {\n return useQuery({\n queryKey: ['plan', idPlan],\n queryFn: withAction(() => findPlanByIdAction(idPlan!)),\n enabled: !!idPlan,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAE5B,SAAS,YAAY,QAAqC;AAC/D,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,QAAQ,MAAM;AAAA,IACzB,SAAS,WAAW,MAAM,mBAAmB,MAAO,CAAC;AAAA,IACrD,SAAS,CAAC,CAAC;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { api } from "../../../infra/api/client";
|
|
3
|
+
import { ApiError } from "../../../infra/api/types";
|
|
4
|
+
import { PlanSchema } from "../types/plan.type";
|
|
5
|
+
class PlansService {
|
|
6
|
+
async findById(idPlan) {
|
|
7
|
+
const response = await api.apps.get(
|
|
8
|
+
`/plans/${idPlan}?type=client`
|
|
9
|
+
);
|
|
10
|
+
if (response.status === 0) {
|
|
11
|
+
throw new ApiError(
|
|
12
|
+
response.message || "Erro ao buscar plano",
|
|
13
|
+
"FIND_PLAN_FAILED",
|
|
14
|
+
400
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (!response.data?.length) {
|
|
18
|
+
throw new ApiError(
|
|
19
|
+
"Plano n\xE3o encontrado",
|
|
20
|
+
"PLAN_NOT_FOUND",
|
|
21
|
+
404
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
data: PlanSchema.parse(response.data[0])
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const plansService = new PlansService();
|
|
31
|
+
export {
|
|
32
|
+
plansService
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=plans.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/services/plans.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiPaginatedActionResult, SuccessResult } from '../../../infra/api/types';\nimport { Plan, PlanSchema } from '../types/plan.type';\n\nclass PlansService {\n async findById(idPlan: number | string): Promise<SuccessResult<Plan>> {\n const response = await api.apps.get<ApiPaginatedActionResult<Plan>>(\n `/plans/${idPlan}?type=client`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao buscar plano',\n 'FIND_PLAN_FAILED',\n 400\n );\n }\n\n if (!response.data?.length) {\n throw new ApiError(\n 'Plano não encontrado',\n 'PLAN_NOT_FOUND',\n 404\n );\n }\n\n return {\n success: true,\n data: PlanSchema.parse(response.data[0]),\n };\n }\n}\n\nexport const plansService = new PlansService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAyD;AAClE,SAAe,kBAAkB;AAEjC,MAAM,aAAa;AAAA,EACjB,MAAM,SAAS,QAAuD;AACpE,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,UAAU,MAAM;AAAA,IAClB;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,SAAS,MAAM,QAAQ;AAC1B,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM,WAAW,MAAM,SAAS,KAAK,CAAC,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,MAAM,eAAe,IAAI,aAAa;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
const PlanItemSchema = z.object({
|
|
3
|
+
id_addon: z.number(),
|
|
4
|
+
quantity: z.number(),
|
|
5
|
+
value: z.number()
|
|
6
|
+
});
|
|
7
|
+
const PlanSchema = z.object({
|
|
8
|
+
id: z.number(),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
value: z.number().default(0),
|
|
11
|
+
type: z.string().optional(),
|
|
12
|
+
discount_semester: z.number().default(0),
|
|
13
|
+
discount_annual: z.number().default(0),
|
|
14
|
+
items: z.array(PlanItemSchema).optional().default([])
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
PlanItemSchema,
|
|
18
|
+
PlanSchema
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=plan.type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/types/plan.type.ts"],"sourcesContent":["import z from 'zod';\n\nexport const PlanItemSchema = z.object({\n id_addon: z.number(),\n quantity: z.number(),\n value: z.number(),\n});\n\nexport type PlanItem = z.infer<typeof PlanItemSchema>;\n\nexport const PlanSchema = z.object({\n id: z.number(),\n name: z.string(),\n value: z.number().default(0),\n type: z.string().optional(),\n discount_semester: z.number().default(0),\n discount_annual: z.number().default(0),\n items: z.array(PlanItemSchema).optional().default([]),\n});\n\nexport type Plan = z.infer<typeof PlanSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,UAAU,EAAE,OAAO;AAAA,EACnB,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO;AAClB,CAAC;AAIM,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,OAAO;AAAA,EACb,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EAC3B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,mBAAmB,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EACvC,iBAAiB,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EACrC,OAAO,EAAE,MAAM,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
+
async function addProjectUserAction(params) {
|
|
5
|
+
return safeServerAction(() => projectUsersService.addToProject(params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
addProjectUserAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=add-project-user.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/add-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function addProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.addToProject(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,qBAAqB,QAAqC;AAC9E,SAAO,iBAAiB,MAAM,oBAAoB,aAAa,MAAM,CAAC;AACxE;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
+
async function listAllAccountUsersAction(params = {}) {
|
|
5
|
+
return safeServerAction(() => projectUsersService.listAllAccountUsers(params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
listAllAccountUsersAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=list-all-account-users.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/list-all-account-users.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { ListUsersParams } from '../types';\n\nexport async function listAllAccountUsersAction(params: ListUsersParams = {}) {\n return safeServerAction(() => projectUsersService.listAllAccountUsers(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,0BAA0B,SAA0B,CAAC,GAAG;AAC5E,SAAO,iBAAiB,MAAM,oBAAoB,oBAAoB,MAAM,CAAC;AAC/E;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
+
async function listAvailableUsersAction(projectId, params = {}) {
|
|
5
|
+
return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
listAvailableUsersAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=list-available-users.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/list-available-users.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { ListUsersParams } from '../types';\n\nexport async function listAvailableUsersAction(projectId: number, params: ListUsersParams = {}) {\n return safeServerAction(() => projectUsersService.listNotInProject(projectId, params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,yBAAyB,WAAmB,SAA0B,CAAC,GAAG;AAC9F,SAAO,iBAAiB,MAAM,oBAAoB,iBAAiB,WAAW,MAAM,CAAC;AACvF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
+
async function listProjectUsersAction(projectId, params = {}) {
|
|
5
|
+
return safeServerAction(() => projectUsersService.listInProject(projectId, params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
listProjectUsersAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=list-project-users.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/list-project-users.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { ListUsersParams } from '../types';\n\nexport async function listProjectUsersAction(projectId: number, params: ListUsersParams = {}) {\n return safeServerAction(() => projectUsersService.listInProject(projectId, params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,uBAAuB,WAAmB,SAA0B,CAAC,GAAG;AAC5F,SAAO,iBAAiB,MAAM,oBAAoB,cAAc,WAAW,MAAM,CAAC;AACpF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectUsersService } from "../services/project-users.service";
|
|
4
|
+
async function removeProjectUserAction(params) {
|
|
5
|
+
return safeServerAction(() => projectUsersService.removeFromProject(params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
removeProjectUserAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=remove-project-user.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/remove-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function removeProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.removeFromProject(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,wBAAwB,QAAqC;AACjF,SAAO,iBAAiB,MAAM,oBAAoB,kBAAkB,MAAM,CAAC;AAC7E;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { addProjectUserAction } from "../actions/add-project-user.action";
|
|
4
|
+
import { LIST_PROJECT_USERS_BASE_KEY } from "./list-project-users.hook";
|
|
5
|
+
import { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from "./list-all-account-users.hook";
|
|
6
|
+
function useAddProjectUser(projectId) {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
return useMutation({
|
|
9
|
+
mutationFn: (userId) => addProjectUserAction({ projectId, users: [userId] }),
|
|
10
|
+
onMutate: async (userId) => {
|
|
11
|
+
await queryClient.cancelQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });
|
|
12
|
+
await queryClient.cancelQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });
|
|
13
|
+
const prevAccountUsers = queryClient.getQueriesData({
|
|
14
|
+
queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY()
|
|
15
|
+
});
|
|
16
|
+
const prevProjectUsers = queryClient.getQueriesData({
|
|
17
|
+
queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId)
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueriesData(
|
|
20
|
+
{ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(), exact: false },
|
|
21
|
+
(old) => {
|
|
22
|
+
if (!old) return old;
|
|
23
|
+
return {
|
|
24
|
+
...old,
|
|
25
|
+
pages: old.pages.map((page) => ({
|
|
26
|
+
...page,
|
|
27
|
+
data: page.data.map(
|
|
28
|
+
(u) => u.id === userId ? { ...u, in_project: true } : u
|
|
29
|
+
)
|
|
30
|
+
}))
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
queryClient.setQueriesData(
|
|
35
|
+
{ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId), exact: false },
|
|
36
|
+
(old) => {
|
|
37
|
+
if (!old?.pages.length) return old;
|
|
38
|
+
return {
|
|
39
|
+
...old,
|
|
40
|
+
pages: old.pages.map(
|
|
41
|
+
(page, i) => i === 0 ? { ...page, total: page.total + 1 } : page
|
|
42
|
+
)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
return { prevAccountUsers, prevProjectUsers };
|
|
47
|
+
},
|
|
48
|
+
onError: (_err, _userId, ctx) => {
|
|
49
|
+
ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
50
|
+
ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
51
|
+
},
|
|
52
|
+
onSettled: () => {
|
|
53
|
+
queryClient.invalidateQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
useAddProjectUser
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=add-project-user.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/add-project-user.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQueryClient, useMutation, InfiniteData } from '@tanstack/react-query';\nimport { addProjectUserAction } from '../actions/add-project-user.action';\nimport { LIST_PROJECT_USERS_BASE_KEY } from './list-project-users.hook';\nimport { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from './list-all-account-users.hook';\nimport type { UsersPage, AccountUser, ProjectUser } from '../types';\n\nexport function useAddProjectUser(projectId: number) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (userId: number) =>\n addProjectUserAction({ projectId, users: [userId] }),\n\n onMutate: async (userId) => {\n await queryClient.cancelQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });\n await queryClient.cancelQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });\n\n const prevAccountUsers = queryClient.getQueriesData<InfiniteData<UsersPage<AccountUser>>>({\n queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(),\n });\n const prevProjectUsers = queryClient.getQueriesData<InfiniteData<UsersPage<ProjectUser>>>({\n queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId),\n });\n\n queryClient.setQueriesData<InfiniteData<UsersPage<AccountUser>>>(\n { queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(), exact: false },\n (old) => {\n if (!old) return old;\n return {\n ...old,\n pages: old.pages.map((page) => ({\n ...page,\n data: page.data.map((u) =>\n u.id === userId ? { ...u, in_project: true } : u\n ),\n })),\n };\n }\n );\n\n queryClient.setQueriesData<InfiniteData<UsersPage<ProjectUser>>>(\n { queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId), exact: false },\n (old) => {\n if (!old?.pages.length) return old;\n return {\n ...old,\n pages: old.pages.map((page, i) =>\n i === 0 ? { ...page, total: page.total + 1 } : page\n ),\n };\n }\n );\n\n return { prevAccountUsers, prevProjectUsers };\n },\n\n onError: (_err, _userId, ctx) => {\n ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n },\n\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });\n queryClient.invalidateQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB,mBAAiC;AAC1D,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,uCAAuC;AAGzC,SAAS,kBAAkB,WAAmB;AACnD,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,WACX,qBAAqB,EAAE,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC;AAAA,IAErD,UAAU,OAAO,WAAW;AAC1B,YAAM,YAAY,cAAc,EAAE,UAAU,gCAAgC,EAAE,CAAC;AAC/E,YAAM,YAAY,cAAc,EAAE,UAAU,4BAA4B,SAAS,EAAE,CAAC;AAEpF,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU,gCAAgC;AAAA,MAC5C,CAAC;AACD,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU,4BAA4B,SAAS;AAAA,MACjD,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,gCAAgC,GAAG,OAAO,MAAM;AAAA,QAC5D,CAAC,QAAQ;AACP,cAAI,CAAC,IAAK,QAAO;AACjB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,OAAO,IAAI,MAAM,IAAI,CAAC,UAAU;AAAA,cAC9B,GAAG;AAAA,cACH,MAAM,KAAK,KAAK;AAAA,gBAAI,CAAC,MACnB,EAAE,OAAO,SAAS,EAAE,GAAG,GAAG,YAAY,KAAK,IAAI;AAAA,cACjD;AAAA,YACF,EAAE;AAAA,UACJ;AAAA,QACF;AAAA,MACF;AAEA,kBAAY;AAAA,QACV,EAAE,UAAU,4BAA4B,SAAS,GAAG,OAAO,MAAM;AAAA,QACjE,CAAC,QAAQ;AACP,cAAI,CAAC,KAAK,MAAM,OAAQ,QAAO;AAC/B,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,OAAO,IAAI,MAAM;AAAA,cAAI,CAAC,MAAM,MAC1B,MAAM,IAAI,EAAE,GAAG,MAAM,OAAO,KAAK,QAAQ,EAAE,IAAI;AAAA,YACjD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO,EAAE,kBAAkB,iBAAiB;AAAA,IAC9C;AAAA,IAEA,SAAS,CAAC,MAAM,SAAS,QAAQ;AAC/B,WAAK,iBAAiB,QAAQ,CAAC,CAAC,KAAK,IAAI,MAAM,YAAY,aAAa,KAAK,IAAI,CAAC;AAClF,WAAK,iBAAiB,QAAQ,CAAC,CAAC,KAAK,IAAI,MAAM,YAAY,aAAa,KAAK,IAAI,CAAC;AAAA,IACpF;AAAA,IAEA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,4BAA4B,SAAS,EAAE,CAAC;AAClF,kBAAY,kBAAkB,EAAE,UAAU,gCAAgC,EAAE,CAAC;AAAA,IAC/E;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
+
import { listAllAccountUsersAction } from "../actions/list-all-account-users.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
5
|
+
const PAGE_SIZE = 20;
|
|
6
|
+
const LIST_ALL_ACCOUNT_USERS_BASE_KEY = () => ["account-users", "all"];
|
|
7
|
+
const LIST_ALL_ACCOUNT_USERS_QUERY_KEY = (search = "", projectId) => [
|
|
8
|
+
...LIST_ALL_ACCOUNT_USERS_BASE_KEY(),
|
|
9
|
+
search,
|
|
10
|
+
projectId
|
|
11
|
+
];
|
|
12
|
+
function useListAllAccountUsers(search = "", projectId) {
|
|
13
|
+
return useInfiniteQuery({
|
|
14
|
+
queryKey: LIST_ALL_ACCOUNT_USERS_QUERY_KEY(search, projectId),
|
|
15
|
+
queryFn: ({ pageParam }) => withAction(
|
|
16
|
+
() => listAllAccountUsersAction({
|
|
17
|
+
search: search || void 0,
|
|
18
|
+
page: pageParam,
|
|
19
|
+
limit: PAGE_SIZE,
|
|
20
|
+
inProject: projectId
|
|
21
|
+
})
|
|
22
|
+
)(),
|
|
23
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
24
|
+
const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
|
|
25
|
+
return loaded < lastPage.total ? allPages.length + 1 : void 0;
|
|
26
|
+
},
|
|
27
|
+
initialPageParam: 1
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
LIST_ALL_ACCOUNT_USERS_BASE_KEY,
|
|
32
|
+
LIST_ALL_ACCOUNT_USERS_QUERY_KEY,
|
|
33
|
+
useListAllAccountUsers
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=list-all-account-users.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/list-all-account-users.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport { listAllAccountUsersAction } from '../actions/list-all-account-users.action';\nimport { withAction } from '../../../utils/withAction';\n\nconst PAGE_SIZE = 20;\n\nexport const LIST_ALL_ACCOUNT_USERS_BASE_KEY = () => ['account-users', 'all'];\nexport const LIST_ALL_ACCOUNT_USERS_QUERY_KEY = (search: string = '', projectId?: number) => [\n ...LIST_ALL_ACCOUNT_USERS_BASE_KEY(),\n search,\n projectId,\n];\n\nexport function useListAllAccountUsers(search: string = '', projectId?: number) {\n return useInfiniteQuery({\n queryKey: LIST_ALL_ACCOUNT_USERS_QUERY_KEY(search, projectId),\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listAllAccountUsersAction({\n search: search || undefined,\n page: pageParam as number,\n limit: PAGE_SIZE,\n inProject: projectId,\n })\n )(),\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n initialPageParam: 1,\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAE3B,MAAM,YAAY;AAEX,MAAM,kCAAkC,MAAM,CAAC,iBAAiB,KAAK;AACrE,MAAM,mCAAmC,CAAC,SAAiB,IAAI,cAAuB;AAAA,EAC3F,GAAG,gCAAgC;AAAA,EACnC;AAAA,EACA;AACF;AAEO,SAAS,uBAAuB,SAAiB,IAAI,WAAoB;AAC9E,SAAO,iBAAiB;AAAA,IACtB,UAAU,iCAAiC,QAAQ,SAAS;AAAA,IAC5D,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,0BAA0B;AAAA,QACxB,QAAQ,UAAU;AAAA,QAClB,MAAM;AAAA,QACN,OAAO;AAAA,QACP,WAAW;AAAA,MACb,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
+
import { listAvailableUsersAction } from "../actions/list-available-users.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
5
|
+
const PAGE_SIZE = 20;
|
|
6
|
+
const LIST_AVAILABLE_USERS_BASE_KEY = (projectId) => ["project-users", projectId, "out"];
|
|
7
|
+
const LIST_AVAILABLE_USERS_QUERY_KEY = (projectId, search = "") => [
|
|
8
|
+
...LIST_AVAILABLE_USERS_BASE_KEY(projectId),
|
|
9
|
+
search
|
|
10
|
+
];
|
|
11
|
+
function useListAvailableUsers(projectId, search = "") {
|
|
12
|
+
return useInfiniteQuery({
|
|
13
|
+
queryKey: LIST_AVAILABLE_USERS_QUERY_KEY(projectId, search),
|
|
14
|
+
queryFn: ({ pageParam }) => withAction(
|
|
15
|
+
() => listAvailableUsersAction(projectId, {
|
|
16
|
+
search: search || void 0,
|
|
17
|
+
page: pageParam,
|
|
18
|
+
limit: PAGE_SIZE
|
|
19
|
+
})
|
|
20
|
+
)(),
|
|
21
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
22
|
+
const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
|
|
23
|
+
return loaded < lastPage.total ? allPages.length + 1 : void 0;
|
|
24
|
+
},
|
|
25
|
+
initialPageParam: 1,
|
|
26
|
+
enabled: !!projectId
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
LIST_AVAILABLE_USERS_BASE_KEY,
|
|
31
|
+
LIST_AVAILABLE_USERS_QUERY_KEY,
|
|
32
|
+
useListAvailableUsers
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=list-available-users.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/list-available-users.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport { listAvailableUsersAction } from '../actions/list-available-users.action';\nimport { withAction } from '../../../utils/withAction';\n\nconst PAGE_SIZE = 20;\n\nexport const LIST_AVAILABLE_USERS_BASE_KEY = (projectId: number) => ['project-users', projectId, 'out'];\nexport const LIST_AVAILABLE_USERS_QUERY_KEY = (projectId: number, search: string = '') => [\n ...LIST_AVAILABLE_USERS_BASE_KEY(projectId),\n search,\n];\n\nexport function useListAvailableUsers(projectId: number, search: string = '') {\n return useInfiniteQuery({\n queryKey: LIST_AVAILABLE_USERS_QUERY_KEY(projectId, search),\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listAvailableUsersAction(projectId, {\n search: search || undefined,\n page: pageParam as number,\n limit: PAGE_SIZE,\n })\n )(),\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n initialPageParam: 1,\n enabled: !!projectId,\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,kBAAkB;AAE3B,MAAM,YAAY;AAEX,MAAM,gCAAgC,CAAC,cAAsB,CAAC,iBAAiB,WAAW,KAAK;AAC/F,MAAM,iCAAiC,CAAC,WAAmB,SAAiB,OAAO;AAAA,EACxF,GAAG,8BAA8B,SAAS;AAAA,EAC1C;AACF;AAEO,SAAS,sBAAsB,WAAmB,SAAiB,IAAI;AAC5E,SAAO,iBAAiB;AAAA,IACtB,UAAU,+BAA+B,WAAW,MAAM;AAAA,IAC1D,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,yBAAyB,WAAW;AAAA,QAClC,QAAQ,UAAU;AAAA,QAClB,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,IAClB,SAAS,CAAC,CAAC;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
+
import { listProjectUsersAction } from "../actions/list-project-users.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
5
|
+
const PAGE_SIZE = 20;
|
|
6
|
+
const LIST_PROJECT_USERS_BASE_KEY = (projectId) => ["project-users", projectId, "in"];
|
|
7
|
+
const LIST_PROJECT_USERS_QUERY_KEY = (projectId, search = "") => [
|
|
8
|
+
...LIST_PROJECT_USERS_BASE_KEY(projectId),
|
|
9
|
+
search
|
|
10
|
+
];
|
|
11
|
+
function useListProjectUsers(projectId, search = "") {
|
|
12
|
+
return useInfiniteQuery({
|
|
13
|
+
queryKey: LIST_PROJECT_USERS_QUERY_KEY(projectId, search),
|
|
14
|
+
queryFn: ({ pageParam }) => withAction(
|
|
15
|
+
() => listProjectUsersAction(projectId, {
|
|
16
|
+
search: search || void 0,
|
|
17
|
+
page: pageParam,
|
|
18
|
+
limit: PAGE_SIZE
|
|
19
|
+
})
|
|
20
|
+
)(),
|
|
21
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
22
|
+
const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
|
|
23
|
+
return loaded < lastPage.total ? allPages.length + 1 : void 0;
|
|
24
|
+
},
|
|
25
|
+
initialPageParam: 1,
|
|
26
|
+
enabled: !!projectId
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
LIST_PROJECT_USERS_BASE_KEY,
|
|
31
|
+
LIST_PROJECT_USERS_QUERY_KEY,
|
|
32
|
+
useListProjectUsers
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=list-project-users.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/list-project-users.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport { listProjectUsersAction } from '../actions/list-project-users.action';\nimport { withAction } from '../../../utils/withAction';\n\nconst PAGE_SIZE = 20;\n\nexport const LIST_PROJECT_USERS_BASE_KEY = (projectId: number) => ['project-users', projectId, 'in'];\nexport const LIST_PROJECT_USERS_QUERY_KEY = (projectId: number, search: string = '') => [\n ...LIST_PROJECT_USERS_BASE_KEY(projectId),\n search,\n];\n\nexport function useListProjectUsers(projectId: number, search: string = '') {\n return useInfiniteQuery({\n queryKey: LIST_PROJECT_USERS_QUERY_KEY(projectId, search),\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listProjectUsersAction(projectId, {\n search: search || undefined,\n page: pageParam as number,\n limit: PAGE_SIZE,\n })\n )(),\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n initialPageParam: 1,\n enabled: !!projectId,\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAE3B,MAAM,YAAY;AAEX,MAAM,8BAA8B,CAAC,cAAsB,CAAC,iBAAiB,WAAW,IAAI;AAC5F,MAAM,+BAA+B,CAAC,WAAmB,SAAiB,OAAO;AAAA,EACtF,GAAG,4BAA4B,SAAS;AAAA,EACxC;AACF;AAEO,SAAS,oBAAoB,WAAmB,SAAiB,IAAI;AAC1E,SAAO,iBAAiB;AAAA,IACtB,UAAU,6BAA6B,WAAW,MAAM;AAAA,IACxD,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,uBAAuB,WAAW;AAAA,QAChC,QAAQ,UAAU;AAAA,QAClB,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,IAClB,SAAS,CAAC,CAAC;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { removeProjectUserAction } from "../actions/remove-project-user.action";
|
|
4
|
+
import { LIST_PROJECT_USERS_BASE_KEY } from "./list-project-users.hook";
|
|
5
|
+
import { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from "./list-all-account-users.hook";
|
|
6
|
+
function useRemoveProjectUser(projectId) {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
return useMutation({
|
|
9
|
+
mutationFn: (userId) => removeProjectUserAction({ projectId, users: [userId] }),
|
|
10
|
+
onMutate: async (userId) => {
|
|
11
|
+
await queryClient.cancelQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });
|
|
12
|
+
await queryClient.cancelQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });
|
|
13
|
+
const prevAccountUsers = queryClient.getQueriesData({
|
|
14
|
+
queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY()
|
|
15
|
+
});
|
|
16
|
+
const prevProjectUsers = queryClient.getQueriesData({
|
|
17
|
+
queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId)
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueriesData(
|
|
20
|
+
{ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(), exact: false },
|
|
21
|
+
(old) => {
|
|
22
|
+
if (!old) return old;
|
|
23
|
+
return {
|
|
24
|
+
...old,
|
|
25
|
+
pages: old.pages.map((page) => ({
|
|
26
|
+
...page,
|
|
27
|
+
data: page.data.map(
|
|
28
|
+
(u) => u.id === userId ? { ...u, in_project: false } : u
|
|
29
|
+
)
|
|
30
|
+
}))
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
queryClient.setQueriesData(
|
|
35
|
+
{ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId), exact: false },
|
|
36
|
+
(old) => {
|
|
37
|
+
if (!old?.pages.length) return old;
|
|
38
|
+
return {
|
|
39
|
+
...old,
|
|
40
|
+
pages: old.pages.map(
|
|
41
|
+
(page, i) => i === 0 ? { ...page, total: page.total - 1 } : page
|
|
42
|
+
)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
return { prevAccountUsers, prevProjectUsers };
|
|
47
|
+
},
|
|
48
|
+
onError: (_err, _userId, ctx) => {
|
|
49
|
+
ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
50
|
+
ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
51
|
+
},
|
|
52
|
+
onSettled: () => {
|
|
53
|
+
queryClient.invalidateQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
useRemoveProjectUser
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=remove-project-user.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/remove-project-user.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQueryClient, useMutation, InfiniteData } from '@tanstack/react-query';\nimport { removeProjectUserAction } from '../actions/remove-project-user.action';\nimport { LIST_PROJECT_USERS_BASE_KEY } from './list-project-users.hook';\nimport { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from './list-all-account-users.hook';\nimport type { UsersPage, AccountUser, ProjectUser } from '../types';\n\nexport function useRemoveProjectUser(projectId: number) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (userId: number) =>\n removeProjectUserAction({ projectId, users: [userId] }),\n\n onMutate: async (userId) => {\n await queryClient.cancelQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });\n await queryClient.cancelQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });\n\n const prevAccountUsers = queryClient.getQueriesData<InfiniteData<UsersPage<AccountUser>>>({\n queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(),\n });\n const prevProjectUsers = queryClient.getQueriesData<InfiniteData<UsersPage<ProjectUser>>>({\n queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId),\n });\n\n queryClient.setQueriesData<InfiniteData<UsersPage<AccountUser>>>(\n { queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY(), exact: false },\n (old) => {\n if (!old) return old;\n return {\n ...old,\n pages: old.pages.map((page) => ({\n ...page,\n data: page.data.map((u) =>\n u.id === userId ? { ...u, in_project: false } : u\n ),\n })),\n };\n }\n );\n\n queryClient.setQueriesData<InfiniteData<UsersPage<ProjectUser>>>(\n { queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId), exact: false },\n (old) => {\n if (!old?.pages.length) return old;\n return {\n ...old,\n pages: old.pages.map((page, i) =>\n i === 0 ? { ...page, total: page.total - 1 } : page\n ),\n };\n }\n );\n\n return { prevAccountUsers, prevProjectUsers };\n },\n\n onError: (_err, _userId, ctx) => {\n ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n },\n\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: LIST_PROJECT_USERS_BASE_KEY(projectId) });\n queryClient.invalidateQueries({ queryKey: LIST_ALL_ACCOUNT_USERS_BASE_KEY() });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB,mBAAiC;AAC1D,SAAS,+BAA+B;AACxC,SAAS,mCAAmC;AAC5C,SAAS,uCAAuC;AAGzC,SAAS,qBAAqB,WAAmB;AACtD,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,WACX,wBAAwB,EAAE,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC;AAAA,IAExD,UAAU,OAAO,WAAW;AAC1B,YAAM,YAAY,cAAc,EAAE,UAAU,gCAAgC,EAAE,CAAC;AAC/E,YAAM,YAAY,cAAc,EAAE,UAAU,4BAA4B,SAAS,EAAE,CAAC;AAEpF,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU,gCAAgC;AAAA,MAC5C,CAAC;AACD,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU,4BAA4B,SAAS;AAAA,MACjD,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,gCAAgC,GAAG,OAAO,MAAM;AAAA,QAC5D,CAAC,QAAQ;AACP,cAAI,CAAC,IAAK,QAAO;AACjB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,OAAO,IAAI,MAAM,IAAI,CAAC,UAAU;AAAA,cAC9B,GAAG;AAAA,cACH,MAAM,KAAK,KAAK;AAAA,gBAAI,CAAC,MACnB,EAAE,OAAO,SAAS,EAAE,GAAG,GAAG,YAAY,MAAM,IAAI;AAAA,cAClD;AAAA,YACF,EAAE;AAAA,UACJ;AAAA,QACF;AAAA,MACF;AAEA,kBAAY;AAAA,QACV,EAAE,UAAU,4BAA4B,SAAS,GAAG,OAAO,MAAM;AAAA,QACjE,CAAC,QAAQ;AACP,cAAI,CAAC,KAAK,MAAM,OAAQ,QAAO;AAC/B,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,OAAO,IAAI,MAAM;AAAA,cAAI,CAAC,MAAM,MAC1B,MAAM,IAAI,EAAE,GAAG,MAAM,OAAO,KAAK,QAAQ,EAAE,IAAI;AAAA,YACjD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO,EAAE,kBAAkB,iBAAiB;AAAA,IAC9C;AAAA,IAEA,SAAS,CAAC,MAAM,SAAS,QAAQ;AAC/B,WAAK,iBAAiB,QAAQ,CAAC,CAAC,KAAK,IAAI,MAAM,YAAY,aAAa,KAAK,IAAI,CAAC;AAClF,WAAK,iBAAiB,QAAQ,CAAC,CAAC,KAAK,IAAI,MAAM,YAAY,aAAa,KAAK,IAAI,CAAC;AAAA,IACpF;AAAA,IAEA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,4BAA4B,SAAS,EAAE,CAAC;AAClF,kBAAY,kBAAkB,EAAE,UAAU,gCAAgC,EAAE,CAAC;AAAA,IAC/E;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { api } from "../../../infra/api/client";
|
|
3
|
+
import { ApiError } from "../../../infra/api/types";
|
|
4
|
+
import { buildQueryParams } from "../../../infra/utils/params";
|
|
5
|
+
import { getUserContext } from "../../auth/utils/get-user-context";
|
|
6
|
+
import {
|
|
7
|
+
AccountUserSchema,
|
|
8
|
+
ProjectUserSchema
|
|
9
|
+
} from "../types";
|
|
10
|
+
class ProjectUsersService {
|
|
11
|
+
async listInProject(projectId, params = {}) {
|
|
12
|
+
const { id_account, id_user } = await getUserContext();
|
|
13
|
+
const query = buildQueryParams(params);
|
|
14
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users${query ? `?${query}` : ""}`;
|
|
15
|
+
const response = await api.apps.get(url);
|
|
16
|
+
if (response.status === 0) {
|
|
17
|
+
throw new ApiError(
|
|
18
|
+
response.message || "Erro ao listar usu\xE1rios do projeto",
|
|
19
|
+
"LIST_PROJECT_USERS_FAILED",
|
|
20
|
+
400
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
data: response.data.map((item) => ProjectUserSchema.parse(item)),
|
|
25
|
+
total: response.total,
|
|
26
|
+
page: params.page ?? 1
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async listAllAccountUsers(params = {}) {
|
|
30
|
+
const { id_account } = await getUserContext();
|
|
31
|
+
const query = buildQueryParams(params);
|
|
32
|
+
const url = `/accounts/${id_account}/users${query ? `?${query}` : ""}`;
|
|
33
|
+
const response = await api.apps.get(url);
|
|
34
|
+
if (response.status === 0) {
|
|
35
|
+
throw new ApiError(
|
|
36
|
+
response.message || "Erro ao listar usu\xE1rios da conta",
|
|
37
|
+
"LIST_ACCOUNT_USERS_FAILED",
|
|
38
|
+
400
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
data: response.data.map((item) => AccountUserSchema.parse(item)),
|
|
43
|
+
total: response.total,
|
|
44
|
+
page: params.page ?? 1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async listNotInProject(projectId, params = {}) {
|
|
48
|
+
const { id_account } = await getUserContext();
|
|
49
|
+
const query = buildQueryParams({ notInProject: projectId, ...params });
|
|
50
|
+
const url = `/accounts/${id_account}/users${query ? `?${query}` : ""}`;
|
|
51
|
+
const response = await api.apps.get(url);
|
|
52
|
+
if (response.status === 0) {
|
|
53
|
+
throw new ApiError(
|
|
54
|
+
response.message || "Erro ao listar usu\xE1rios dispon\xEDveis",
|
|
55
|
+
"LIST_AVAILABLE_USERS_FAILED",
|
|
56
|
+
400
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
data: response.data.map((item) => AccountUserSchema.parse(item)),
|
|
61
|
+
total: response.total,
|
|
62
|
+
page: params.page ?? 1
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async addToProject({ projectId, users }) {
|
|
66
|
+
const { id_account, id_user } = await getUserContext();
|
|
67
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;
|
|
68
|
+
const response = await api.apps.post(url, { users });
|
|
69
|
+
if (response.status === 0) {
|
|
70
|
+
throw new ApiError(
|
|
71
|
+
response.message || "Erro ao adicionar usu\xE1rio ao projeto",
|
|
72
|
+
"ADD_PROJECT_USER_FAILED",
|
|
73
|
+
400
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async removeFromProject({ projectId, users }) {
|
|
78
|
+
const { id_account, id_user } = await getUserContext();
|
|
79
|
+
const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;
|
|
80
|
+
const response = await api.apps.delete(url, {
|
|
81
|
+
body: JSON.stringify({ users })
|
|
82
|
+
});
|
|
83
|
+
if (response.status === 0) {
|
|
84
|
+
throw new ApiError(
|
|
85
|
+
response.message || "Erro ao remover usu\xE1rio do projeto",
|
|
86
|
+
"REMOVE_PROJECT_USER_FAILED",
|
|
87
|
+
400
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const projectUsersService = new ProjectUsersService();
|
|
93
|
+
export {
|
|
94
|
+
projectUsersService
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=project-users.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/services/project-users.service.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { api } from '../../../infra/api/client';\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { buildQueryParams } from '../../../infra/utils/params';\r\nimport { getUserContext } from '../../auth/utils/get-user-context';\r\nimport {\r\n AccountUser,\r\n AccountUserSchema,\r\n AddRemoveProjectUsersParams,\r\n ListUsersParams,\r\n ProjectUser,\r\n ProjectUserSchema,\r\n UsersPage,\r\n} from '../types';\r\n\r\ninterface ApiListResponse<T> {\r\n data: T[];\r\n total: number;\r\n status: number;\r\n message?: string;\r\n}\r\n\r\ninterface ApiActionResponse {\r\n status: number;\r\n message?: string;\r\n}\r\n\r\nclass ProjectUsersService {\r\n async listInProject(projectId: number, params: ListUsersParams = {}): Promise<UsersPage<ProjectUser>> {\r\n const { id_account, id_user } = await getUserContext();\r\n const query = buildQueryParams(params as Record<string, string | number | boolean | undefined>);\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiListResponse<ProjectUser>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar usuários do projeto',\r\n 'LIST_PROJECT_USERS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n data: response.data.map((item) => ProjectUserSchema.parse(item)),\r\n total: response.total,\r\n page: params.page ?? 1,\r\n };\r\n }\r\n\r\n async listAllAccountUsers(params: ListUsersParams = {}): Promise<UsersPage<AccountUser>> {\r\n const { id_account } = await getUserContext();\r\n const query = buildQueryParams(params as Record<string, string | number | boolean | undefined>);\r\n const url = `/accounts/${id_account}/users${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiListResponse<AccountUser>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar usuários da conta',\r\n 'LIST_ACCOUNT_USERS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n data: response.data.map((item) => AccountUserSchema.parse(item)),\r\n total: response.total,\r\n page: params.page ?? 1,\r\n };\r\n }\r\n\r\n async listNotInProject(projectId: number, params: ListUsersParams = {}): Promise<UsersPage<AccountUser>> {\r\n const { id_account } = await getUserContext();\r\n const query = buildQueryParams({ notInProject: projectId, ...params } as Record<string, string | number | boolean | undefined>);\r\n const url = `/accounts/${id_account}/users${query ? `?${query}` : ''}`;\r\n\r\n const response = await api.apps.get<ApiListResponse<AccountUser>>(url);\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao listar usuários disponíveis',\r\n 'LIST_AVAILABLE_USERS_FAILED',\r\n 400\r\n );\r\n }\r\n\r\n return {\r\n data: response.data.map((item) => AccountUserSchema.parse(item)),\r\n total: response.total,\r\n page: params.page ?? 1,\r\n };\r\n }\r\n\r\n async addToProject({ projectId, users }: AddRemoveProjectUsersParams): Promise<void> {\r\n const { id_account, id_user } = await getUserContext();\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;\r\n\r\n const response = await api.apps.post<ApiActionResponse>(url, { users });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao adicionar usuário ao projeto',\r\n 'ADD_PROJECT_USER_FAILED',\r\n 400\r\n );\r\n }\r\n }\r\n\r\n async removeFromProject({ projectId, users }: AddRemoveProjectUsersParams): Promise<void> {\r\n const { id_account, id_user } = await getUserContext();\r\n const url = `/account/${id_account}/user/${id_user}/projects/${projectId}/users`;\r\n\r\n const response = await api.apps.delete<ApiActionResponse>(url, {\r\n body: JSON.stringify({ users }),\r\n });\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || 'Erro ao remover usuário do projeto',\r\n 'REMOVE_PROJECT_USER_FAILED',\r\n 400\r\n );\r\n }\r\n }\r\n}\r\n\r\nexport const projectUsersService = new ProjectUsersService();\r\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B;AAAA,EAEE;AAAA,EAIA;AAAA,OAEK;AAcP,MAAM,oBAAoB;AAAA,EACxB,MAAM,cAAc,WAAmB,SAA0B,CAAC,GAAoC;AACpG,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AACrD,UAAM,QAAQ,iBAAiB,MAA+D;AAC9F,UAAM,MAAM,YAAY,UAAU,SAAS,OAAO,aAAa,SAAS,SAAS,QAAQ,IAAI,KAAK,KAAK,EAAE;AAEzG,UAAM,WAAW,MAAM,IAAI,KAAK,IAAkC,GAAG;AAErE,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,MAAM,SAAS,KAAK,IAAI,CAAC,SAAS,kBAAkB,MAAM,IAAI,CAAC;AAAA,MAC/D,OAAO,SAAS;AAAA,MAChB,MAAM,OAAO,QAAQ;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,MAAM,oBAAoB,SAA0B,CAAC,GAAoC;AACvF,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAC5C,UAAM,QAAQ,iBAAiB,MAA+D;AAC9F,UAAM,MAAM,aAAa,UAAU,SAAS,QAAQ,IAAI,KAAK,KAAK,EAAE;AAEpE,UAAM,WAAW,MAAM,IAAI,KAAK,IAAkC,GAAG;AAErE,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,MAAM,SAAS,KAAK,IAAI,CAAC,SAAS,kBAAkB,MAAM,IAAI,CAAC;AAAA,MAC/D,OAAO,SAAS;AAAA,MAChB,MAAM,OAAO,QAAQ;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,WAAmB,SAA0B,CAAC,GAAoC;AACvG,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAC5C,UAAM,QAAQ,iBAAiB,EAAE,cAAc,WAAW,GAAG,OAAO,CAA0D;AAC9H,UAAM,MAAM,aAAa,UAAU,SAAS,QAAQ,IAAI,KAAK,KAAK,EAAE;AAEpE,UAAM,WAAW,MAAM,IAAI,KAAK,IAAkC,GAAG;AAErE,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,MAAM,SAAS,KAAK,IAAI,CAAC,SAAS,kBAAkB,MAAM,IAAI,CAAC;AAAA,MAC/D,OAAO,SAAS;AAAA,MAChB,MAAM,OAAO,QAAQ;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,EAAE,WAAW,MAAM,GAA+C;AACnF,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AACrD,UAAM,MAAM,YAAY,UAAU,SAAS,OAAO,aAAa,SAAS;AAExE,UAAM,WAAW,MAAM,IAAI,KAAK,KAAwB,KAAK,EAAE,MAAM,CAAC;AAEtE,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,EAAE,WAAW,MAAM,GAA+C;AACxF,UAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,eAAe;AACrD,UAAM,MAAM,YAAY,UAAU,SAAS,OAAO,aAAa,SAAS;AAExE,UAAM,WAAW,MAAM,IAAI,KAAK,OAA0B,KAAK;AAAA,MAC7D,MAAM,KAAK,UAAU,EAAE,MAAM,CAAC;AAAA,IAChC,CAAC;AAED,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,sBAAsB,IAAI,oBAAoB;","names":[]}
|