sea-react-components 1.3.39 → 1.3.41
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/HOC/can-access-application/index.d.ts +3 -2
- package/dist/HOC/can-access-application/index.d.ts.map +1 -1
- package/dist/HOC/can-access-application/index.js +2 -2
- package/dist/HOC/with-authorization/index.d.ts +3 -2
- package/dist/HOC/with-authorization/index.d.ts.map +1 -1
- package/dist/HOC/with-authorization/index.js +5 -5
- package/dist/components/comments-container/comment-form/index.d.ts +2 -1
- package/dist/components/comments-container/comment-form/index.d.ts.map +1 -1
- package/dist/components/comments-container/comment-form/index.js +5 -3
- package/dist/components/comments-container/index.d.ts +2 -1
- package/dist/components/comments-container/index.d.ts.map +1 -1
- package/dist/components/comments-container/index.js +11 -9
- package/dist/components/comments-container/use-comments/index.d.ts +2 -1
- package/dist/components/comments-container/use-comments/index.d.ts.map +1 -1
- package/dist/components/comments-container/use-comments/index.js +3 -3
- package/dist/components/firebase-token-handler/index.d.ts +2 -1
- package/dist/components/firebase-token-handler/index.d.ts.map +1 -1
- package/dist/components/firebase-token-handler/index.js +18 -17
- package/dist/components/log-activities-container/index.d.ts +2 -1
- package/dist/components/log-activities-container/index.d.ts.map +1 -1
- package/dist/components/log-activities-container/index.js +2 -2
- package/dist/components/log-activities-container/log-activities-list/index.d.ts +2 -1
- package/dist/components/log-activities-container/log-activities-list/index.d.ts.map +1 -1
- package/dist/components/log-activities-container/log-activities-list/index.js +4 -2
- package/dist/components/log-activities-container/use-log-activities/index.d.ts +2 -1
- package/dist/components/log-activities-container/use-log-activities/index.d.ts.map +1 -1
- package/dist/components/log-activities-container/use-log-activities/index.js +5 -3
- package/dist/components/not-authorized/index.d.ts +5 -1
- package/dist/components/not-authorized/index.d.ts.map +1 -1
- package/dist/components/not-authorized/index.js +27 -2
- package/dist/components/notifications-menu/index.d.ts +2 -1
- package/dist/components/notifications-menu/index.d.ts.map +1 -1
- package/dist/components/notifications-menu/index.js +48 -27
- package/dist/components/skeleton/index.d.ts +4 -2
- package/dist/components/skeleton/index.d.ts.map +1 -1
- package/dist/components/skeleton/index.js +3 -3
- package/dist/hooks/use-has-permission-access/index.d.ts +2 -2
- package/dist/hooks/use-has-permission-access/index.d.ts.map +1 -1
- package/dist/hooks/use-has-permission-access/index.js +2 -6
- package/dist/hooks/use-translation/index.d.ts.map +1 -1
- package/dist/hooks/use-translation/index.js +5 -2
- package/dist/hooks/user-has-application-access/index.d.ts +1 -1
- package/dist/hooks/user-has-application-access/index.d.ts.map +1 -1
- package/dist/hooks/user-has-application-access/index.js +1 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/middleware/must-auth/index.d.ts +2 -1
- package/dist/middleware/must-auth/index.d.ts.map +1 -1
- package/dist/middleware/must-auth/index.js +2 -5
- package/dist/providers/abstract-socket-provider/index.d.ts +22 -0
- package/dist/providers/abstract-socket-provider/index.d.ts.map +1 -0
- package/dist/providers/abstract-socket-provider/index.js +118 -0
- package/dist/providers/sea-socket-provider/index.d.ts +22 -0
- package/dist/providers/sea-socket-provider/index.d.ts.map +1 -0
- package/dist/providers/sea-socket-provider/index.js +119 -0
- package/dist/providers/socket-provider/index.d.ts +2 -1
- package/dist/providers/socket-provider/index.d.ts.map +1 -1
- package/dist/providers/socket-provider/index.js +1 -4
- package/dist/services/remote-service/index.d.ts +1 -0
- package/dist/services/remote-service/index.d.ts.map +1 -1
- package/dist/services/remote-service/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/auth-axios/index.d.ts +1 -1
- package/dist/utils/auth-axios/index.d.ts.map +1 -1
- package/dist/utils/auth-axios/index.js +1 -3
- package/dist/utils/axios/index.d.ts +1 -1
- package/dist/utils/axios/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,8 @@ import { CONSTANTS } from "sea-platform-helpers";
|
|
|
3
3
|
export interface Props {
|
|
4
4
|
applicationKey: CONSTANTS.Application.ApplicationKeys;
|
|
5
5
|
fallback?: React.ReactNode;
|
|
6
|
-
hasApplicationAccess: (key: CONSTANTS.Application.ApplicationKeys) => boolean;
|
|
6
|
+
hasApplicationAccess: (key: CONSTANTS.Application.ApplicationKeys, accessToken: string) => boolean;
|
|
7
|
+
accessToken: string;
|
|
7
8
|
}
|
|
8
|
-
export default function CanAccessApplication<P>(WrappedComponent: React.ComponentType<P>, { applicationKey, fallback, hasApplicationAccess, }: Props): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function CanAccessApplication<P>(WrappedComponent: React.ComponentType<P>, { applicationKey, fallback, hasApplicationAccess, accessToken, }: Props): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/HOC/can-access-application/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,WAAW,KAAK;IACpB,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/HOC/can-access-application/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,WAAW,KAAK;IACpB,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,oBAAoB,EAAE,CACpB,GAAG,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,EAC1C,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,CAAC,EAC5C,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACxC,EACE,cAAc,EACd,QAIC,EACD,oBAAoB,EACpB,WAAW,GACZ,EAAE,KAAK,IAEA,OAAO,CAAC,6CAMjB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import NotAuthorized from "../../components/not-authorized";
|
|
4
|
-
export default function CanAccessApplication(WrappedComponent, { applicationKey, fallback = (_jsx("div", { className: "flex items-center justify-center h-screen", children: _jsx(NotAuthorized, {}) })), hasApplicationAccess, }) {
|
|
4
|
+
export default function CanAccessApplication(WrappedComponent, { applicationKey, fallback = (_jsx("div", { className: "flex items-center justify-center h-screen", children: _jsx(NotAuthorized, {}) })), hasApplicationAccess, accessToken, }) {
|
|
5
5
|
return (props) => {
|
|
6
|
-
const canAccess = hasApplicationAccess(applicationKey);
|
|
6
|
+
const canAccess = hasApplicationAccess(applicationKey, accessToken);
|
|
7
7
|
if (!canAccess)
|
|
8
8
|
return _jsx(_Fragment, { children: fallback });
|
|
9
9
|
return _jsx(WrappedComponent, { ...props });
|
|
@@ -5,8 +5,9 @@ export interface Props {
|
|
|
5
5
|
requiredPermissions: CONSTANTS.Permission.PermissionKeys[];
|
|
6
6
|
strategy?: ValidationStrategy;
|
|
7
7
|
fallback?: React.ReactNode;
|
|
8
|
-
hasPermission: (key: CONSTANTS.Permission.PermissionKeys) => boolean;
|
|
8
|
+
hasPermission: (key: CONSTANTS.Permission.PermissionKeys, accessToken: string) => boolean;
|
|
9
|
+
accessToken: string;
|
|
9
10
|
}
|
|
10
|
-
export default function WithAuthorization<P>(WrappedComponent: React.ComponentType<P>, { requiredPermissions, strategy, fallback, hasPermission, }: Props): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default function WithAuthorization<P>(WrappedComponent: React.ComponentType<P>, { requiredPermissions, strategy, fallback, hasPermission, accessToken, }: Props): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/HOC/with-authorization/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,KAAK,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjD,MAAM,WAAW,KAAK;IACpB,mBAAmB,EAAE,SAAS,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/HOC/with-authorization/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,KAAK,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjD,MAAM,WAAW,KAAK;IACpB,mBAAmB,EAAE,SAAS,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,EAAE,CACb,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,cAAc,EACxC,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EACzC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACxC,EACE,mBAAmB,EACnB,QAAgB,EAChB,QAA4B,EAC5B,aAAa,EACb,WAAW,GACZ,EAAE,KAAK,IAEA,OAAO,CAAC,6CAYjB"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import NotAuthorized from "../../components/not-authorized";
|
|
4
|
-
export default function WithAuthorization(WrappedComponent, { requiredPermissions, strategy = "all", fallback = _jsx(NotAuthorized, {}), hasPermission, }) {
|
|
4
|
+
export default function WithAuthorization(WrappedComponent, { requiredPermissions, strategy = "all", fallback = _jsx(NotAuthorized, {}), hasPermission, accessToken, }) {
|
|
5
5
|
return (props) => {
|
|
6
|
-
const isAuthorized = validatePermissions(requiredPermissions, strategy, hasPermission);
|
|
6
|
+
const isAuthorized = validatePermissions(requiredPermissions, strategy, hasPermission, accessToken);
|
|
7
7
|
if (!isAuthorized)
|
|
8
8
|
return _jsx(_Fragment, { children: fallback });
|
|
9
9
|
return _jsx(WrappedComponent, { ...props });
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function validatePermissions(requiredPermissions, strategy, hasPermission) {
|
|
12
|
+
function validatePermissions(requiredPermissions, strategy, hasPermission, accessToken) {
|
|
13
13
|
switch (strategy) {
|
|
14
14
|
case "all":
|
|
15
|
-
return requiredPermissions.every((key) => hasPermission(key));
|
|
15
|
+
return requiredPermissions.every((key) => hasPermission(key, accessToken));
|
|
16
16
|
case "some":
|
|
17
17
|
case "one":
|
|
18
|
-
return requiredPermissions.some((key) => hasPermission(key));
|
|
18
|
+
return requiredPermissions.some((key) => hasPermission(key, accessToken));
|
|
19
19
|
default:
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
@@ -33,7 +33,8 @@ export type Props = {
|
|
|
33
33
|
onCreateCommentSuccess?: (comment: DTO.Comment.IComment) => void;
|
|
34
34
|
onEditCommentSuccess?: (comment: DTO.Comment.IComment) => void;
|
|
35
35
|
renderForm?: (props: CommentFormRenderProps) => React.ReactNode;
|
|
36
|
+
accessToken?: string;
|
|
36
37
|
};
|
|
37
|
-
export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, accessToken, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
38
39
|
export {};
|
|
39
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/comments-container/comment-form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,eAAO,MAAM,0BAA0B;;;;MAQtC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IAExB,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrC,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEtE,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,iBAAiB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEvE,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IACjE,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAE/D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/comments-container/comment-form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,eAAO,MAAM,0BAA0B;;;;MAQtC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IAExB,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrC,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEtE,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtC,iBAAiB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAEvE,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IACjE,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAE/D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,KAAK,EACL,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACV,WAAW,GACZ,EAAE,KAAK,2CAsIP"}
|
|
@@ -16,7 +16,7 @@ export const createNewCommentValidation = () => {
|
|
|
16
16
|
.required("Required"),
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, }) {
|
|
19
|
+
export default function CommentForm({ objectId, model, commentsBaseUrl, commentToEdit, setCommentToEdit, replyOnComment, setReplyOnComment, onCreateCommentSuccess, onEditCommentSuccess, renderForm, accessToken, }) {
|
|
20
20
|
var _a;
|
|
21
21
|
const initialValues = {
|
|
22
22
|
model,
|
|
@@ -27,12 +27,14 @@ export default function CommentForm({ objectId, model, commentsBaseUrl, commentT
|
|
|
27
27
|
const onSubmit = async (values, helpers) => {
|
|
28
28
|
try {
|
|
29
29
|
if (commentToEdit) {
|
|
30
|
-
const response = await authAxiosInstance.put(`${commentsBaseUrl}/${commentToEdit.id}`, {
|
|
30
|
+
const response = await authAxiosInstance(accessToken).put(`${commentsBaseUrl}/${commentToEdit.id}`, {
|
|
31
|
+
description: values.description,
|
|
32
|
+
});
|
|
31
33
|
eventBus.emit(COMMENT_EVENTS.UpdateComment, response.data);
|
|
32
34
|
onEditCommentSuccess === null || onEditCommentSuccess === void 0 ? void 0 : onEditCommentSuccess(response.data);
|
|
33
35
|
}
|
|
34
36
|
else {
|
|
35
|
-
const response = await authAxiosInstance.post(commentsBaseUrl, {
|
|
37
|
+
const response = await authAxiosInstance(accessToken).post(commentsBaseUrl, {
|
|
36
38
|
objectId: values.objectId,
|
|
37
39
|
model: values.model,
|
|
38
40
|
description: values.description,
|
|
@@ -16,6 +16,7 @@ export type Props = {
|
|
|
16
16
|
highlightCommentId?: string;
|
|
17
17
|
}) => React.ReactNode;
|
|
18
18
|
renderForm?: (props: CommentFormRenderProps) => React.ReactNode;
|
|
19
|
+
accessToken?: string;
|
|
19
20
|
};
|
|
20
|
-
export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit, highlightCommentId, renderCommentItem, renderForm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit, highlightCommentId, renderCommentItem, renderForm, accessToken, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/comments-container/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/comments-container/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAG3C,OAAoB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAC7B,WAAW,EAAE;QACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACjE,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;QACpE,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,KACE,KAAK,CAAC,SAAS,CAAC;IAErB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;IAEhE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,eAAe,EACf,QAAQ,EACR,KAAK,EACL,KAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,EAAE,KAAK,2CA6DP"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
|
-
import { CONSTANTS } from "sea-platform-helpers";
|
|
5
|
-
import { getCookie } from "../../utils/cookie";
|
|
6
4
|
import { jwtDecode } from "../../utils/jwt";
|
|
7
5
|
import CommentForm from "./comment-form";
|
|
8
6
|
import CommentsList from "./comments-list";
|
|
9
7
|
import CommentItem from "./comment-item";
|
|
10
|
-
export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit = 10, highlightCommentId, renderCommentItem, renderForm, }) {
|
|
8
|
+
export default function CommentsContainer({ commentsBaseUrl, objectId, model, limit = 10, highlightCommentId, renderCommentItem, renderForm, accessToken, }) {
|
|
11
9
|
const [accountId, setAccountId] = useState("");
|
|
12
10
|
const [commentToEdit, setCommentToEdit] = useState();
|
|
13
11
|
const [replyOnComment, setReplyOnComment] = useState();
|
|
14
12
|
useEffect(() => {
|
|
15
|
-
var _a
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
var _a;
|
|
14
|
+
if (accessToken) {
|
|
15
|
+
const payload = (_a = jwtDecode(accessToken)) !== null && _a !== void 0 ? _a : null;
|
|
16
|
+
setAccountId((payload === null || payload === void 0 ? void 0 : payload.id) || "");
|
|
17
|
+
}
|
|
18
|
+
}, [accessToken]);
|
|
19
|
+
if (!accessToken) {
|
|
20
|
+
return (_jsx("p", { className: "p-4 text-center text-sm text-gray-500", children: "Please provide an access token to view and interact with comments." }));
|
|
21
|
+
}
|
|
20
22
|
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(CommentForm, { commentsBaseUrl: commentsBaseUrl, objectId: objectId, model: model, commentToEdit: commentToEdit, setCommentToEdit: setCommentToEdit, replyOnComment: replyOnComment, setReplyOnComment: setReplyOnComment, onCreateCommentSuccess: () => {
|
|
21
23
|
setCommentToEdit(undefined);
|
|
22
24
|
setReplyOnComment(undefined);
|
|
23
25
|
}, onEditCommentSuccess: () => {
|
|
24
26
|
setCommentToEdit(undefined);
|
|
25
27
|
setReplyOnComment(undefined);
|
|
26
|
-
}, renderForm: renderForm }), _jsx(CommentsList, { editComment: setCommentToEdit, replyOnComment: setReplyOnComment, highlightCommentId: highlightCommentId, currentAccountId: accountId, commentsBaseUrl: commentsBaseUrl, objectId: objectId, limit: limit, renderCommentItem: renderCommentItem !== null && renderCommentItem !== void 0 ? renderCommentItem : ((comment, props) => (_jsx(CommentItem, { comment: comment, ...props }, comment.id))) })] }));
|
|
28
|
+
}, renderForm: renderForm, accessToken: accessToken }), _jsx(CommentsList, { editComment: setCommentToEdit, replyOnComment: setReplyOnComment, highlightCommentId: highlightCommentId, currentAccountId: accountId, commentsBaseUrl: commentsBaseUrl, objectId: objectId, limit: limit, renderCommentItem: renderCommentItem !== null && renderCommentItem !== void 0 ? renderCommentItem : ((comment, props) => (_jsx(CommentItem, { comment: comment, ...props }, comment.id))) })] }));
|
|
27
29
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DTO } from "sea-platform-helpers";
|
|
2
|
-
export declare function useComments({ commentsBaseUrl, objectId, limit, parentCommentId, }: {
|
|
2
|
+
export declare function useComments({ commentsBaseUrl, objectId, limit, parentCommentId, accessToken, }: {
|
|
3
3
|
commentsBaseUrl: string;
|
|
4
4
|
objectId: string;
|
|
5
5
|
limit?: number;
|
|
6
6
|
parentCommentId?: string;
|
|
7
|
+
accessToken?: string;
|
|
7
8
|
}): {
|
|
8
9
|
comments: DTO.Comment.IComment[];
|
|
9
10
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/comments-container/use-comments/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,WAAW,CAAC,EAC1B,eAAe,EACf,QAAQ,EACR,KAAU,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/comments-container/use-comments/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,WAAW,CAAC,EAC1B,eAAe,EACf,QAAQ,EACR,KAAU,EACV,eAAe,EACf,WAAW,GACZ,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;8BA0CkC,GAAG,CAAC,OAAO,CAAC,QAAQ;6BAkBrB,GAAG,CAAC,OAAO,CAAC,QAAQ;;;EAkBrD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { Utils } from "sea-platform-helpers";
|
|
4
4
|
import { authAxiosInstance } from "../../../utils/auth-axios";
|
|
5
|
-
export function useComments({ commentsBaseUrl, objectId, limit = 10, parentCommentId, }) {
|
|
5
|
+
export function useComments({ commentsBaseUrl, objectId, limit = 10, parentCommentId, accessToken, }) {
|
|
6
6
|
const [loading, setLoading] = useState(false);
|
|
7
7
|
const [page, setPage] = useState(1);
|
|
8
8
|
const [totalCount, setTotalCount] = useState(0);
|
|
@@ -16,7 +16,7 @@ export function useComments({ commentsBaseUrl, objectId, limit = 10, parentComme
|
|
|
16
16
|
objectId,
|
|
17
17
|
...(parentCommentId ? { parentCommentId } : {}),
|
|
18
18
|
});
|
|
19
|
-
authAxiosInstance
|
|
19
|
+
authAxiosInstance(accessToken)
|
|
20
20
|
.get(`${commentsBaseUrl}?${params.toString()}`)
|
|
21
21
|
.then((response) => {
|
|
22
22
|
const { data, totalCount: tc, totalPages: tp } = response.data;
|
|
@@ -27,7 +27,7 @@ export function useComments({ commentsBaseUrl, objectId, limit = 10, parentComme
|
|
|
27
27
|
.finally(() => {
|
|
28
28
|
setLoading(false);
|
|
29
29
|
});
|
|
30
|
-
}, [commentsBaseUrl, limit, objectId, page]);
|
|
30
|
+
}, [commentsBaseUrl, limit, objectId, page, accessToken]);
|
|
31
31
|
const pushNewComment = (comment) => {
|
|
32
32
|
setComments((prev) => {
|
|
33
33
|
if (comment.isReply && !parentCommentId) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CONSTANTS } from "sea-platform-helpers";
|
|
2
2
|
import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
|
|
3
|
-
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath, _onForegroundMessage, _onGetToken, }: Readonly<{
|
|
3
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath, _onForegroundMessage, _onGetToken, accessToken, }: Readonly<{
|
|
4
4
|
config: FirebaseConfig;
|
|
5
5
|
updateFirebaseTokenUrl: string;
|
|
6
6
|
applicationKey: CONSTANTS.Application.ApplicationKeys;
|
|
7
7
|
firebaseSWPath?: string;
|
|
8
8
|
_onForegroundMessage?: (notification: NotificationPayload) => void;
|
|
9
9
|
_onGetToken?: (token: string) => void;
|
|
10
|
+
accessToken?: string;
|
|
10
11
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,sBAAsB,EACtB,cAAc,EACd,cAA4C,EAC5C,oBAAoB,EACpB,WAAW,EACX,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,2CA8BD"}
|
|
@@ -6,25 +6,26 @@ import { CONSTANTS } from "sea-platform-helpers";
|
|
|
6
6
|
import { getCookie } from "../../utils/cookie";
|
|
7
7
|
import { initFirebase, requestForToken, onForegroundMessage, } from "../../utils/firebase-client";
|
|
8
8
|
import * as NotificationLocalStorageUtils from "../../utils/notification-localstorage";
|
|
9
|
-
|
|
10
|
-
headers: {
|
|
11
|
-
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath = "/firebase-messaging-sw.js", _onForegroundMessage, _onGetToken, }) {
|
|
9
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath = "/firebase-messaging-sw.js", _onForegroundMessage, _onGetToken, accessToken, }) {
|
|
15
10
|
useEffect(() => {
|
|
16
11
|
initFirebase(config);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
if (accessToken) {
|
|
13
|
+
requestForToken(config.vapidKey, firebaseSWPath).then((token) => {
|
|
14
|
+
if (token) {
|
|
15
|
+
axios.put(updateFirebaseTokenUrl, { token, applicationKey }, {
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
_onGetToken && _onGetToken(token);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
onForegroundMessage((notification) => {
|
|
24
|
+
console.log("Foreground notification:", notification);
|
|
25
|
+
NotificationLocalStorageUtils.pushNewNotificationId(notification.id);
|
|
26
|
+
_onForegroundMessage && _onForegroundMessage(notification);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
28
29
|
}, [config]);
|
|
29
30
|
return _jsx(_Fragment, {});
|
|
30
31
|
}
|
|
@@ -5,6 +5,7 @@ export type Props = {
|
|
|
5
5
|
objectId: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
renderLogActivityItem?: (logActivity: DTO.Activity.IActivity) => React.ReactNode;
|
|
8
|
+
accessToken?: string;
|
|
8
9
|
};
|
|
9
|
-
export default function LogActivitiesContainer({ logActivitiesBaseUrl, objectId, limit, renderLogActivityItem, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function LogActivitiesContainer({ logActivitiesBaseUrl, objectId, limit, renderLogActivityItem, accessToken, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/log-activities-container/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAGhD,MAAM,MAAM,KAAK,GAAG;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,CACtB,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,KAChC,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,oBAAoB,EACpB,QAAQ,EACR,KAAU,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/log-activities-container/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAGhD,MAAM,MAAM,KAAK,GAAG;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,CACtB,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,KAChC,KAAK,CAAC,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,oBAAoB,EACpB,QAAQ,EACR,KAAU,EACV,qBAAqB,EACrB,WAAW,GACZ,EAAE,KAAK,2CAcP"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import LogActivitiesList from "./log-activities-list";
|
|
4
4
|
import LogActivityItem from "./log-activity-item";
|
|
5
|
-
export default function LogActivitiesContainer({ logActivitiesBaseUrl, objectId, limit = 10, renderLogActivityItem, }) {
|
|
5
|
+
export default function LogActivitiesContainer({ logActivitiesBaseUrl, objectId, limit = 10, renderLogActivityItem, accessToken, }) {
|
|
6
6
|
return (_jsx(LogActivitiesList, { logActivitiesBaseUrl: logActivitiesBaseUrl, objectId: objectId, limit: limit, renderLogActivityItem: renderLogActivityItem
|
|
7
7
|
? renderLogActivityItem
|
|
8
|
-
: (activity) => _jsx(LogActivityItem, { activity: activity }) }));
|
|
8
|
+
: (activity) => _jsx(LogActivityItem, { activity: activity }), accessToken: accessToken }));
|
|
9
9
|
}
|
|
@@ -5,7 +5,8 @@ type Props = {
|
|
|
5
5
|
objectId: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
renderLogActivityItem?: (logActivity: DTO.Activity.IActivity) => React.ReactNode;
|
|
8
|
+
accessToken?: string;
|
|
8
9
|
};
|
|
9
|
-
export default function LogActivitiesList({ logActivitiesBaseUrl, objectId, limit, renderLogActivityItem, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function LogActivitiesList({ logActivitiesBaseUrl, objectId, limit, renderLogActivityItem, accessToken, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/log-activities-list/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAGhD,KAAK,KAAK,GAAG;IACX,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,CACtB,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,KAChC,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,QAAQ,EACR,KAAU,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/log-activities-list/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAGhD,KAAK,KAAK,GAAG;IACX,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,CACtB,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,KAChC,KAAK,CAAC,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,QAAQ,EACR,KAAU,EACV,qBAAqB,EACrB,WAAW,GACZ,EAAE,KAAK,2CA8DP"}
|
|
@@ -5,8 +5,10 @@ import Button from "../../button";
|
|
|
5
5
|
import { useLogActivities } from "../use-log-activities";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import LogActivityItem from "../log-activity-item";
|
|
8
|
-
export default function LogActivitiesList({ logActivitiesBaseUrl, objectId, limit = 10, renderLogActivityItem, }) {
|
|
9
|
-
const { logActivities, loading, totalCount, loadMoreLogActivities, hasMoreLogActivities, } = useLogActivities({ logActivitiesBaseUrl, objectId, limit });
|
|
8
|
+
export default function LogActivitiesList({ logActivitiesBaseUrl, objectId, limit = 10, renderLogActivityItem, accessToken, }) {
|
|
9
|
+
const { logActivities, loading, totalCount, loadMoreLogActivities, hasMoreLogActivities, } = useLogActivities({ logActivitiesBaseUrl, objectId, limit, accessToken });
|
|
10
|
+
if (!accessToken)
|
|
11
|
+
return (_jsx("p", { className: "text-gray-500 text-sm text-center py-4", children: "Access token is required to view activities" }));
|
|
10
12
|
return (_jsx("div", { className: clsx("flex flex-col gap-3"), children: logActivities.length === 0 && !loading ? (_jsx("p", { className: "text-gray-500 text-sm text-center py-4", children: "There are no activities yet" })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex flex-col gap-3", children: logActivities.map((logActivity) => renderLogActivityItem ? (renderLogActivityItem(logActivity)) : (_jsx(LogActivityItem, { activity: logActivity }, logActivity.id))) }), loading && (_jsx("div", { className: "flex flex-col gap-3", children: Array(3)
|
|
11
13
|
.fill(null)
|
|
12
14
|
.map((_, i) => (_jsx(Skeleton, { className: "h-20 w-full rounded-lg" }, `logActivity-loading-${i}`))) })), hasMoreLogActivities && !loading && (_jsx("div", { className: clsx("flex justify-center mt-2"), children: _jsx(Button, { type: "button", onClick: loadMoreLogActivities, variant: "secondary", children: "Load More" }) }))] })) }));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DTO } from "sea-platform-helpers";
|
|
2
|
-
export declare function useLogActivities({ logActivitiesBaseUrl, objectId, limit, }: {
|
|
2
|
+
export declare function useLogActivities({ logActivitiesBaseUrl, objectId, limit, accessToken, }: {
|
|
3
3
|
logActivitiesBaseUrl: string;
|
|
4
4
|
objectId: string;
|
|
5
5
|
limit?: number;
|
|
6
|
+
accessToken?: string;
|
|
6
7
|
}): {
|
|
7
8
|
logActivities: DTO.Activity.IActivity[];
|
|
8
9
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/use-log-activities/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,gBAAgB,CAAC,EAC/B,oBAAoB,EACpB,QAAQ,EACR,KAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/log-activities-container/use-log-activities/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAS,MAAM,sBAAsB,CAAC;AAGlD,wBAAgB,gBAAgB,CAAC,EAC/B,oBAAoB,EACpB,QAAQ,EACR,KAAU,EACV,WAAW,GACZ,EAAE;IACD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;EAyDA"}
|
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { Utils } from "sea-platform-helpers";
|
|
4
4
|
import { authAxiosInstance } from "../../../utils/auth-axios";
|
|
5
|
-
export function useLogActivities({ logActivitiesBaseUrl, objectId, limit = 10, }) {
|
|
5
|
+
export function useLogActivities({ logActivitiesBaseUrl, objectId, limit = 10, accessToken, }) {
|
|
6
6
|
const [loading, setLoading] = useState(false);
|
|
7
7
|
const [page, setPage] = useState(1);
|
|
8
8
|
const [totalCount, setTotalCount] = useState(0);
|
|
9
9
|
const [totalPages, setTotalPages] = useState(1);
|
|
10
10
|
const [logActivities, setLogActivities] = useState([]);
|
|
11
11
|
useEffect(() => {
|
|
12
|
+
if (!accessToken)
|
|
13
|
+
return;
|
|
12
14
|
setLoading(true);
|
|
13
15
|
const params = new URLSearchParams({
|
|
14
16
|
page: String(page),
|
|
15
17
|
limit: String(limit),
|
|
16
18
|
objectId,
|
|
17
19
|
});
|
|
18
|
-
authAxiosInstance
|
|
20
|
+
authAxiosInstance(accessToken)
|
|
19
21
|
.get(`${logActivitiesBaseUrl}?${params.toString()}`)
|
|
20
22
|
.then((response) => {
|
|
21
23
|
const { data, totalCount: tc, totalPages: tp } = response.data;
|
|
@@ -26,7 +28,7 @@ export function useLogActivities({ logActivitiesBaseUrl, objectId, limit = 10, }
|
|
|
26
28
|
.finally(() => {
|
|
27
29
|
setLoading(false);
|
|
28
30
|
});
|
|
29
|
-
}, [logActivitiesBaseUrl, limit, objectId, page]);
|
|
31
|
+
}, [logActivitiesBaseUrl, limit, objectId, page, accessToken]);
|
|
30
32
|
const loadMoreLogActivities = () => {
|
|
31
33
|
setPage((prev) => Math.min(prev + 1, totalPages));
|
|
32
34
|
};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type Props = {
|
|
2
|
+
defaultLogoutPath?: string;
|
|
3
|
+
};
|
|
4
|
+
export default function NotAuthorized({ defaultLogoutPath }: Props): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export {};
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/not-authorized/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/not-authorized/index.tsx"],"names":[],"mappings":"AACA,KAAK,KAAK,GAAG;IACX,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,iBAAiB,EAAE,EAAE,KAAK,2CA6EjE"}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Icon from "../icon";
|
|
3
|
-
export default function NotAuthorized() {
|
|
4
|
-
|
|
3
|
+
export default function NotAuthorized({ defaultLogoutPath }) {
|
|
4
|
+
function goToLogout() {
|
|
5
|
+
// Get the current pathname: "/student-attendance/faculty/today"
|
|
6
|
+
const pathname = window.location.pathname;
|
|
7
|
+
const isLocalhost = pathname.includes("localhost");
|
|
8
|
+
if (isLocalhost) {
|
|
9
|
+
window.location.href = "/logout";
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// optional special case for logging out from the root path (e.g., "/")
|
|
13
|
+
if (defaultLogoutPath && !isLocalhost) {
|
|
14
|
+
window.location.href = defaultLogoutPath;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
// Production logic to determine logout path:
|
|
18
|
+
// Split by '/' and get the first two segments: ["", "student-attendance", "faculty", "today"]
|
|
19
|
+
const segments = pathname.split("/");
|
|
20
|
+
// Output: ["", "student-attendance", "faculty", "today"]
|
|
21
|
+
// ↑
|
|
22
|
+
// Empty string at index 0
|
|
23
|
+
const basePath = "/" + segments[1]; // "/student-attendance"
|
|
24
|
+
// Navigate to logout (go up one level from faculty)
|
|
25
|
+
window.location.href = basePath + "/logout";
|
|
26
|
+
// Results in: /student-attendance/logout
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center min-h-screen px-6 text-center space-y-10", children: [_jsx(Icon, { icon: "fluent-mdl2:protect-restrict", className: "text-warning text-opacity-80 h-48 w-48 md:h-56 md:w-56" }), _jsxs("div", { className: "max-w-xl space-y-4", children: [_jsx("h1", { className: "text-3xl md:text-4xl font-bold text-warning", children: "Not Authorized" }), _jsxs("p", { className: "text-base text-text md:text-lg text-muted-foreground", children: ["You don\u2019t have the necessary permissions to access this page. ", _jsx("br", {}), "Please contact your administrator if you believe this is a mistake."] })] }), _jsx("p", { className: "text-sm md:text-base text-muted-foreground", children: "\u2014 or \u2014" }), _jsxs("div", { className: "flex flex-wrap justify-center gap-4", children: [_jsxs("button", { type: "button", onClick: () => window.history.back(), className: "flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-white text-sm md:text-base font-medium shadow hover:bg-primary/90 transition", children: [_jsx(Icon, { icon: "material-symbols:arrow-back-rounded" }), "Go Back"] }), _jsxs("button", { type: "button", onClick: goToLogout, className: "flex items-center gap-2 rounded-xl bg-error px-5 py-2.5 text-white text-sm md:text-base font-medium shadow hover:bg-error/90 transition", children: [_jsx(Icon, { icon: "material-symbols:logout-rounded" }), "Logout"] })] })] }));
|
|
5
30
|
}
|
|
@@ -5,6 +5,7 @@ export type Props = {
|
|
|
5
5
|
notificationBaseUrl: string;
|
|
6
6
|
applicationsBaseUrls: Partial<Record<CONSTANTS.Application.ApplicationKeys, string>>;
|
|
7
7
|
navigate?: (to: string) => void;
|
|
8
|
+
accessToken?: string;
|
|
8
9
|
};
|
|
9
|
-
export default function NotificationMenu({ applicationKey, notificationBaseUrl, limit, applicationsBaseUrls, navigate, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function NotificationMenu({ applicationKey, notificationBaseUrl, limit, applicationsBaseUrls, navigate, accessToken, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAY7D,MAAM,MAAM,KAAK,GAAG;IAClB,cAAc,EACV,SAAS,CAAC,WAAW,CAAC,eAAe,GACrC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAC3B,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CACtD,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,cAAc,EACd,mBAAmB,EACnB,KAAyC,EACzC,oBAAoB,EACpB,QAAQ,EACR,WAAW,GACZ,EAAE,KAAK,2CAocP"}
|