@edifice.io/react 2.6.7 → 2.6.8-develop-pedago.20261008121224
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/Alert/Alert.js +47 -23
- package/dist/components/AppIcon/AppIcon.js +11 -5
- package/dist/components/Form/FormText.js +11 -6
- package/dist/components/Image/Image.js +5 -2
- package/dist/components/Input/Input.d.ts +11 -2
- package/dist/components/Input/Input.js +43 -21
- package/dist/components/Label/Label.js +4 -4
- package/dist/components/Layout/Layout.js +15 -11
- package/dist/components/LinkPill/LinkPill.d.ts +41 -0
- package/dist/components/LinkPill/LinkPill.js +28 -0
- package/dist/components/LinkPill/index.d.ts +2 -0
- package/dist/components/ModalBeta/ModalBeta.d.ts +47 -0
- package/dist/components/ModalBeta/ModalBeta.js +62 -0
- package/dist/components/ModalBeta/ModalBetaBody.d.ts +19 -0
- package/dist/components/ModalBeta/ModalBetaBody.js +15 -0
- package/dist/components/ModalBeta/ModalBetaContext.d.ts +7 -0
- package/dist/components/ModalBeta/ModalBetaContext.js +15 -0
- package/dist/components/ModalBeta/ModalBetaFooter.d.ts +13 -0
- package/dist/components/ModalBeta/ModalBetaFooter.js +7 -0
- package/dist/components/ModalBeta/ModalBetaHeader.d.ts +23 -0
- package/dist/components/ModalBeta/ModalBetaHeader.js +31 -0
- package/dist/components/ModalBeta/index.d.ts +2 -0
- package/dist/components/PageLayout/PageLayout.d.ts +4 -0
- package/dist/components/PageLayout/PageLayout.js +37 -14
- package/dist/components/PageLayout/components/PageLayoutContent.js +5 -1
- package/dist/components/PageLayout/components/PageLayoutHelpZone.d.ts +12 -0
- package/dist/components/PageLayout/components/PageLayoutHelpZone.js +6 -0
- package/dist/components/Table/components/Table.d.ts +2 -2
- package/dist/components/Table/components/TableTd.d.ts +1 -1
- package/dist/components/Table/components/TableTh.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/homepage.js +14 -2
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useBackground/index.d.ts +1 -0
- package/dist/hooks/useBackground/useBackground.d.ts +8 -0
- package/dist/hooks/useBackground/useBackground.js +18 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +3 -2
- package/dist/hooks/useToast/useToast.d.ts +1 -0
- package/dist/hooks/useToast/useToast.js +12 -9
- package/dist/hooks/useUserPreferences/index.d.ts +1 -0
- package/dist/hooks/useUserPreferences/useUserPreferences.d.ts +9 -0
- package/dist/hooks/useUserPreferences/useUserPreferences.js +40 -0
- package/dist/hooks/useZendeskGuide/useZendeskGuide.d.ts +14 -2
- package/dist/hooks/useZendeskGuide/useZendeskGuide.js +51 -24
- package/dist/index.js +168 -160
- package/dist/modules/HelpZone/HelpZone.d.ts +13 -0
- package/dist/modules/HelpZone/HelpZone.js +52 -0
- package/dist/modules/HelpZone/HelpZoneContainer.d.ts +4 -0
- package/dist/modules/HelpZone/HelpZoneContainer.js +18 -0
- package/dist/modules/HelpZone/index.d.ts +3 -0
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
- package/dist/modules/homepage/components/Communities/Communities.d.ts +2 -1
- package/dist/modules/homepage/components/Communities/Communities.js +14 -13
- package/dist/modules/homepage/components/Communities/CommunitiesContainer.d.ts +1 -1
- package/dist/modules/homepage/components/Communities/CommunitiesContainer.js +9 -5
- package/dist/modules/homepage/components/Communities/CommunitiesSkeleton.js +4 -7
- package/dist/modules/homepage/components/Communities/useCommunities.d.ts +4 -1
- package/dist/modules/homepage/components/Communities/useCommunities.js +8 -3
- package/dist/modules/homepage/components/Favorites/Favorites.js +2 -2
- package/dist/modules/homepage/components/Header/Header.js +11 -4
- package/dist/modules/homepage/components/HomeCard/HomeCard.d.ts +1 -1
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.d.ts +15 -1
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +3 -2
- package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.js +36 -26
- package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.js +1 -1
- package/dist/modules/homepage/components/Notifications/services/queries/notification.js +9 -2
- package/dist/modules/homepage/components/UsefulLinks/LinkForm.d.ts +13 -0
- package/dist/modules/homepage/components/UsefulLinks/LinkForm.js +67 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinks.d.ts +6 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinks.js +31 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksContainer.d.ts +1 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksContainer.js +40 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksModal.d.ts +11 -0
- package/dist/modules/homepage/components/UsefulLinks/UsefulLinksModal.js +65 -0
- package/dist/modules/homepage/components/UsefulLinks/hooks/useUsefulLinksContainer.d.ts +19 -0
- package/dist/modules/homepage/components/UsefulLinks/hooks/useUsefulLinksContainer.js +26 -0
- package/dist/modules/homepage/components/UsefulLinks/index.d.ts +5 -0
- package/dist/modules/homepage/components/UsefulLinks/services/api/index.d.ts +6 -0
- package/dist/modules/homepage/components/UsefulLinks/services/api/index.js +5 -0
- package/dist/modules/homepage/components/UsefulLinks/services/api/usefulLinksService.d.ts +31 -0
- package/dist/modules/homepage/components/UsefulLinks/services/api/usefulLinksService.js +50 -0
- package/dist/modules/homepage/components/UsefulLinks/services/queries/usefulLinks.d.ts +20 -0
- package/dist/modules/homepage/components/UsefulLinks/services/queries/usefulLinks.js +65 -0
- package/dist/modules/homepage/components/UserSpace/hooks/useProfileLinks.js +18 -8
- package/dist/modules/homepage/components/index.d.ts +1 -0
- package/dist/modules/icons/components/logo/IconLogoEdificeFull.d.ts +7 -0
- package/dist/modules/icons/components/logo/IconLogoEdificeFull.js +26 -0
- package/dist/modules/icons/components/logo/IconLogoEdificeSmall.d.ts +7 -0
- package/dist/modules/icons/components/logo/IconLogoEdificeSmall.js +17 -0
- package/dist/modules/icons/components/logo/index.d.ts +2 -0
- package/dist/modules/widgets/index.d.ts +1 -1
- package/package.json +6 -6
|
@@ -2,9 +2,10 @@ import { CommunityItemProps } from './CommunityItem';
|
|
|
2
2
|
export interface CommunitiesProps {
|
|
3
3
|
communitiesList?: CommunityItemProps[];
|
|
4
4
|
handleActionClick: () => void;
|
|
5
|
+
canCreateCommunity?: boolean;
|
|
5
6
|
}
|
|
6
7
|
declare const Communities: {
|
|
7
|
-
({ communitiesList, handleActionClick, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
({ communitiesList, handleActionClick, canCreateCommunity, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
displayName: string;
|
|
9
10
|
};
|
|
10
11
|
export default Communities;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import illuCommunities from "@edifice.io/bootstrap/dist/images/homepage/illu-communities.svg";
|
|
3
|
-
import { useMeasure } from "@uidotdev/usehooks";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
5
4
|
import SvgIconArrowRight from "../../../icons/components/IconArrowRight.js";
|
|
6
5
|
import CommunityItem from "./CommunityItem.js";
|
|
7
6
|
import HomeCard from "../HomeCard/HomeCard.js";
|
|
8
7
|
import Flex from "../../../../components/Flex/Flex.js";
|
|
9
8
|
import Image from "../../../../components/Image/Image.js";
|
|
10
|
-
const
|
|
9
|
+
const Communities = ({
|
|
11
10
|
communitiesList = [],
|
|
12
|
-
handleActionClick
|
|
11
|
+
handleActionClick,
|
|
12
|
+
canCreateCommunity = !1
|
|
13
13
|
}) => {
|
|
14
14
|
const {
|
|
15
15
|
t
|
|
16
|
-
} = useTranslation()
|
|
17
|
-
width
|
|
18
|
-
}] = useMeasure(), maxItems = width !== null && width < NARROW_CONTAINER_WIDTH ? MAX_ITEMS_NARROW : MAX_ITEMS, visibleCommunities = communitiesList.slice(0, maxItems), itemWidth = `${100 / maxItems}%`;
|
|
16
|
+
} = useTranslation();
|
|
19
17
|
return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
|
|
20
|
-
/* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 ? t("homepage.communities.actionLabel.seeMore") : t("homepage.communities.actionLabel.create"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title") }),
|
|
21
|
-
/* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, {
|
|
18
|
+
/* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 || !canCreateCommunity ? t("homepage.communities.actionLabel.seeMore", "Voir plus") : t("homepage.communities.actionLabel.create", "Créer une communauté"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title", "Mes communautés") }),
|
|
19
|
+
/* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: communitiesList.length > 0 ? /* @__PURE__ */ jsx("div", { className: "communities-list", children: communitiesList.map((community, index) => /* @__PURE__ */ jsx(CommunityItem, { title: community.title, communityImage: community.communityImage, onActionClick: community.onActionClick, nbNotifications: community.nbNotifications, width: "auto" }, index)) }) : /* @__PURE__ */ jsxs("div", { className: "communities-empty", children: [
|
|
22
20
|
/* @__PURE__ */ jsx(Image, { src: illuCommunities, alt: "", "aria-hidden": "true", style: {
|
|
23
21
|
width: 80,
|
|
24
22
|
height: 80
|
|
25
23
|
} }),
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle", "
|
|
28
|
-
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description", "
|
|
29
|
-
] })
|
|
24
|
+
/* @__PURE__ */ jsx("div", { className: "communities-empty-content", children: canCreateCommunity ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.teacher", "Réunissez vos élèves avec Communautés !") }),
|
|
26
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.teacher", "Centralisez et organisez les documents et les ressources pour vos groupes d'élèves.") })
|
|
27
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.student", "Retrouvez toutes vos communautés ici ! ") }),
|
|
29
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.student", `Consultez l'onglet "Nouveaux partages" pour découvrir si vous avez été ajouté à une nouvelle communauté.`) })
|
|
30
|
+
] }) })
|
|
30
31
|
] }) }) })
|
|
31
32
|
] });
|
|
32
33
|
};
|
|
@@ -5,7 +5,7 @@ export type CommunitiesContainerProps = {
|
|
|
5
5
|
/** Handle a click on the header action button. If undefined, communities (or the community creation flow) will be opened. */
|
|
6
6
|
onHeaderActionClick?: () => void;
|
|
7
7
|
};
|
|
8
|
-
export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities.";
|
|
8
|
+
export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities." | null;
|
|
9
9
|
export declare namespace CommunitiesContainer {
|
|
10
10
|
var displayName: string;
|
|
11
11
|
}
|
|
@@ -3,28 +3,32 @@ import { useCallback, useMemo } from "react";
|
|
|
3
3
|
import Communities from "./Communities.js";
|
|
4
4
|
import CommunitiesSkeleton from "./CommunitiesSkeleton.js";
|
|
5
5
|
import { useCommunities } from "./useCommunities.js";
|
|
6
|
+
import useHasWorkflow from "../../../../hooks/useHasWorkflow/useHasWorkflow.js";
|
|
7
|
+
const COMMUNITY_ACCESS_WORKFLOW = "community.access", COMMUNITY_CREATE_WORKFLOW = "community.create", COMMUNITY_WORKFLOWS = [COMMUNITY_ACCESS_WORKFLOW, COMMUNITY_CREATE_WORKFLOW];
|
|
6
8
|
function CommunitiesContainer({
|
|
7
9
|
onCommunityClick: handleCommunityClick = (community) => {
|
|
8
10
|
window.open(`/communities/id/${community.id}/home`, "_self");
|
|
9
11
|
},
|
|
10
12
|
onHeaderActionClick: handleHeaderActionClick
|
|
11
13
|
}) {
|
|
12
|
-
const {
|
|
14
|
+
const rights = useHasWorkflow(COMMUNITY_WORKFLOWS), canCreateCommunity = (rights == null ? void 0 : rights[COMMUNITY_CREATE_WORKFLOW]) === !0, hasCommunitiesRight = canCreateCommunity || (rights == null ? void 0 : rights[COMMUNITY_ACCESS_WORKFLOW]) === !0, {
|
|
13
15
|
communities,
|
|
14
16
|
isLoading,
|
|
15
17
|
error
|
|
16
|
-
} = useCommunities(
|
|
18
|
+
} = useCommunities({
|
|
19
|
+
enabled: hasCommunitiesRight
|
|
20
|
+
}), handleActionClick = useCallback(() => {
|
|
17
21
|
if (handleHeaderActionClick) {
|
|
18
22
|
handleHeaderActionClick();
|
|
19
23
|
return;
|
|
20
24
|
}
|
|
21
|
-
window.open(communities.length
|
|
22
|
-
}, [handleHeaderActionClick, communities.length]), mappedCommunities = useMemo(() => communities.map((community) => ({
|
|
25
|
+
window.open(communities.length === 0 && canCreateCommunity ? "/communities/create/step-type" : "/communities", "_self");
|
|
26
|
+
}, [handleHeaderActionClick, communities.length, canCreateCommunity]), mappedCommunities = useMemo(() => communities.map((community) => ({
|
|
23
27
|
title: community.title,
|
|
24
28
|
communityImage: community.image ?? "",
|
|
25
29
|
onActionClick: () => handleCommunityClick(community)
|
|
26
30
|
})), [communities, handleCommunityClick]);
|
|
27
|
-
return isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick });
|
|
31
|
+
return rights === void 0 || isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : hasCommunitiesRight ? error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick, canCreateCommunity }) : null;
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
34
|
CommunitiesContainer
|
|
@@ -3,17 +3,14 @@ import HomeCard from "../HomeCard/HomeCard.js";
|
|
|
3
3
|
import Flex from "../../../../components/Flex/Flex.js";
|
|
4
4
|
import TextSkeleton from "../../../../components/Skeleton/TextSkeleton.js";
|
|
5
5
|
import ButtonSkeleton from "../../../../components/Skeleton/ButtonSkeleton.js";
|
|
6
|
-
const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
|
|
6
|
+
const primaryTitleWidths = ["80%", "64%", "88%", "72%", "76%", "68%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%", "52%", "40%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
|
|
7
7
|
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: "home-card-header", children: [
|
|
8
8
|
/* @__PURE__ */ jsx(TextSkeleton, { size: "lg", className: "col-5" }),
|
|
9
9
|
/* @__PURE__ */ jsx(ButtonSkeleton, { "aria-hidden": "true", size: "sm", className: "px-24", color: "tertiary" })
|
|
10
10
|
] }),
|
|
11
|
-
/* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item",
|
|
12
|
-
width: "25%"
|
|
13
|
-
}, "aria-hidden": "true", children: [
|
|
11
|
+
/* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: /* @__PURE__ */ jsx("div", { className: "communities-list", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item", "aria-hidden": "true", children: [
|
|
14
12
|
/* @__PURE__ */ jsx("div", { className: "communities-item-image placeholder rounded", style: {
|
|
15
|
-
display: "block"
|
|
16
|
-
aspectRatio: "1 / 1"
|
|
13
|
+
display: "block"
|
|
17
14
|
} }),
|
|
18
15
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", className: "mt-8", children: [
|
|
19
16
|
/* @__PURE__ */ jsx("div", { style: {
|
|
@@ -25,7 +22,7 @@ const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths =
|
|
|
25
22
|
alignSelf: "center"
|
|
26
23
|
}, children: /* @__PURE__ */ jsx(TextSkeleton, { className: "col-12", size: "sm" }) })
|
|
27
24
|
] })
|
|
28
|
-
] }, primaryWidth)) }) })
|
|
25
|
+
] }, primaryWidth)) }) }) })
|
|
29
26
|
] });
|
|
30
27
|
export {
|
|
31
28
|
CommunitiesSkeleton as default
|
|
@@ -3,7 +3,10 @@ export interface CommunitiesModel {
|
|
|
3
3
|
title: string;
|
|
4
4
|
image?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare
|
|
6
|
+
export declare const COMMUNITIES_PREVIEW_SIZE = 6;
|
|
7
|
+
export declare function useCommunities({ enabled }?: {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}): {
|
|
7
10
|
communities: CommunitiesModel[];
|
|
8
11
|
isLoading: boolean;
|
|
9
12
|
error: Error | null;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { odeServices } from "@edifice.io/client";
|
|
2
2
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
3
|
-
|
|
3
|
+
const COMMUNITIES_PREVIEW_SIZE = 6;
|
|
4
|
+
function useCommunities({
|
|
5
|
+
enabled = !0
|
|
6
|
+
} = {}) {
|
|
4
7
|
const {
|
|
5
8
|
data,
|
|
6
9
|
isLoading,
|
|
@@ -8,11 +11,12 @@ function useCommunities() {
|
|
|
8
11
|
} = useQuery(queryOptions({
|
|
9
12
|
queryKey: ["communities", "preview"],
|
|
10
13
|
queryFn: async () => {
|
|
11
|
-
const http = odeServices.http(), response = await http.get(
|
|
14
|
+
const http = odeServices.http(), response = await http.get(`/communities/api/communities?page=1&size=${COMMUNITIES_PREVIEW_SIZE}`);
|
|
12
15
|
if (http.isResponseError())
|
|
13
16
|
throw new Error(http.latestResponse.statusText);
|
|
14
17
|
return response.items;
|
|
15
|
-
}
|
|
18
|
+
},
|
|
19
|
+
enabled
|
|
16
20
|
}));
|
|
17
21
|
return {
|
|
18
22
|
communities: data ?? [],
|
|
@@ -21,5 +25,6 @@ function useCommunities() {
|
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
export {
|
|
28
|
+
COMMUNITIES_PREVIEW_SIZE,
|
|
24
29
|
useCommunities
|
|
25
30
|
};
|
|
@@ -16,10 +16,10 @@ function Favorites({
|
|
|
16
16
|
sensitivity: "base"
|
|
17
17
|
})), [apps, t]);
|
|
18
18
|
return /* @__PURE__ */ jsxs(HomeCard, { variant: "secondary", children: [
|
|
19
|
-
/* @__PURE__ */ jsx(HomeCard.Header, { title: t("homepage.favorites.title"
|
|
19
|
+
/* @__PURE__ */ jsx(HomeCard.Header, { title: t("homepage.favorites.title"), actionLabel: t("homepage.favorites.all"), onActionClick: onSeeAllClick, actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}) }),
|
|
20
20
|
/* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx("div", { className: "favorites-content", children: visibleApps.length === 0 ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "12", children: [
|
|
21
21
|
/* @__PURE__ */ jsx("img", { src: illuEmptyFavorite, alt: "", width: 50, height: 50 }),
|
|
22
|
-
/* @__PURE__ */ jsx("span", { className: "favorites-empty-text", children: t("homepage.favorites.empty"
|
|
22
|
+
/* @__PURE__ */ jsx("span", { className: "favorites-empty-text", children: t("homepage.favorites.empty") })
|
|
23
23
|
] }) : /* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "8 16", children: visibleApps.map((app) => {
|
|
24
24
|
const appName = getAppName(app), opensInNewTab = app.isExternal || app.target === "_blank";
|
|
25
25
|
return /* @__PURE__ */ jsx("a", { href: app.address, "aria-label": appName, title: appName, target: opensInNewTab ? "_blank" : void 0, rel: opensInNewTab ? "noopener noreferrer" : void 0, children: /* @__PURE__ */ jsx(AppIcon, { app, size: "40", variant: "square" }) }, app.name);
|
|
@@ -6,6 +6,7 @@ import { Navbar } from "../../../../components/Layout/components/Navbar.js";
|
|
|
6
6
|
import { NavItem } from "../../../../components/Layout/components/NavItem.js";
|
|
7
7
|
import { NavLink } from "../../../../components/Layout/components/NavLink.js";
|
|
8
8
|
import useHeader from "../../../../components/Layout/hooks/useHeader.js";
|
|
9
|
+
import SvgIconSetBackground from "../../../icons/components/IconSetBackground.js";
|
|
9
10
|
import SvgIconCommunitiesBeta from "../../../icons/components/nav/IconCommunitiesBeta.js";
|
|
10
11
|
import SvgIconDisconnect from "../../../icons/components/nav/IconDisconnect.js";
|
|
11
12
|
import SvgIconHomeBeta from "../../../icons/components/nav/IconHomeBeta.js";
|
|
@@ -86,10 +87,16 @@ const Header = ({
|
|
|
86
87
|
] }),
|
|
87
88
|
/* @__PURE__ */ jsxs(NavItem, { className: "position-relative", ref: userRef, id: popoverUserId, "aria-haspopup": "true", "aria-expanded": isUserHovered, "data-testid": "header-user-menu-button", children: [
|
|
88
89
|
/* @__PURE__ */ jsx(NavLink, { link: "/userbook/mon-compte", translate: t("navbar.myaccount"), "data-testid": "header-user-profile-button", children: /* @__PURE__ */ jsx(Avatar, { alt: userName, size: "sm", src: userAvatar, variant: "circle", className: "bg-white", width: "32", height: "32" }) }),
|
|
89
|
-
/* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
/* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */ jsxs(PopoverBody, { children: [
|
|
91
|
+
/* @__PURE__ */ jsxs("a", { href: "/timeline/customize?callback=" + encodeURIComponent(`${window.location.pathname}${window.location.search}`), className: "nav-link customize d-flex align-items-center gap-8", "data-testid": "header-customize-button", children: [
|
|
92
|
+
/* @__PURE__ */ jsx(SvgIconSetBackground, { className: "icon" }),
|
|
93
|
+
/* @__PURE__ */ jsx("span", { id: "cutomize-label", className: "nav-text", children: t("navbar.customize") })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link logout d-flex align-items-center gap-8", "data-testid": "header-logout-button", children: [
|
|
96
|
+
/* @__PURE__ */ jsx(SvgIconDisconnect, { className: "icon logout" }),
|
|
97
|
+
/* @__PURE__ */ jsx("span", { id: "logout-label", className: "nav-text", children: t("navbar.disconnect") })
|
|
98
|
+
] })
|
|
99
|
+
] }) })
|
|
93
100
|
] })
|
|
94
101
|
] })
|
|
95
102
|
] }) });
|
|
@@ -30,7 +30,7 @@ declare const HomeCard: {
|
|
|
30
30
|
displayName: string;
|
|
31
31
|
} & {
|
|
32
32
|
Header: {
|
|
33
|
-
({ title, actionLabel, onActionClick, actionLeftIcon, actionRightIcon, className, ...rest }: HomeCardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
({ title, actionLabel, onActionClick, actionLeftIcon, actionRightIcon, actionProps, className, ...rest }: HomeCardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
34
34
|
displayName: string;
|
|
35
35
|
};
|
|
36
36
|
Content: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { ButtonBeta } from '../../../../components';
|
|
2
3
|
export interface HomeCardHeaderProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {
|
|
3
4
|
/** Title displayed on the left side of the header. */
|
|
4
5
|
title: ReactNode;
|
|
@@ -10,9 +11,22 @@ export interface HomeCardHeaderProps extends Omit<ComponentPropsWithoutRef<'div'
|
|
|
10
11
|
actionLeftIcon?: ReactNode;
|
|
11
12
|
/** Optional right icon of the action button. */
|
|
12
13
|
actionRightIcon?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Extra props spread onto the action button (e.g. `data-testid`) — its
|
|
16
|
+
* default `data-testid` (`home-card-header-action`) isn't unique across
|
|
17
|
+
* the several `HomeCard`s a page can render, so consumers doing that
|
|
18
|
+
* should override it here. The `data-*` index signature covers
|
|
19
|
+
* attributes like `data-testid` that `ButtonBetaProps` doesn't declare:
|
|
20
|
+
* TypeScript's built-in allowance for undeclared `data-*`/`aria-*`
|
|
21
|
+
* attributes only applies to attributes written directly on a JSX
|
|
22
|
+
* element, not to a plain object literal passed as a prop value.
|
|
23
|
+
*/
|
|
24
|
+
actionProps?: ComponentPropsWithoutRef<typeof ButtonBeta> & {
|
|
25
|
+
[key: `data-${string}`]: string;
|
|
26
|
+
};
|
|
13
27
|
}
|
|
14
28
|
declare const HomeCardHeader: {
|
|
15
|
-
({ title, actionLabel, onActionClick, actionLeftIcon, actionRightIcon, className, ...rest }: HomeCardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
({ title, actionLabel, onActionClick, actionLeftIcon, actionRightIcon, actionProps, className, ...rest }: HomeCardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
30
|
displayName: string;
|
|
17
31
|
};
|
|
18
32
|
export default HomeCardHeader;
|
|
@@ -8,13 +8,14 @@ const HomeCardHeader = ({
|
|
|
8
8
|
onActionClick,
|
|
9
9
|
actionLeftIcon,
|
|
10
10
|
actionRightIcon,
|
|
11
|
+
actionProps,
|
|
11
12
|
className,
|
|
12
13
|
...rest
|
|
13
14
|
}) => {
|
|
14
15
|
const hasAction = !!actionLabel && !!onActionClick;
|
|
15
|
-
return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: clsx("home-card-header", className), ...rest, children: [
|
|
16
|
+
return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", wrap: "wrap", className: clsx("home-card-header", className), ...rest, children: [
|
|
16
17
|
/* @__PURE__ */ jsx("h3", { className: "home-card-header-title", children: title }),
|
|
17
|
-
hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", children: actionLabel })
|
|
18
|
+
hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, className: "home-card-header-action", leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", ...actionProps, children: actionLabel })
|
|
18
19
|
] });
|
|
19
20
|
};
|
|
20
21
|
export {
|
package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useState, useRef, useMemo, useEffect } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import SvgIconCheck from "../../../../icons/components/IconCheck.js";
|
|
6
6
|
import { getAppCodeAndI18nKey } from "./notificationAdapter.js";
|
|
7
7
|
import Modal from "../../../../../components/Modal/Modal.js";
|
|
8
8
|
import Flex from "../../../../../components/Flex/Flex.js";
|
|
9
|
-
import Checkbox from "../../../../../components/Checkbox/Checkbox.js";
|
|
10
9
|
import AppIcon from "../../../../../components/AppIcon/AppIcon.js";
|
|
11
10
|
import ButtonBeta from "../../../../../components/ButtonBeta/ButtonBeta.js";
|
|
12
11
|
const NotificationFilterModal = ({
|
|
@@ -17,48 +16,59 @@ const NotificationFilterModal = ({
|
|
|
17
16
|
onApply
|
|
18
17
|
}) => {
|
|
19
18
|
const {
|
|
20
|
-
t
|
|
21
|
-
|
|
19
|
+
t,
|
|
20
|
+
i18n
|
|
21
|
+
} = useTranslation(), [selected, setSelected] = useState(appliedTypes), refSelectAllCheckbox = useRef(null), allTypesSorted = useMemo(() => allTypes.map((type) => {
|
|
22
|
+
const [appCode, appI18nKey] = getAppCodeAndI18nKey(type), label = t(appI18nKey, {
|
|
23
|
+
defaultValue: appCode
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
type,
|
|
27
|
+
appCode,
|
|
28
|
+
appI18nKey,
|
|
29
|
+
label
|
|
30
|
+
};
|
|
31
|
+
}).sort((a, b) => a.label.localeCompare(b.label, i18n.language, {
|
|
32
|
+
sensitivity: "base"
|
|
33
|
+
})), [allTypes, t, i18n.language]), toggleType = (type) => {
|
|
22
34
|
setSelected((current) => current.includes(type) ? current.filter((value) => value !== type) : [...current, type]);
|
|
23
35
|
}, toggleAll = () => {
|
|
24
36
|
setSelected(selected.length === allTypes.length ? [] : allTypes);
|
|
25
37
|
};
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/* @__PURE__ */ jsx(Modal.Subtitle, { children: t("homepage.notifications.filter-modal.subtitle",
|
|
31
|
-
defaultValue: "Sélectionnez seulement les notifications importantes pour vous"
|
|
32
|
-
}) }),
|
|
38
|
+
return useEffect(() => {
|
|
39
|
+
refSelectAllCheckbox.current && (refSelectAllCheckbox.current.indeterminate = selected.length > 0 && selected.length < allTypes.length);
|
|
40
|
+
}, [selected.length, allTypes.length]), /* @__PURE__ */ jsxs(Modal, { id: "notification-filter-modal", size: "lg", scrollable: !0, isOpen, onModalClose: onCancel, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("homepage.notifications.filter-modal.title") }),
|
|
42
|
+
/* @__PURE__ */ jsx(Modal.Subtitle, { children: t("homepage.notifications.filter-modal.subtitle") }),
|
|
33
43
|
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
|
34
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", gap: "8", className: "mb-
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", gap: "8", className: "mb-24", children: [
|
|
45
|
+
/* @__PURE__ */ jsxs("label", { className: "notification-filter-select-all notification-filter-chip", children: [
|
|
46
|
+
/* @__PURE__ */ jsx("span", { children: t("homepage.notifications.filter-modal.select-all") }),
|
|
47
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", ref: refSelectAllCheckbox, checked: selected.length === allTypes.length, className: "notification-filter-checkbox", onChange: toggleAll })
|
|
48
|
+
] }),
|
|
38
49
|
/* @__PURE__ */ jsx("span", { className: "notification-filter-count", children: t("homepage.notifications.filter-modal.count", {
|
|
39
50
|
selected: selected.length,
|
|
40
|
-
total: allTypes.length
|
|
41
|
-
defaultValue: "[[selected]] / [[total]] sélectionnées"
|
|
51
|
+
total: allTypes.length
|
|
42
52
|
}) })
|
|
43
53
|
] }),
|
|
44
|
-
/* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "
|
|
45
|
-
|
|
54
|
+
/* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "16", className: "notification-filter-options", children: allTypesSorted.map(({
|
|
55
|
+
type,
|
|
56
|
+
label,
|
|
57
|
+
appCode
|
|
58
|
+
}) => {
|
|
59
|
+
const checked = selected.includes(type);
|
|
46
60
|
return /* @__PURE__ */ jsxs("label", { className: clsx("notification-filter-chip", {
|
|
47
61
|
"is-checked": checked
|
|
48
62
|
}), children: [
|
|
49
63
|
/* @__PURE__ */ jsx(AppIcon, { app: appCode, size: "24", iconFit: "contain" }),
|
|
50
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
51
|
-
|
|
52
|
-
}) }),
|
|
53
|
-
/* @__PURE__ */ jsx("input", { type: "checkbox", className: "form-check-input", checked, onChange: () => toggleType(type) })
|
|
64
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
65
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", className: "notification-filter-checkbox", checked, onChange: () => toggleType(type) })
|
|
54
66
|
] }, type);
|
|
55
67
|
}) })
|
|
56
68
|
] }),
|
|
57
69
|
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
58
70
|
/* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("cancel") }),
|
|
59
|
-
/* @__PURE__ */ jsx(ButtonBeta, { color: "default", onClick: () => onApply(selected), type: "button", variant: "filled", rightIcon: /* @__PURE__ */ jsx(SvgIconCheck, {}), children: t("homepage.notifications.filter-modal.confirm"
|
|
60
|
-
defaultValue: "Enregistrer"
|
|
61
|
-
}) })
|
|
71
|
+
/* @__PURE__ */ jsx(ButtonBeta, { color: "default", onClick: () => onApply(selected), type: "button", variant: "filled", rightIcon: /* @__PURE__ */ jsx(SvgIconCheck, {}), children: t("homepage.notifications.filter-modal.confirm") })
|
|
62
72
|
] })
|
|
63
73
|
] });
|
|
64
74
|
};
|
package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.js
CHANGED
|
@@ -11,7 +11,7 @@ const ReportNotificationModal = ({
|
|
|
11
11
|
const {
|
|
12
12
|
t
|
|
13
13
|
} = useTranslation();
|
|
14
|
-
return /* @__PURE__ */ jsxs(Modal, { id: "report-notification-modal", size: "
|
|
14
|
+
return /* @__PURE__ */ jsxs(Modal, { id: "report-notification-modal", size: "sm", isOpen, onModalClose: onCancel, children: [
|
|
15
15
|
/* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("homepage.notifications.report-modal.title", {
|
|
16
16
|
defaultValue: "Signaler une notification"
|
|
17
17
|
}) }),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { odeServices } from "@edifice.io/client";
|
|
2
2
|
import { useQuery, useInfiniteQuery, useMutation, useQueryClient, queryOptions, infiniteQueryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
3
4
|
import { notificationService } from "../api/index.js";
|
|
5
|
+
import useToast from "../../../../../../hooks/useToast/useToast.js";
|
|
4
6
|
const notificationQueryKeys = {
|
|
5
7
|
all: () => ["notifications"],
|
|
6
8
|
notifications: (types = []) => [...notificationQueryKeys.all(), "list", types],
|
|
@@ -52,7 +54,9 @@ const notificationQueryKeys = {
|
|
|
52
54
|
}, useReportNotification = () => useMutation({
|
|
53
55
|
mutationFn: (id) => notificationService.reportNotification(id)
|
|
54
56
|
}), useDeleteNotification = () => {
|
|
55
|
-
const
|
|
57
|
+
const {
|
|
58
|
+
t
|
|
59
|
+
} = useTranslation(), toast = useToast(), queryClient = useQueryClient();
|
|
56
60
|
return useMutation({
|
|
57
61
|
mutationFn: (id) => notificationService.deleteNotification(id),
|
|
58
62
|
onSuccess: (_data, id) => {
|
|
@@ -61,7 +65,10 @@ const notificationQueryKeys = {
|
|
|
61
65
|
}, (data) => data && {
|
|
62
66
|
...data,
|
|
63
67
|
pages: data.pages.map((page) => page.filter((notification) => notification._id !== id))
|
|
64
|
-
});
|
|
68
|
+
}), toast.success(t("homepage.notifications.options.delete.success"));
|
|
69
|
+
},
|
|
70
|
+
onError: () => {
|
|
71
|
+
toast.error(t("homepage.notifications.options.delete.error"));
|
|
65
72
|
}
|
|
66
73
|
});
|
|
67
74
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UsefulLink, UsefulLinkPayload } from '@edifice.io/client';
|
|
2
|
+
export interface LinkFormProps {
|
|
3
|
+
mode: 'add' | 'edit';
|
|
4
|
+
/** Link being edited. Ignored (and required to be undefined) in "add" mode. */
|
|
5
|
+
link?: UsefulLink;
|
|
6
|
+
isSubmitting: boolean;
|
|
7
|
+
/** Closes the form and goes back to the management modal, without saving. */
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
/** Closes the whole modal stack. */
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onSubmit: (payload: UsefulLinkPayload) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function LinkForm({ mode, link, isSubmitting, onCancel, onClose, onSubmit, }: LinkFormProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
import ModalBeta from "../../../../components/ModalBeta/ModalBeta.js";
|
|
5
|
+
import FormControl from "../../../../components/Form/FormControl.js";
|
|
6
|
+
import Label from "../../../../components/Label/Label.js";
|
|
7
|
+
import Input from "../../../../components/Input/Input.js";
|
|
8
|
+
import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
|
|
9
|
+
const NAME_MAX_LENGTH = 80, URL_PATTERN = /^https?:\/\/.+/i;
|
|
10
|
+
function LinkForm({
|
|
11
|
+
mode,
|
|
12
|
+
link,
|
|
13
|
+
isSubmitting,
|
|
14
|
+
onCancel,
|
|
15
|
+
onClose,
|
|
16
|
+
onSubmit
|
|
17
|
+
}) {
|
|
18
|
+
const {
|
|
19
|
+
t
|
|
20
|
+
} = useTranslation(), formId = "useful-link-form", {
|
|
21
|
+
register,
|
|
22
|
+
handleSubmit,
|
|
23
|
+
formState: {
|
|
24
|
+
errors,
|
|
25
|
+
isDirty,
|
|
26
|
+
isValid
|
|
27
|
+
}
|
|
28
|
+
} = useForm({
|
|
29
|
+
mode: "onChange",
|
|
30
|
+
defaultValues: {
|
|
31
|
+
name: (link == null ? void 0 : link.name) ?? "",
|
|
32
|
+
url: (link == null ? void 0 : link.url) ?? ""
|
|
33
|
+
}
|
|
34
|
+
}), title = t(mode === "add" ? "homepage.usefulLinks.form.addTitle" : "homepage.usefulLinks.form.editTitle"), handleFormSubmit = (data) => {
|
|
35
|
+
onSubmit({
|
|
36
|
+
name: data.name.trim(),
|
|
37
|
+
url: data.url.trim()
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsxs(ModalBeta, { id: "useful-link-modal", isOpen: !0, size: "l", onModalClose: onClose, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(ModalBeta.Header, { onModalClose: onClose, children: title }),
|
|
42
|
+
/* @__PURE__ */ jsx(ModalBeta.Body, { children: /* @__PURE__ */ jsxs("form", { id: formId, onSubmit: handleSubmit(handleFormSubmit), children: [
|
|
43
|
+
/* @__PURE__ */ jsxs(FormControl, { id: "useful-link-name", className: "mb-16", isRequired: !0, children: [
|
|
44
|
+
/* @__PURE__ */ jsx(Label, { children: t("homepage.usefulLinks.form.name") }),
|
|
45
|
+
/* @__PURE__ */ jsx(Input, { type: "text", size: "md", maxLength: NAME_MAX_LENGTH, showCounter: !0, clearable: !0, "data-testid": "usefullinks-input-name", placeholder: t("homepage.usefulLinks.form.name.placeholder"), ...register("name", {
|
|
46
|
+
required: !0,
|
|
47
|
+
maxLength: NAME_MAX_LENGTH
|
|
48
|
+
}) })
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsxs(FormControl, { id: "useful-link-url", isRequired: !0, status: errors.url ? "invalid" : void 0, children: [
|
|
51
|
+
/* @__PURE__ */ jsx(Label, { children: t("homepage.usefulLinks.form.url") }),
|
|
52
|
+
/* @__PURE__ */ jsx(Input, { type: "text", size: "md", "data-testid": "usefullinks-input-url", placeholder: t("homepage.usefulLinks.form.url.placeholder"), ...register("url", {
|
|
53
|
+
required: !0,
|
|
54
|
+
pattern: URL_PATTERN
|
|
55
|
+
}) }),
|
|
56
|
+
errors.url && /* @__PURE__ */ jsx(FormControl.Text, { children: t("homepage.usefulLinks.form.url.error") })
|
|
57
|
+
] })
|
|
58
|
+
] }) }),
|
|
59
|
+
/* @__PURE__ */ jsxs(ModalBeta.Footer, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", "data-testid": "usefullinks-button-cancel", onClick: onCancel, children: t("homepage.usefulLinks.form.cancel") }),
|
|
61
|
+
/* @__PURE__ */ jsx(ButtonBeta, { form: formId, type: "submit", isLoading: isSubmitting, disabled: !isValid || !isDirty || isSubmitting, "data-testid": "usefullinks-button-save", children: t("homepage.usefulLinks.form.save") })
|
|
62
|
+
] })
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
LinkForm
|
|
67
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import illuEmptyUsefulLinks from "@edifice.io/bootstrap/dist/images/homepage/illu-empty-useful-links.png";
|
|
4
|
+
import SvgIconEdit from "../../../icons/components/IconEdit.js";
|
|
5
|
+
import HomeCard from "../HomeCard/HomeCard.js";
|
|
6
|
+
import Image from "../../../../components/Image/Image.js";
|
|
7
|
+
import Flex from "../../../../components/Flex/Flex.js";
|
|
8
|
+
import LinkPill from "../../../../components/LinkPill/LinkPill.js";
|
|
9
|
+
function UsefulLinks({
|
|
10
|
+
links,
|
|
11
|
+
onEditClick
|
|
12
|
+
}) {
|
|
13
|
+
const {
|
|
14
|
+
t
|
|
15
|
+
} = useTranslation();
|
|
16
|
+
return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
|
|
17
|
+
/* @__PURE__ */ jsx(HomeCard.Header, { title: t("homepage.usefulLinks.title"), actionLabel: t("homepage.usefulLinks.edit"), actionLeftIcon: /* @__PURE__ */ jsx(SvgIconEdit, {}), onActionClick: onEditClick, actionProps: {
|
|
18
|
+
"data-testid": "usefullinks-button-edit"
|
|
19
|
+
} }),
|
|
20
|
+
/* @__PURE__ */ jsx(HomeCard.Content, { children: links.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "useful-links-widget__empty", children: [
|
|
21
|
+
/* @__PURE__ */ jsx(Image, { src: illuEmptyUsefulLinks, alt: "", "aria-hidden": "true", style: {
|
|
22
|
+
width: 160,
|
|
23
|
+
height: 87
|
|
24
|
+
} }),
|
|
25
|
+
/* @__PURE__ */ jsx("p", { className: "useful-links-widget__empty-text", children: t("homepage.usefulLinks.empty") })
|
|
26
|
+
] }) : /* @__PURE__ */ jsx(Flex, { direction: "column", gap: "8", children: links.map((link) => /* @__PURE__ */ jsx(LinkPill, { href: link.url, label: link.name, "data-testid": `usefullinks-link-${link.id}` }, link.id)) }) })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
UsefulLinks
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UsefulLinksContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useUsefulLinksContainer } from "./hooks/useUsefulLinksContainer.js";
|
|
4
|
+
import { LinkForm } from "./LinkForm.js";
|
|
5
|
+
import { UsefulLinks } from "./UsefulLinks.js";
|
|
6
|
+
import { UsefulLinksModal } from "./UsefulLinksModal.js";
|
|
7
|
+
function UsefulLinksContainer() {
|
|
8
|
+
const [view, setView] = useState({
|
|
9
|
+
name: "closed"
|
|
10
|
+
}), {
|
|
11
|
+
links,
|
|
12
|
+
canAddLink,
|
|
13
|
+
createLink,
|
|
14
|
+
isCreating,
|
|
15
|
+
updateLink,
|
|
16
|
+
isUpdating,
|
|
17
|
+
deleteLink
|
|
18
|
+
} = useUsefulLinksContainer(), closeAll = () => setView({
|
|
19
|
+
name: "closed"
|
|
20
|
+
}), backToManage = () => setView({
|
|
21
|
+
name: "manage"
|
|
22
|
+
}), handleSubmit = async (payload) => {
|
|
23
|
+
view.name === "edit" ? await updateLink(view.link.id, payload) : await createLink(payload), backToManage();
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
/* @__PURE__ */ jsx(UsefulLinks, { links, onEditClick: () => setView({
|
|
27
|
+
name: "manage"
|
|
28
|
+
}) }),
|
|
29
|
+
/* @__PURE__ */ jsx(UsefulLinksModal, { isOpen: view.name === "manage", links, canAddLink, onClose: closeAll, onAddClick: () => setView({
|
|
30
|
+
name: "add"
|
|
31
|
+
}), onEditLink: (link) => setView({
|
|
32
|
+
name: "edit",
|
|
33
|
+
link
|
|
34
|
+
}), onDeleteLink: deleteLink }),
|
|
35
|
+
(view.name === "add" || view.name === "edit") && /* @__PURE__ */ jsx(LinkForm, { mode: view.name, link: view.name === "edit" ? view.link : void 0, isSubmitting: view.name === "edit" ? isUpdating : isCreating, onCancel: backToManage, onClose: closeAll, onSubmit: handleSubmit })
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
UsefulLinksContainer
|
|
40
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UsefulLink } from '@edifice.io/client';
|
|
2
|
+
export interface UsefulLinksModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
links: UsefulLink[];
|
|
5
|
+
canAddLink: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onAddClick: () => void;
|
|
8
|
+
onEditLink: (link: UsefulLink) => void;
|
|
9
|
+
onDeleteLink: (id: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function UsefulLinksModal({ isOpen, links, canAddLink, onClose, onAddClick, onEditLink, onDeleteLink, }: UsefulLinksModalProps): import("react/jsx-runtime").JSX.Element;
|