@carlonicora/nextjs-jsonapi 1.0.4 → 1.0.6
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/LICENSE +675 -0
- package/dist/{AbstractService-BKlpJA61.d.mts → AbstractService-B2n_JdiC.d.mts} +1 -1
- package/dist/{AbstractService-D9eSVKNa.d.ts → AbstractService-DtQTYovo.d.ts} +1 -1
- package/dist/{content.interface-Dg2lt_An.d.mts → AuthComponent-CPLvEerw.d.mts} +11 -15
- package/dist/{content.interface-BhyAiOFq.d.ts → AuthComponent-m6Qp4Hz6.d.ts} +11 -15
- package/dist/{BlockNoteEditor-UVO3VZZE.mjs → BlockNoteEditor-BLVXQPXV.mjs} +14 -18
- package/dist/{BlockNoteEditor-UVO3VZZE.mjs.map → BlockNoteEditor-BLVXQPXV.mjs.map} +1 -1
- package/dist/{BlockNoteEditor-VFWG6LXI.js → BlockNoteEditor-ZTDHULFT.js} +15 -19
- package/dist/BlockNoteEditor-ZTDHULFT.js.map +1 -0
- package/dist/JsonApiRequest-O7BGUMFO.mjs +23 -0
- package/dist/JsonApiRequest-VARLNKAF.js +23 -0
- package/dist/JsonApiRequest-VARLNKAF.js.map +1 -0
- package/dist/chunk-2LM6LCJW.mjs +1 -0
- package/dist/chunk-3APORDYP.mjs +7783 -0
- package/dist/chunk-3APORDYP.mjs.map +1 -0
- package/dist/{chunk-TMVHSY3Y.js → chunk-5ZEADNNP.js} +36 -17
- package/dist/chunk-5ZEADNNP.js.map +1 -0
- package/dist/{chunk-ECDTZBYO.mjs → chunk-74F6BBHH.mjs} +21 -2
- package/dist/chunk-74F6BBHH.mjs.map +1 -0
- package/dist/{chunk-GYWPEPOH.mjs → chunk-7C5RAEBO.mjs} +72 -68
- package/dist/chunk-7C5RAEBO.mjs.map +1 -0
- package/dist/chunk-A5DDIABK.js +1 -0
- package/dist/{chunk-TEGF6ZWG.js → chunk-AGAJMJ4T.js} +47 -9
- package/dist/chunk-AGAJMJ4T.js.map +1 -0
- package/dist/{chunk-CXQOWQSY.js → chunk-AYHKQWHH.js} +15 -2
- package/dist/chunk-AYHKQWHH.js.map +1 -0
- package/dist/{chunk-I2REI7OA.js → chunk-HMHGLXWC.js} +33 -15
- package/dist/chunk-HMHGLXWC.js.map +1 -0
- package/dist/chunk-IWFGEPAA.mjs +1 -0
- package/dist/chunk-JC3WJK65.js +1 -0
- package/dist/{chunk-L6EQEAXU.mjs → chunk-PYF2U6WG.mjs} +25 -7
- package/dist/chunk-PYF2U6WG.mjs.map +1 -0
- package/dist/{chunk-YDVTFM7X.mjs → chunk-RBIVEH2K.mjs} +42 -4
- package/dist/chunk-RBIVEH2K.mjs.map +1 -0
- package/dist/{chunk-V2JJPI7N.js → chunk-RZO2LOW4.js} +237 -233
- package/dist/chunk-RZO2LOW4.js.map +1 -0
- package/dist/{chunk-X4BIHJ2B.mjs → chunk-SM63SZCP.mjs} +15 -2
- package/dist/chunk-SM63SZCP.mjs.map +1 -0
- package/dist/chunk-WEC4YMOS.js +7783 -0
- package/dist/chunk-WEC4YMOS.js.map +1 -0
- package/dist/client/index.d.mts +21 -2
- package/dist/client/index.d.ts +21 -2
- package/dist/client/index.js +18 -245
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +28 -255
- package/dist/client/index.mjs.map +1 -1
- package/dist/components/index.d.mts +293 -8
- package/dist/components/index.d.ts +293 -8
- package/dist/components/index.js +78 -2323
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +172 -2417
- package/dist/components/index.mjs.map +1 -1
- package/dist/{config-hXufftVS.d.ts → config-BmnK65TD.d.mts} +1 -0
- package/dist/{config-hXufftVS.d.mts → config-BmnK65TD.d.ts} +1 -0
- package/dist/config-DQeAo9Kf.d.mts +49 -0
- package/dist/config-DQeAo9Kf.d.ts +49 -0
- package/dist/contexts/index.d.mts +109 -21
- package/dist/contexts/index.d.ts +109 -21
- package/dist/contexts/index.js +39 -7
- package/dist/contexts/index.js.map +1 -1
- package/dist/contexts/index.mjs +40 -8
- package/dist/core/index.d.mts +3 -4
- package/dist/core/index.d.ts +3 -4
- package/dist/core/index.js +3 -7
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +4 -8
- package/dist/{d3.link.interface-QMdB22bC.d.mts → d3.link.interface-ClC4Irqp.d.mts} +2 -1
- package/dist/{d3.link.interface-QMdB22bC.d.ts → d3.link.interface-ClC4Irqp.d.ts} +2 -1
- package/dist/features/index.d.mts +17 -86
- package/dist/features/index.d.ts +17 -86
- package/dist/features/index.js +7 -16
- package/dist/features/index.js.map +1 -1
- package/dist/features/index.mjs +10 -19
- package/dist/hooks/index.d.mts +18 -43
- package/dist/hooks/index.d.ts +18 -43
- package/dist/hooks/index.js +20 -7
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +19 -6
- package/dist/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -19
- package/dist/interfaces/index.d.mts +2 -1
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/notification.interface-BBgMUdLR.d.mts +14 -0
- package/dist/notification.interface-gyvT-Z2F.d.ts +14 -0
- package/dist/permissions/index.d.mts +2 -3
- package/dist/permissions/index.d.ts +2 -3
- package/dist/server/index.d.mts +38 -18
- package/dist/server/index.d.ts +38 -18
- package/dist/server/index.js +70 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +68 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/types-BUAlgqqh.d.ts +39 -0
- package/dist/{types-DluCaP1I.d.ts → types-Bl61ob-7.d.mts} +19 -2
- package/dist/{types-lQVA8d_P.d.mts → types-Bl61ob-7.d.ts} +19 -2
- package/dist/types-iVdVY7ba.d.mts +39 -0
- package/dist/useSocket-Cn7fB_B1.d.mts +25 -0
- package/dist/useSocket-DzMKRKCA.d.ts +25 -0
- package/dist/user.fields-CbdObSmS.d.mts +18 -0
- package/dist/user.fields-CbdObSmS.d.ts +18 -0
- package/dist/utils/index.d.mts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/package.json +5 -3
- package/src/client/index.ts +13 -0
- package/src/components/forms/index.ts +1 -0
- package/src/components/index.ts +5 -0
- package/src/components/tables/ContentListTable.tsx +1 -0
- package/src/contexts/CommonContext.tsx +52 -0
- package/src/contexts/SharedContext.tsx +2 -0
- package/src/contexts/SocketContext.tsx +65 -0
- package/src/contexts/index.ts +6 -1
- package/src/features/auth/components/containers/AuthContainer.tsx +32 -0
- package/src/features/auth/components/containers/index.ts +1 -0
- package/src/features/auth/components/details/LandingComponent.tsx +39 -0
- package/src/features/auth/components/details/index.ts +1 -0
- package/src/features/auth/components/forms/AcceptInvitation.tsx +136 -0
- package/src/features/auth/components/forms/ActivateAccount.tsx +75 -0
- package/src/features/auth/components/forms/Cookies.tsx +32 -0
- package/src/features/auth/components/forms/ForgotPassword.tsx +108 -0
- package/src/features/auth/components/forms/Login.tsx +118 -0
- package/src/features/auth/components/forms/Logout.tsx +19 -0
- package/src/features/auth/components/forms/RefreshUser.tsx +39 -0
- package/src/features/auth/components/forms/Register.tsx +150 -0
- package/src/features/auth/components/forms/ResetPassword.tsx +126 -0
- package/src/features/auth/components/forms/index.ts +9 -0
- package/src/features/auth/components/index.ts +3 -0
- package/src/features/auth/contexts/AuthContext.tsx +77 -0
- package/src/features/auth/contexts/index.ts +1 -0
- package/src/features/auth/enums/AuthComponent.ts +9 -0
- package/src/features/auth/enums/index.ts +1 -0
- package/src/features/auth/index.ts +2 -1
- package/src/features/auth/utils/AuthCookies.ts +134 -0
- package/src/features/auth/utils/index.ts +1 -0
- package/src/features/company/components/containers/AdminCompanyContainer.tsx +26 -0
- package/src/features/company/components/containers/CompanyContainer.tsx +17 -0
- package/src/features/company/components/containers/index.ts +2 -0
- package/src/features/company/components/details/CompanyDetails.tsx +26 -0
- package/src/features/company/components/details/index.ts +1 -0
- package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +151 -0
- package/src/features/company/components/forms/CompanyConfigurationSecurityForm.tsx +97 -0
- package/src/features/company/components/forms/CompanyDeleter.tsx +121 -0
- package/src/features/company/components/forms/CompanyEditor.tsx +245 -0
- package/src/features/company/components/forms/CompanyLicense.tsx +213 -0
- package/src/features/company/components/forms/index.ts +5 -0
- package/src/features/company/components/index.ts +4 -0
- package/src/features/company/components/lists/CompaniesList.tsx +31 -0
- package/src/features/company/components/lists/index.ts +1 -0
- package/src/features/company/contexts/CompanyContext.tsx +99 -0
- package/src/features/company/contexts/index.ts +0 -0
- package/src/features/company/hooks/index.ts +1 -0
- package/src/features/company/hooks/useCompanyTableStructure.tsx +82 -0
- package/src/features/feature/components/forms/FormFeatures.tsx +141 -140
- package/src/features/feature/components/forms/index.ts +1 -0
- package/src/features/feature/components/index.ts +1 -1
- package/src/features/feature/index.ts +1 -2
- package/src/features/module/index.ts +1 -1
- package/src/features/notification/components/common/NotificationErrorBoundary.tsx +51 -0
- package/src/features/notification/components/common/index.ts +1 -0
- package/src/features/notification/components/containers/NotificationsListContainer.tsx +44 -0
- package/src/features/notification/components/containers/index.ts +1 -0
- package/src/features/notification/components/index.ts +5 -0
- package/src/features/notification/components/lists/NotificationsList.tsx +129 -0
- package/src/features/notification/components/lists/index.ts +1 -0
- package/src/features/notification/components/modals/NotificationModal.tsx +220 -0
- package/src/features/notification/components/modals/index.ts +1 -0
- package/src/features/notification/components/notifications/Notification.tsx +120 -0
- package/src/features/notification/components/notifications/PushNotificationProvider.tsx +9 -0
- package/src/features/notification/components/notifications/index.ts +2 -0
- package/src/features/notification/contexts/NotificationContext.tsx +187 -0
- package/src/features/notification/contexts/index.ts +1 -0
- package/src/features/notification/index.ts +1 -1
- package/src/features/push/index.ts +1 -1
- package/src/features/role/components/containers/RoleContainer.tsx +18 -0
- package/src/features/role/components/containers/index.ts +1 -0
- package/src/features/role/components/details/RoleDetails.tsx +21 -0
- package/src/features/role/components/details/index.ts +1 -0
- package/src/features/role/components/forms/FormRoles.tsx +82 -0
- package/src/features/role/components/forms/RemoveUserFromRole.tsx +108 -0
- package/src/features/role/components/forms/UserRoleAdd.tsx +128 -0
- package/src/features/role/components/forms/index.ts +3 -0
- package/src/features/role/components/index.ts +4 -0
- package/src/features/role/components/lists/RolesList.tsx +27 -0
- package/src/features/role/components/lists/UserRolesList.tsx +31 -0
- package/src/features/role/components/lists/index.ts +2 -0
- package/src/features/role/contexts/RoleContext.tsx +84 -0
- package/src/features/role/contexts/index.ts +1 -0
- package/src/features/role/hooks/index.ts +1 -0
- package/src/features/role/hooks/useRoleTableStructure.tsx +72 -0
- package/src/features/s3/index.ts +1 -1
- package/src/features/user/components/containers/UserContainer.tsx +23 -0
- package/src/features/user/components/containers/UserIndexContainer.tsx +12 -0
- package/src/features/user/components/containers/UsersListContainer.tsx +36 -0
- package/src/features/user/components/containers/index.ts +3 -0
- package/src/features/user/components/details/UserDetails.tsx +74 -0
- package/src/features/user/components/details/UserIndexDetails.tsx +28 -0
- package/src/features/user/components/details/index.ts +2 -0
- package/src/features/user/components/forms/RoleUserAdd.tsx +93 -0
- package/src/features/user/components/forms/UserAvatarEditor.tsx +78 -0
- package/src/features/user/components/forms/UserDeleter.tsx +49 -0
- package/src/features/user/components/forms/UserEditor.tsx +319 -0
- package/src/features/user/components/forms/UserMultiSelect.tsx +218 -0
- package/src/features/user/components/forms/UserReactivator.tsx +79 -0
- package/src/features/user/components/forms/UserResentInvitationEmail.tsx +88 -0
- package/src/features/user/components/forms/UserSelector.tsx +185 -0
- package/src/features/user/components/forms/index.ts +8 -0
- package/src/features/user/components/index.ts +3 -0
- package/src/features/user/components/lists/AdminUsersList.tsx +41 -0
- package/src/features/user/components/lists/CompanyUsersList.tsx +44 -0
- package/src/features/user/components/lists/RelevantUsersList.tsx +30 -0
- package/src/features/user/components/lists/RoleUsersList.tsx +31 -0
- package/src/features/user/components/lists/UserListInAdd.tsx +53 -0
- package/src/features/user/components/lists/UsersList.tsx +30 -0
- package/src/features/user/components/lists/UsersListByContentIds.tsx +30 -0
- package/src/features/user/components/lists/index.ts +7 -0
- package/src/features/user/components/widgets/UserAvatarList.tsx +31 -0
- package/src/features/user/components/widgets/UserSearchPopover.tsx +89 -0
- package/src/features/user/contexts/UserContext.tsx +106 -0
- package/src/features/user/contexts/index.ts +1 -0
- package/src/features/user/hooks/index.ts +2 -0
- package/src/features/user/hooks/useUserSearch.ts +53 -0
- package/src/features/user/hooks/useUserTableStructure.tsx +115 -0
- package/src/features/user/index.ts +0 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCustomD3Graph.tsx +2 -0
- package/src/hooks/useNotificationSync.ts +20 -0
- package/src/hooks/usePageTracker.ts +69 -0
- package/src/hooks/usePushNotifications.ts +82 -0
- package/src/hooks/useSocket.ts +201 -0
- package/src/hooks/useTableGenerator.ts +6 -2
- package/src/i18n/config.ts +1 -0
- package/src/index.ts +4 -0
- package/src/interfaces/d3.link.interface.ts +2 -1
- package/src/server/ServerSession.ts +103 -0
- package/src/server/index.ts +2 -1
- package/src/unified/JsonApiRequest.ts +23 -0
- package/dist/ApiRequestDataTypeInterface-CUKFDBx2.d.mts +0 -20
- package/dist/ApiRequestDataTypeInterface-CUKFDBx2.d.ts +0 -20
- package/dist/BlockNoteEditor-VFWG6LXI.js.map +0 -1
- package/dist/JsonApiRequest-S3ICLM7B.mjs +0 -20
- package/dist/JsonApiRequest-ZZLSP26T.js +0 -20
- package/dist/JsonApiRequest-ZZLSP26T.js.map +0 -1
- package/dist/chunk-366S2JCC.mjs +0 -31
- package/dist/chunk-366S2JCC.mjs.map +0 -1
- package/dist/chunk-5W6AKZE6.mjs +0 -131
- package/dist/chunk-5W6AKZE6.mjs.map +0 -1
- package/dist/chunk-A3J3AAYM.mjs +0 -97
- package/dist/chunk-A3J3AAYM.mjs.map +0 -1
- package/dist/chunk-AWONBQQP.js +0 -97
- package/dist/chunk-AWONBQQP.js.map +0 -1
- package/dist/chunk-CXQOWQSY.js.map +0 -1
- package/dist/chunk-DKKMWBP4.mjs +0 -1
- package/dist/chunk-DKKMWBP4.mjs.map +0 -1
- package/dist/chunk-DO2HLAZO.js +0 -48
- package/dist/chunk-DO2HLAZO.js.map +0 -1
- package/dist/chunk-DZXDB3K2.mjs +0 -17
- package/dist/chunk-DZXDB3K2.mjs.map +0 -1
- package/dist/chunk-ECDTZBYO.mjs.map +0 -1
- package/dist/chunk-FY4SXJGU.js +0 -806
- package/dist/chunk-FY4SXJGU.js.map +0 -1
- package/dist/chunk-GYWPEPOH.mjs.map +0 -1
- package/dist/chunk-H6FMOA6B.js +0 -1
- package/dist/chunk-H6FMOA6B.js.map +0 -1
- package/dist/chunk-I2REI7OA.js.map +0 -1
- package/dist/chunk-J4Q36PMP.js +0 -31
- package/dist/chunk-J4Q36PMP.js.map +0 -1
- package/dist/chunk-L6EQEAXU.mjs.map +0 -1
- package/dist/chunk-MFO27OHB.mjs +0 -48
- package/dist/chunk-MFO27OHB.mjs.map +0 -1
- package/dist/chunk-RAF7PNLG.js +0 -131
- package/dist/chunk-RAF7PNLG.js.map +0 -1
- package/dist/chunk-RUR22SVM.js +0 -17
- package/dist/chunk-RUR22SVM.js.map +0 -1
- package/dist/chunk-TEGF6ZWG.js.map +0 -1
- package/dist/chunk-TMVHSY3Y.js.map +0 -1
- package/dist/chunk-V2JJPI7N.js.map +0 -1
- package/dist/chunk-WWWMJZEF.mjs +0 -806
- package/dist/chunk-WWWMJZEF.mjs.map +0 -1
- package/dist/chunk-X4BIHJ2B.mjs.map +0 -1
- package/dist/chunk-YDVTFM7X.mjs.map +0 -1
- /package/dist/{JsonApiRequest-S3ICLM7B.mjs.map → JsonApiRequest-O7BGUMFO.mjs.map} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
import { ContentListTable } from "../../../../components";
|
|
6
|
+
import { Modules } from "../../../../core";
|
|
7
|
+
import { DataListRetriever, useDataListRetriever } from "../../../../hooks";
|
|
8
|
+
import { CompanyFields, CompanyInterface, CompanyService } from "../../data";
|
|
9
|
+
import { CompanyEditor } from "../forms/CompanyEditor";
|
|
10
|
+
|
|
11
|
+
export function CompaniesList() {
|
|
12
|
+
const t = useTranslations();
|
|
13
|
+
|
|
14
|
+
const data: DataListRetriever<CompanyInterface> = useDataListRetriever({
|
|
15
|
+
retriever: (params) => CompanyService.findMany(params),
|
|
16
|
+
retrieverParams: {},
|
|
17
|
+
module: Modules.Company,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const functions: ReactNode[] = [<CompanyEditor key="create-account" />];
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ContentListTable
|
|
24
|
+
data={data}
|
|
25
|
+
fields={[CompanyFields.name, CompanyFields.createdAt]}
|
|
26
|
+
tableGeneratorType={Modules.Company}
|
|
27
|
+
functions={functions}
|
|
28
|
+
title={t(`types.companies`, { count: 2 })}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CompaniesList";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
4
|
+
import { createContext, ReactNode, useContext, useState } from "react";
|
|
5
|
+
import { SharedProvider } from "../../../contexts";
|
|
6
|
+
import { JsonApiHydratedDataInterface, Modules, rehydrate } from "../../../core";
|
|
7
|
+
import { usePageUrlGenerator } from "../../../hooks";
|
|
8
|
+
import { BreadcrumbItemData } from "../../../interfaces";
|
|
9
|
+
import { Action } from "../../../permissions";
|
|
10
|
+
import { getRoleId } from "../../../roles";
|
|
11
|
+
import { UserInterface } from "../../user";
|
|
12
|
+
import { useCurrentUserContext } from "../../user/contexts";
|
|
13
|
+
import { CompanyConfigurationEditor, CompanyDeleter, CompanyEditor } from "../components";
|
|
14
|
+
import { CompanyInterface } from "../data";
|
|
15
|
+
|
|
16
|
+
interface CompanyContextType {
|
|
17
|
+
company: CompanyInterface | undefined;
|
|
18
|
+
setCompany: (value: CompanyInterface | undefined) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const CompanyContext = createContext<CompanyContextType | undefined>(undefined);
|
|
22
|
+
|
|
23
|
+
type CompanyProviderProps = {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
dehydratedCompany?: JsonApiHydratedDataInterface;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const defaultContextValue: CompanyContextType = {
|
|
29
|
+
company: undefined,
|
|
30
|
+
setCompany: () => {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const CompanyProvider = ({ children, dehydratedCompany }: CompanyProviderProps) => {
|
|
34
|
+
const generateUrl = usePageUrlGenerator();
|
|
35
|
+
const t = useTranslations();
|
|
36
|
+
const { hasPermissionToModule, hasRole } = useCurrentUserContext<UserInterface>();
|
|
37
|
+
|
|
38
|
+
const [company, setCompany] = useState<CompanyInterface | undefined>(
|
|
39
|
+
dehydratedCompany ? rehydrate<CompanyInterface>(Modules.Company, dehydratedCompany) : undefined,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const breadcrumb = () => {
|
|
43
|
+
const response: BreadcrumbItemData[] = [];
|
|
44
|
+
|
|
45
|
+
if (company)
|
|
46
|
+
response.push({
|
|
47
|
+
name: company.name,
|
|
48
|
+
href: generateUrl({ page: Modules.Company }),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const title = () => {
|
|
55
|
+
const response: any = {
|
|
56
|
+
type: t(`types.companies`, { count: company ? 1 : 2 }),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (company) response.element = company.name;
|
|
60
|
+
|
|
61
|
+
const functions: ReactNode[] = [];
|
|
62
|
+
|
|
63
|
+
if (
|
|
64
|
+
company &&
|
|
65
|
+
hasRole(getRoleId().Administrator) &&
|
|
66
|
+
hasPermissionToModule({ module: Modules.Company, action: Action.Delete })
|
|
67
|
+
)
|
|
68
|
+
functions.push(<CompanyDeleter key="companyDeleter" company={company} />);
|
|
69
|
+
|
|
70
|
+
if (
|
|
71
|
+
hasRole(getRoleId().Administrator) ||
|
|
72
|
+
hasPermissionToModule({ module: Modules.Company, action: Action.Update })
|
|
73
|
+
) {
|
|
74
|
+
if (company) functions.push(<CompanyConfigurationEditor key="companyConfigurationEditor" company={company} />);
|
|
75
|
+
functions.push(<CompanyEditor key="companyEditor" company={company} propagateChanges={setCompany} />);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (functions.length > 0) response.functions = functions;
|
|
79
|
+
|
|
80
|
+
return response;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<SharedProvider value={{ breadcrumbs: breadcrumb(), title: title() }}>
|
|
85
|
+
<CompanyContext.Provider
|
|
86
|
+
value={{
|
|
87
|
+
company: company,
|
|
88
|
+
setCompany: setCompany,
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
{children}
|
|
92
|
+
</CompanyContext.Provider>
|
|
93
|
+
</SharedProvider>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const useCompanyContext = (): CompanyContextType => {
|
|
98
|
+
return useContext(CompanyContext) ?? defaultContextValue;
|
|
99
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useCompanyTableStructure";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ColumnDef, Row } from "@tanstack/react-table";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { cellDate, cellId } from "../../../components";
|
|
7
|
+
import { Modules } from "../../../core";
|
|
8
|
+
import { TableContent, usePageUrlGenerator, UseTableStructureHook } from "../../../hooks";
|
|
9
|
+
import { getRoleId } from "../../../roles";
|
|
10
|
+
import { Link } from "../../../shadcnui";
|
|
11
|
+
import { UserInterface } from "../../user";
|
|
12
|
+
import { useCurrentUserContext } from "../../user/contexts";
|
|
13
|
+
import { CompanyFields, CompanyInterface } from "../data";
|
|
14
|
+
|
|
15
|
+
export const useCompanyTableStructure: UseTableStructureHook<CompanyInterface, CompanyFields> = (params) => {
|
|
16
|
+
const t = useTranslations();
|
|
17
|
+
const generateUrl = usePageUrlGenerator();
|
|
18
|
+
const { hasRole } = useCurrentUserContext<UserInterface>();
|
|
19
|
+
|
|
20
|
+
// Memoize tableData to prevent infinite re-renders
|
|
21
|
+
const tableData = useMemo(() => {
|
|
22
|
+
return params.data.map((company: CompanyInterface) => {
|
|
23
|
+
const entry: TableContent<CompanyInterface> = {
|
|
24
|
+
jsonApiData: company,
|
|
25
|
+
};
|
|
26
|
+
entry[CompanyFields.companyId] = company.id;
|
|
27
|
+
params.fields.forEach((field) => {
|
|
28
|
+
entry[field] = company[field as keyof CompanyInterface];
|
|
29
|
+
});
|
|
30
|
+
return entry;
|
|
31
|
+
});
|
|
32
|
+
}, [params.data, params.fields]);
|
|
33
|
+
|
|
34
|
+
const fieldColumnMap: Partial<Record<CompanyFields, () => any>> = {
|
|
35
|
+
[CompanyFields.companyId]: () =>
|
|
36
|
+
cellId({
|
|
37
|
+
name: "companyId",
|
|
38
|
+
checkedIds: params.checkedIds,
|
|
39
|
+
toggleId: params.toggleId,
|
|
40
|
+
}),
|
|
41
|
+
[CompanyFields.name]: () => ({
|
|
42
|
+
id: "name",
|
|
43
|
+
accessorKey: "name",
|
|
44
|
+
header: t(`foundations.user.fields.name.label`),
|
|
45
|
+
cell: ({ row }: { row: Row<TableContent<CompanyInterface>> }) => {
|
|
46
|
+
const company = row.original.jsonApiData as CompanyInterface;
|
|
47
|
+
return (
|
|
48
|
+
<Link
|
|
49
|
+
href={
|
|
50
|
+
hasRole(getRoleId().Administrator)
|
|
51
|
+
? generateUrl({
|
|
52
|
+
page: "/administration",
|
|
53
|
+
id: Modules.Company.pageUrl?.substring(1),
|
|
54
|
+
childPage: company.id,
|
|
55
|
+
})
|
|
56
|
+
: generateUrl({ page: Modules.Company, id: company.id })
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
{row.getValue("name")}
|
|
60
|
+
</Link>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
enableSorting: false,
|
|
64
|
+
enableHiding: false,
|
|
65
|
+
}),
|
|
66
|
+
[CompanyFields.createdAt]: () =>
|
|
67
|
+
cellDate({
|
|
68
|
+
name: "createdAt",
|
|
69
|
+
title: t(`generic.date.create`),
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Memoize columns to prevent infinite re-renders
|
|
74
|
+
const columns = useMemo(() => {
|
|
75
|
+
return params.fields.map((field) => fieldColumnMap[field]?.()).filter((col) => col !== undefined) as ColumnDef<
|
|
76
|
+
TableContent<CompanyInterface>
|
|
77
|
+
>[];
|
|
78
|
+
}, [params.fields, fieldColumnMap, t, generateUrl, hasRole]);
|
|
79
|
+
|
|
80
|
+
// Memoize the return object to prevent infinite re-renders
|
|
81
|
+
return useMemo(() => ({ data: tableData, columns: columns }), [tableData, columns]);
|
|
82
|
+
};
|
|
@@ -1,149 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import {
|
|
4
|
+
Accordion,
|
|
5
|
+
AccordionContent,
|
|
6
|
+
AccordionItem,
|
|
7
|
+
AccordionTrigger,
|
|
8
|
+
Checkbox,
|
|
9
|
+
FormLabel,
|
|
10
|
+
FormMessage,
|
|
11
|
+
} from "../../../../shadcnui";
|
|
12
|
+
import { ModuleInterface } from "../../../module";
|
|
13
|
+
import { FeatureInterface } from "../../data";
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
type FormFeaturesProps = {
|
|
16
|
+
form: any;
|
|
17
|
+
name?: string;
|
|
18
|
+
features: FeatureInterface[];
|
|
19
|
+
featureField?: string;
|
|
20
|
+
moduleField?: string;
|
|
21
|
+
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
export function FormFeatures({
|
|
24
|
+
form,
|
|
25
|
+
name,
|
|
26
|
+
features,
|
|
27
|
+
featureField = "featureIds",
|
|
28
|
+
moduleField = "moduleIds",
|
|
29
|
+
}: FormFeaturesProps) {
|
|
30
|
+
const selectedFeatures: string[] = form.watch(featureField);
|
|
31
|
+
const selectedModules: string[] = form.watch(moduleField);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const toggleFeature = (feature: FeatureInterface, checked: boolean) => {
|
|
34
|
+
let newFeatureIds = [...selectedFeatures];
|
|
35
|
+
let newModuleIds = [...selectedModules];
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
if (checked) {
|
|
38
|
+
if (!newFeatureIds.includes(feature.id)) {
|
|
39
|
+
newFeatureIds.push(feature.id);
|
|
40
|
+
}
|
|
41
|
+
feature.modules.forEach((module) => {
|
|
42
|
+
if (!newModuleIds.includes(module.id)) {
|
|
43
|
+
newModuleIds.push(module.id);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
newFeatureIds = newFeatureIds.filter((id) => id !== feature.id);
|
|
48
|
+
feature.modules.forEach((module) => {
|
|
49
|
+
newModuleIds = newModuleIds.filter((id) => id !== module.id);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
form.setValue(featureField, newFeatureIds);
|
|
53
|
+
form.setValue(moduleField, newModuleIds);
|
|
54
|
+
};
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const toggleModule = (feature: FeatureInterface, module: ModuleInterface, checked: boolean) => {
|
|
57
|
+
const modulesForFeature = feature.modules.map((m) => m.id);
|
|
58
|
+
let newModuleIds = [...selectedModules];
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
if (checked) {
|
|
61
|
+
if (!selectedFeatures.includes(feature.id)) {
|
|
62
|
+
newModuleIds = newModuleIds.filter((id) => !modulesForFeature.includes(id));
|
|
63
|
+
newModuleIds.push(module.id);
|
|
64
|
+
form.setValue(featureField, [...selectedFeatures, feature.id]);
|
|
65
|
+
} else {
|
|
66
|
+
if (!newModuleIds.includes(module.id)) {
|
|
67
|
+
newModuleIds.push(module.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newModuleIds = newModuleIds.filter((id) => id !== module.id);
|
|
72
|
+
const remaining = feature.modules.filter((m) => newModuleIds.includes(m.id));
|
|
73
|
+
if (remaining.length === 0) {
|
|
74
|
+
form.setValue(
|
|
75
|
+
featureField,
|
|
76
|
+
selectedFeatures.filter((id) => id !== feature.id),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
form.setValue(moduleField, newModuleIds);
|
|
81
|
+
};
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
const isFeatureChecked = (feature: FeatureInterface) =>
|
|
84
|
+
selectedFeatures.includes(feature.id) || feature.modules.every((module) => selectedModules.includes(module.id));
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
86
|
+
return (
|
|
87
|
+
<div className="flex w-full flex-col">
|
|
88
|
+
{name && <h2 className="mb-5 font-semibold">{name}</h2>}
|
|
89
|
+
{features.map((feature) => (
|
|
90
|
+
<Accordion
|
|
91
|
+
key={feature.id}
|
|
92
|
+
type="single"
|
|
93
|
+
collapsible
|
|
94
|
+
// className={`w-full p-0 ${feature.modules.filter((module) => !module.isCore).length === 0 ? "border-t" : ""}`}
|
|
95
|
+
className={`w-full p-0`}
|
|
96
|
+
>
|
|
97
|
+
<AccordionItem value={feature.id} className="p-0">
|
|
98
|
+
<div
|
|
99
|
+
className={`flex items-center justify-between p-0 ${feature.modules.filter((module) => !module.isCore).length === 0 ? "py-4" : ""}`}
|
|
100
|
+
>
|
|
101
|
+
<div className="flex items-center" onClick={(e) => e.stopPropagation()}>
|
|
102
|
+
<Checkbox
|
|
103
|
+
id={feature.id}
|
|
104
|
+
checked={isFeatureChecked(feature)}
|
|
105
|
+
onCheckedChange={(val) => {
|
|
106
|
+
toggleFeature(feature, val === true);
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
<FormLabel htmlFor={feature.id} className="ml-3 cursor-pointer font-normal">
|
|
110
|
+
{feature.name}
|
|
111
|
+
</FormLabel>
|
|
112
|
+
</div>
|
|
113
|
+
{feature.modules.filter((module) => !module.isCore).length > 0 && (
|
|
114
|
+
<AccordionTrigger asChild>
|
|
115
|
+
<div className="w-full"></div>
|
|
116
|
+
</AccordionTrigger>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
{feature.modules.filter((module) => !module.isCore).length > 0 && (
|
|
120
|
+
<AccordionContent className="pl-6">
|
|
121
|
+
{feature.modules
|
|
122
|
+
.filter((module) => !module.isCore)
|
|
123
|
+
.sort((a: ModuleInterface, b: ModuleInterface) => a.name.localeCompare(b.name))
|
|
124
|
+
.map((module: ModuleInterface) => (
|
|
125
|
+
<div
|
|
126
|
+
key={module.id}
|
|
127
|
+
className="flex items-center border-t py-2"
|
|
128
|
+
onClick={(e) => e.stopPropagation()}
|
|
129
|
+
>
|
|
130
|
+
<Checkbox
|
|
131
|
+
id={module.id}
|
|
132
|
+
checked={selectedModules.includes(module.id)}
|
|
133
|
+
onCheckedChange={(val) => {
|
|
134
|
+
toggleModule(feature, module, val === true);
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
<FormLabel htmlFor={module.id} className="ml-3 cursor-pointer font-normal">
|
|
138
|
+
{module.name}
|
|
139
|
+
</FormLabel>
|
|
140
|
+
</div>
|
|
141
|
+
))}
|
|
142
|
+
</AccordionContent>
|
|
143
|
+
)}
|
|
144
|
+
</AccordionItem>
|
|
145
|
+
</Accordion>
|
|
146
|
+
))}
|
|
147
|
+
<FormMessage />
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FormFeatures";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "./forms";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { Component, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
fallback?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface State {
|
|
11
|
+
hasError: boolean;
|
|
12
|
+
error?: Error;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class NotificationErrorBoundary extends Component<Props, State> {
|
|
16
|
+
constructor(props: Props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.state = { hasError: false };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getDerivedStateFromError(error: Error): State {
|
|
22
|
+
// Update state so the next render will show the fallback UI
|
|
23
|
+
return { hasError: true, error };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
27
|
+
console.error("🚨 [NotificationErrorBoundary] Caught error:", error, errorInfo);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
render() {
|
|
31
|
+
if (this.state.hasError) {
|
|
32
|
+
return (
|
|
33
|
+
this.props.fallback || (
|
|
34
|
+
<div className="flex items-center justify-center p-4 text-center">
|
|
35
|
+
<div className="text-muted-foreground text-sm">
|
|
36
|
+
<p>Something went wrong with notifications.</p>
|
|
37
|
+
<button
|
|
38
|
+
onClick={() => this.setState({ hasError: false })}
|
|
39
|
+
className="text-primary mt-2 underline hover:no-underline"
|
|
40
|
+
>
|
|
41
|
+
Try again
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.props.children;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./NotificationErrorBoundary";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
4
|
+
import { Tab, TabsContainer } from "../../../../components";
|
|
5
|
+
import { useNotificationContext } from "../../contexts/NotificationContext";
|
|
6
|
+
import { NotificationErrorBoundary } from "../common";
|
|
7
|
+
import { NotificationsList } from "../lists/NotificationsList";
|
|
8
|
+
|
|
9
|
+
function NotificationsListContainerContent() {
|
|
10
|
+
const t = useTranslations();
|
|
11
|
+
const { notifications, isLoading, error } = useNotificationContext();
|
|
12
|
+
|
|
13
|
+
if (error) {
|
|
14
|
+
return (
|
|
15
|
+
<div className="flex items-center justify-center p-8 text-center">
|
|
16
|
+
<div className="text-destructive text-sm">
|
|
17
|
+
<p>Error loading notifications: {error}</p>
|
|
18
|
+
<p className="text-muted-foreground mt-2">Please try refreshing the page.</p>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const tabs: Tab[] = [
|
|
25
|
+
{
|
|
26
|
+
label: t(`foundations.notification.inbox`),
|
|
27
|
+
content: <NotificationsList archived={false} />,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: t(`foundations.notification.archived`),
|
|
31
|
+
content: <NotificationsList archived={true} />,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
return <TabsContainer tabs={tabs} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function NotificationsListContainer() {
|
|
39
|
+
return (
|
|
40
|
+
<NotificationErrorBoundary>
|
|
41
|
+
<NotificationsListContainerContent />
|
|
42
|
+
</NotificationErrorBoundary>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./NotificationsListContainer";
|