@edifice.io/react 2.6.9-develop-integration.20261016090812 → 2.6.9-develop-b2school.20261016170630
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/Layout/Layout.js +12 -4
- package/dist/components/Layout/components/Header.js +4 -4
- package/dist/components/Layout/components/NavLink.d.ts +3 -3
- package/dist/components/Layout/components/NavLink.js +5 -3
- package/dist/components/Tree/utilities/tree.js +1 -21
- package/dist/homepage.js +62 -24
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/useBackground/useBackground.d.ts +1 -1
- package/dist/hooks/useZendeskGuide/useZendeskGuide.d.ts +2 -6
- package/dist/hooks/useZendeskGuide/useZendeskGuide.js +11 -8
- package/dist/icons.js +404 -402
- package/dist/index.js +184 -198
- package/dist/modules/HelpZone/HelpZone.js +6 -8
- package/dist/modules/HelpZone/HelpZoneContainer.js +2 -5
- package/dist/modules/homepage/components/Agenda/Agenda.d.ts +10 -0
- package/dist/modules/homepage/components/Agenda/Agenda.js +54 -0
- package/dist/modules/homepage/components/Agenda/AgendaContainer.d.ts +1 -0
- package/dist/modules/homepage/components/Agenda/AgendaContainer.js +14 -0
- package/dist/modules/homepage/components/Agenda/AgendaEventCard.d.ts +10 -0
- package/dist/modules/homepage/components/Agenda/AgendaEventCard.js +30 -0
- package/dist/modules/homepage/components/Agenda/hooks/useAgendaContainer.d.ts +14 -0
- package/dist/modules/homepage/components/Agenda/hooks/useAgendaContainer.js +27 -0
- package/dist/modules/homepage/components/Agenda/index.d.ts +3 -0
- package/dist/modules/homepage/components/Agenda/services/api/agendaService.d.ts +24 -0
- package/dist/modules/homepage/components/Agenda/services/api/agendaService.js +45 -0
- package/dist/modules/homepage/components/Agenda/services/api/index.d.ts +4 -0
- package/dist/modules/homepage/components/Agenda/services/api/index.js +5 -0
- package/dist/modules/homepage/components/Agenda/services/queries/agenda.d.ts +19 -0
- package/dist/modules/homepage/components/Agenda/services/queries/agenda.js +26 -0
- package/dist/modules/homepage/components/BriefMe/BriefMe.d.ts +9 -0
- package/dist/modules/homepage/components/BriefMe/BriefMe.js +59 -0
- package/dist/modules/homepage/components/BriefMe/BriefMeContainer.d.ts +4 -0
- package/dist/modules/homepage/components/BriefMe/BriefMeContainer.js +17 -0
- package/dist/modules/homepage/components/BriefMe/index.d.ts +4 -0
- package/dist/modules/homepage/components/BriefMe/types.d.ts +17 -0
- package/dist/modules/homepage/components/BriefMe/types.js +8 -0
- package/dist/modules/homepage/components/BriefMe/useBriefMe.d.ts +31 -0
- package/dist/modules/homepage/components/BriefMe/useBriefMe.js +51 -0
- package/dist/modules/homepage/components/Cantine/Cantine.d.ts +7 -0
- package/dist/modules/homepage/components/Cantine/Cantine.js +44 -0
- package/dist/modules/homepage/components/Cantine/CantineContainer.d.ts +4 -0
- package/dist/modules/homepage/components/Cantine/CantineContainer.js +18 -0
- package/dist/modules/homepage/components/Cantine/CantineModal.d.ts +24 -0
- package/dist/modules/homepage/components/Cantine/CantineModal.js +88 -0
- package/dist/modules/homepage/components/Cantine/CantineModalContainer.d.ts +7 -0
- package/dist/modules/homepage/components/Cantine/CantineModalContainer.js +12 -0
- package/dist/modules/homepage/components/Cantine/components/CantineLegend.d.ts +5 -0
- package/dist/modules/homepage/components/Cantine/components/CantineLegend.js +22 -0
- package/dist/modules/homepage/components/Cantine/components/CantineMenuSection.d.ts +6 -0
- package/dist/modules/homepage/components/Cantine/components/CantineMenuSection.js +28 -0
- package/dist/modules/homepage/components/Cantine/components/cantineLabels.d.ts +12 -0
- package/dist/modules/homepage/components/Cantine/components/cantineLabels.js +60 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantine.d.ts +11 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantine.js +20 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantineMenu.d.ts +24 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantineMenu.js +65 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantineModal.d.ts +23 -0
- package/dist/modules/homepage/components/Cantine/hooks/useCantineModal.js +43 -0
- package/dist/modules/homepage/components/Cantine/index.d.ts +7 -0
- package/dist/modules/homepage/components/Cantine/types.d.ts +42 -0
- package/dist/modules/homepage/components/Communities/Communities.js +4 -4
- package/dist/modules/homepage/components/GenerationHdf/GenerationHdf.d.ts +16 -0
- package/dist/modules/homepage/components/GenerationHdf/GenerationHdf.js +48 -0
- package/dist/modules/homepage/components/GenerationHdf/GenerationHdfContainer.d.ts +4 -0
- package/dist/modules/homepage/components/GenerationHdf/GenerationHdfContainer.js +12 -0
- package/dist/modules/homepage/components/GenerationHdf/formatSolde.d.ts +1 -0
- package/dist/modules/homepage/components/GenerationHdf/formatSolde.js +6 -0
- package/dist/modules/homepage/components/GenerationHdf/index.d.ts +3 -0
- package/dist/modules/homepage/components/GenerationHdf/useGenerationHdf.d.ts +10 -0
- package/dist/modules/homepage/components/GenerationHdf/useGenerationHdf.js +68 -0
- package/dist/modules/homepage/components/Header/Header.js +30 -21
- package/dist/modules/homepage/components/Header/MyAppsPopover.d.ts +5 -0
- package/dist/modules/homepage/components/Header/MyAppsPopover.js +28 -0
- package/dist/modules/homepage/components/Header/useSafeHoverPopover.js +32 -0
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.d.ts +5 -1
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +1 -1
- package/dist/modules/homepage/components/MessageFlashList/MessageFlash.js +1 -1
- package/dist/modules/homepage/components/Notifications/NotificationList.js +5 -5
- package/dist/modules/homepage/components/Notifications/NotificationSkeleton.js +2 -2
- package/dist/modules/homepage/components/Notifications/components/NotificationFilterMenu.js +1 -5
- package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.js +10 -12
- package/dist/modules/homepage/components/Notifications/components/NotificationOptionsMenu.js +3 -9
- package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.js +6 -12
- package/dist/modules/homepage/components/Notifications/components/notificationAdapter.js +12 -10
- package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.js +9 -10
- package/dist/modules/homepage/components/Qwant/Qwant.d.ts +4 -0
- package/dist/modules/homepage/components/Qwant/Qwant.js +41 -0
- package/dist/modules/homepage/components/Qwant/QwantContainer.d.ts +1 -0
- package/dist/modules/homepage/components/Qwant/QwantContainer.js +10 -0
- package/dist/modules/homepage/components/Qwant/index.d.ts +3 -0
- package/dist/modules/homepage/components/SchoolSpace/SchoolSpaceContainer.js +1 -1
- package/dist/modules/homepage/components/Universalis/Universalis.d.ts +8 -0
- package/dist/modules/homepage/components/Universalis/Universalis.js +62 -0
- package/dist/modules/homepage/components/Universalis/UniversalisContainer.d.ts +1 -0
- package/dist/modules/homepage/components/Universalis/UniversalisContainer.js +16 -0
- package/dist/modules/homepage/components/Universalis/index.d.ts +3 -0
- package/dist/modules/homepage/components/UserSpace/UserSpace.d.ts +3 -1
- package/dist/modules/homepage/components/UserSpace/UserSpace.js +13 -7
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.d.ts +4 -2
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.js +3 -2
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.d.ts +16 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.js +15 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.d.ts +21 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.js +47 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/index.d.ts +2 -0
- package/dist/modules/homepage/components/index.d.ts +8 -1
- package/dist/modules/homepage/{components/SchoolSpace → hooks}/useUserSchools.d.ts +2 -2
- package/dist/modules/homepage/{components/SchoolSpace → hooks}/useUserSchools.js +4 -4
- package/dist/modules/icons/components/IconAddWidget.d.ts +7 -0
- package/dist/modules/icons/components/IconAddWidget.js +12 -0
- package/dist/modules/icons/components/index.d.ts +1 -0
- package/dist/modules/multimedia/FileCard/index.d.ts +0 -4
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.d.ts +1 -7
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.js +0 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +2 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +12 -48
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.js +0 -4
- package/dist/modules/multimedia/Workspace/Workspace.js +5 -8
- package/dist/modules/multimedia/index.d.ts +0 -2
- package/dist/multimedia.js +18 -26
- package/package.json +6 -6
- package/dist/hooks/useCarbonioUnread/index.d.ts +0 -1
- package/dist/hooks/useCarbonioUnread/useCarbonioUnread.d.ts +0 -5
- package/dist/hooks/useCarbonioUnread/useCarbonioUnread.js +0 -24
- package/dist/hooks/useGoogleDriveSearch/index.d.ts +0 -1
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.d.ts +0 -19
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.js +0 -60
- package/dist/hooks/useNextcloudSearch/index.d.ts +0 -1
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.d.ts +0 -14
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.js +0 -64
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.d.ts +0 -25
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.js +0 -102
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.d.ts +0 -25
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.js +0 -102
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.d.ts +0 -24
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.js +0 -103
- package/dist/modules/multimedia/GoogleDrive/index.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.js +0 -61
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.js +0 -48
- package/dist/modules/multimedia/Nextcloud/Nextcloud.d.ts +0 -24
- package/dist/modules/multimedia/Nextcloud/Nextcloud.js +0 -120
- package/dist/modules/multimedia/Nextcloud/index.d.ts +0 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import CantineModal from "./CantineModal.js";
|
|
3
|
+
import { useCantineModal } from "./hooks/useCantineModal.js";
|
|
4
|
+
function CantineModalContainer({
|
|
5
|
+
onClose
|
|
6
|
+
}) {
|
|
7
|
+
const cantineModal = useCantineModal();
|
|
8
|
+
return /* @__PURE__ */ jsx(CantineModal, { isOpen: !0, onClose, ...cantineModal });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
CantineModalContainer
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { DISH_TAGS } from "./cantineLabels.js";
|
|
4
|
+
import Image from "../../../../../components/Image/Image.js";
|
|
5
|
+
function CantineLegend() {
|
|
6
|
+
const {
|
|
7
|
+
t
|
|
8
|
+
} = useTranslation();
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: "cantine-modal__legend", children: [
|
|
10
|
+
/* @__PURE__ */ jsxs("div", { className: "cantine-modal__legend-list", children: [
|
|
11
|
+
/* @__PURE__ */ jsx("h3", { className: "cantine-modal__legend-title", children: t("homepage.widget.cantine.legend.title") }),
|
|
12
|
+
DISH_TAGS.map((tag) => /* @__PURE__ */ jsxs("p", { className: "cantine-modal__legend-item", children: [
|
|
13
|
+
/* @__PURE__ */ jsx(Image, { src: tag.icon, alt: t(tag.i18nKey, tag.defaultLabel), className: "cantine-modal__legend-icon" }),
|
|
14
|
+
t(tag.i18nKey, tag.defaultLabel)
|
|
15
|
+
] }, tag.flag))
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ jsx("p", { className: "cantine-modal__notice", children: t("homepage.widget.cantine.legend.notice") })
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
CantineLegend as default
|
|
22
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CantineCategory, CantineDish } from '../types';
|
|
2
|
+
export interface CantineMenuSectionProps {
|
|
3
|
+
category: CantineCategory;
|
|
4
|
+
items: CantineDish[];
|
|
5
|
+
}
|
|
6
|
+
export default function CantineMenuSection({ category, items, }: CantineMenuSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { CATEGORY_CONFIG, DISH_TAGS } from "./cantineLabels.js";
|
|
4
|
+
import Image from "../../../../../components/Image/Image.js";
|
|
5
|
+
function CantineMenuSection({
|
|
6
|
+
category,
|
|
7
|
+
items
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
t
|
|
11
|
+
} = useTranslation(), config = CATEGORY_CONFIG[category];
|
|
12
|
+
return /* @__PURE__ */ jsxs("li", { className: `cantine__section cantine__section-${category}`, children: [
|
|
13
|
+
/* @__PURE__ */ jsxs("div", { className: "cantine__section-header", children: [
|
|
14
|
+
/* @__PURE__ */ jsx("span", { className: "cantine__section-icon", children: /* @__PURE__ */ jsx(Image, { src: config.icon, alt: t(config.i18nKey, config.defaultLabel) }) }),
|
|
15
|
+
/* @__PURE__ */ jsx("h4", { className: "cantine__section-title", children: t(config.i18nKey, config.defaultLabel) })
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ jsx("ul", { className: "cantine__items", children: items.map((item) => /* @__PURE__ */ jsxs("li", { className: "cantine__item", children: [
|
|
18
|
+
/* @__PURE__ */ jsxs("div", { className: "cantine__item-text", children: [
|
|
19
|
+
/* @__PURE__ */ jsx("p", { className: "cantine__item-label", children: item.label }),
|
|
20
|
+
item.allergens.length > 0 && /* @__PURE__ */ jsx("p", { className: "cantine__item-allergens", children: item.allergens.join(", ") })
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ jsx("div", { className: "cantine__item-tags", children: DISH_TAGS.filter((tag) => item[tag.flag]).map((tag) => /* @__PURE__ */ jsx(Image, { src: tag.icon, alt: t(tag.i18nKey, tag.defaultLabel), className: "cantine__item-tag" }, tag.flag)) })
|
|
23
|
+
] }, item.id)) })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
CantineMenuSection as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CantineCategory } from '../types';
|
|
2
|
+
export interface IllustratedLabel {
|
|
3
|
+
icon: string;
|
|
4
|
+
i18nKey: string;
|
|
5
|
+
defaultLabel: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const CATEGORY_CONFIG: Record<CantineCategory, IllustratedLabel>;
|
|
8
|
+
/** Boolean quality flags of a dish */
|
|
9
|
+
export type DishFlag = 'vegetarien' | 'faitmaison' | 'bio' | 'local';
|
|
10
|
+
export declare const DISH_TAGS: (IllustratedLabel & {
|
|
11
|
+
flag: DishFlag;
|
|
12
|
+
})[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import illuAccompagnement from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-dish-accompagnement.svg";
|
|
2
|
+
import illuDessert from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-dish-dessert.svg";
|
|
3
|
+
import illuEntree from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-dish-entree.svg";
|
|
4
|
+
import illuLaitage from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-dish-laitage.svg";
|
|
5
|
+
import illuPlat from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-dish-plat.svg";
|
|
6
|
+
import labelBio from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-label-bio.png";
|
|
7
|
+
import labelFaitmaison from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-label-faitmaison.png";
|
|
8
|
+
import labelLocal from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-label-local.png";
|
|
9
|
+
import labelVegetarien from "@edifice.io/bootstrap/dist/images/homepage/cantine/cantine-label-vegetarien.png";
|
|
10
|
+
const CATEGORY_CONFIG = {
|
|
11
|
+
entree: {
|
|
12
|
+
icon: illuEntree,
|
|
13
|
+
i18nKey: "homepage.widget.cantine.category.entree",
|
|
14
|
+
defaultLabel: "Entrée"
|
|
15
|
+
},
|
|
16
|
+
plat: {
|
|
17
|
+
icon: illuPlat,
|
|
18
|
+
i18nKey: "homepage.widget.cantine.category.plat",
|
|
19
|
+
defaultLabel: "Plat"
|
|
20
|
+
},
|
|
21
|
+
accompagnement: {
|
|
22
|
+
icon: illuAccompagnement,
|
|
23
|
+
i18nKey: "homepage.widget.cantine.category.accompagnement",
|
|
24
|
+
defaultLabel: "Accompagnement"
|
|
25
|
+
},
|
|
26
|
+
laitage: {
|
|
27
|
+
icon: illuLaitage,
|
|
28
|
+
i18nKey: "homepage.widget.cantine.category.laitage",
|
|
29
|
+
defaultLabel: "Laitage"
|
|
30
|
+
},
|
|
31
|
+
dessert: {
|
|
32
|
+
icon: illuDessert,
|
|
33
|
+
i18nKey: "homepage.widget.cantine.category.dessert",
|
|
34
|
+
defaultLabel: "Dessert"
|
|
35
|
+
}
|
|
36
|
+
}, DISH_TAGS = [{
|
|
37
|
+
flag: "vegetarien",
|
|
38
|
+
icon: labelVegetarien,
|
|
39
|
+
i18nKey: "homepage.widget.cantine.tag.vegetarien",
|
|
40
|
+
defaultLabel: "Végétarien"
|
|
41
|
+
}, {
|
|
42
|
+
flag: "faitmaison",
|
|
43
|
+
icon: labelFaitmaison,
|
|
44
|
+
i18nKey: "homepage.widget.cantine.tag.faitmaison",
|
|
45
|
+
defaultLabel: "Fait maison"
|
|
46
|
+
}, {
|
|
47
|
+
flag: "bio",
|
|
48
|
+
icon: labelBio,
|
|
49
|
+
i18nKey: "homepage.widget.cantine.tag.bio",
|
|
50
|
+
defaultLabel: "Agriculture biologique"
|
|
51
|
+
}, {
|
|
52
|
+
flag: "local",
|
|
53
|
+
icon: labelLocal,
|
|
54
|
+
i18nKey: "homepage.widget.cantine.tag.local",
|
|
55
|
+
defaultLabel: "Produit local"
|
|
56
|
+
}];
|
|
57
|
+
export {
|
|
58
|
+
CATEGORY_CONFIG,
|
|
59
|
+
DISH_TAGS
|
|
60
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Today's lunch menu for the school currently selected by the user (see
|
|
3
|
+
* `useUserSchools`).
|
|
4
|
+
*
|
|
5
|
+
* Only lunch is exposed: the widget design has no lunch/dinner toggle, unlike
|
|
6
|
+
* the modal and the legacy AngularJS widget.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCantine(): {
|
|
9
|
+
sections: import('..').CantineSection[];
|
|
10
|
+
status: import('..').CantineStatus;
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useUserSchools } from "../../../hooks/useUserSchools.js";
|
|
2
|
+
import { useCantineMenu } from "./useCantineMenu.js";
|
|
3
|
+
import useDate from "../../../../../hooks/useDate/useDate.js";
|
|
4
|
+
function useCantine() {
|
|
5
|
+
const {
|
|
6
|
+
selectedSchool
|
|
7
|
+
} = useUserSchools(), {
|
|
8
|
+
formatDate
|
|
9
|
+
} = useDate(), {
|
|
10
|
+
sections,
|
|
11
|
+
status
|
|
12
|
+
} = useCantineMenu((selectedSchool == null ? void 0 : selectedSchool.UAI) ?? "", formatDate(/* @__PURE__ */ new Date(), "YYYY-MM-DD"));
|
|
13
|
+
return {
|
|
14
|
+
sections,
|
|
15
|
+
status
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
useCantine
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CantineMenuItem, CantineMenus, CantineMenuType, CantineSection, CantineStatus } from '../types';
|
|
2
|
+
export declare function buildSections(menu: CantineMenuItem[]): CantineSection[];
|
|
3
|
+
export declare function cantineMenuQueryOptions(uai: string, date: string): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<CantineMenus, Error, CantineMenus, import('@tanstack/react-query').QueryKey>, "queryFn"> & {
|
|
4
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<CantineMenus, import('@tanstack/react-query').QueryKey, never> | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
queryKey: import('@tanstack/react-query').DataTag<import('@tanstack/react-query').QueryKey, CantineMenus>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Loads one day's menu for one school and groups the requested service's
|
|
10
|
+
* dishes by category. Shared by the widget and its full-screen modal.
|
|
11
|
+
*
|
|
12
|
+
* `loading` also covers "no school selected yet": an absent UAI leaves
|
|
13
|
+
* `enabled: false`, so the query never starts.
|
|
14
|
+
*
|
|
15
|
+
* When the day or the school has no dinner service, the returned `menuType`
|
|
16
|
+
* falls back on lunch: the caller keeps its own request untouched and simply
|
|
17
|
+
* renders what is actually served.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useCantineMenu(uai: string, date: string, requestedMenuType?: CantineMenuType): {
|
|
20
|
+
sections: CantineSection[];
|
|
21
|
+
dinnerAvailable: boolean;
|
|
22
|
+
menuType: CantineMenuType;
|
|
23
|
+
status: CantineStatus;
|
|
24
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { odeServices } from "@edifice.io/client";
|
|
2
|
+
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
const CANTINE_CATEGORIES = ["entree", "plat", "accompagnement", "laitage", "dessert"];
|
|
5
|
+
function getAllergens(item) {
|
|
6
|
+
return Object.keys(item).filter((key) => key.startsWith("allerg_") && item[key] !== 0 && item[key] !== void 0).map((key) => key.slice(7).replace(/_/g, " "));
|
|
7
|
+
}
|
|
8
|
+
function normalizeDish(item, index) {
|
|
9
|
+
var _a;
|
|
10
|
+
const designation = (_a = item.designationMenu) == null ? void 0 : _a.trim();
|
|
11
|
+
return {
|
|
12
|
+
id: `${item.type}-${index}`,
|
|
13
|
+
label: designation || item.nom,
|
|
14
|
+
vegetarien: !!item.vegetarien,
|
|
15
|
+
faitmaison: !!item.faitmaison,
|
|
16
|
+
bio: !!item.bio,
|
|
17
|
+
local: !!item.local,
|
|
18
|
+
allergens: getAllergens(item)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function buildSections(menu) {
|
|
22
|
+
return CANTINE_CATEGORIES.map((category) => ({
|
|
23
|
+
category,
|
|
24
|
+
items: menu.filter((item) => item.type === category).map((item, index) => normalizeDish(item, index))
|
|
25
|
+
})).filter((section) => section.items.length > 0);
|
|
26
|
+
}
|
|
27
|
+
function cantineMenuQueryOptions(uai, date) {
|
|
28
|
+
return queryOptions({
|
|
29
|
+
queryKey: ["cantine", uai, date],
|
|
30
|
+
enabled: !!uai,
|
|
31
|
+
// The menu is keyed by day and proxied from a slow upstream service, so
|
|
32
|
+
// this caches it for 5 minutes instead of refetching on every remount.
|
|
33
|
+
staleTime: 5 * 60 * 1e3,
|
|
34
|
+
// 5 minutes
|
|
35
|
+
queryFn: async () => {
|
|
36
|
+
const http = odeServices.http(), body = await http.get(`/appregistry/${encodeURIComponent(uai)}/cantine/menu?date=${date}`);
|
|
37
|
+
if (http.isResponseError())
|
|
38
|
+
throw new Error(http.latestResponse.statusText);
|
|
39
|
+
const lunch = Array.isArray(body == null ? void 0 : body.menu) ? body.menu : [], dinner = Array.isArray(body == null ? void 0 : body.dinnerMenu) ? body.dinnerMenu : [];
|
|
40
|
+
return {
|
|
41
|
+
lunch,
|
|
42
|
+
dinner,
|
|
43
|
+
dinnerAvailable: (body == null ? void 0 : body.dinnerAvailable) === !0 && dinner.length > 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function useCantineMenu(uai, date, requestedMenuType = "lunch") {
|
|
49
|
+
const {
|
|
50
|
+
data,
|
|
51
|
+
isPending,
|
|
52
|
+
error
|
|
53
|
+
} = useQuery(cantineMenuQueryOptions(uai, date)), dinnerAvailable = (data == null ? void 0 : data.dinnerAvailable) === !0, menuType = requestedMenuType === "dinner" && dinnerAvailable ? "dinner" : "lunch", sections = useMemo(() => buildSections((menuType === "lunch" ? data == null ? void 0 : data.lunch : data == null ? void 0 : data.dinner) ?? []), [data, menuType]);
|
|
54
|
+
return {
|
|
55
|
+
sections,
|
|
56
|
+
dinnerAvailable,
|
|
57
|
+
menuType,
|
|
58
|
+
status: error ? "error" : !uai || isPending ? "loading" : sections.length > 0 ? "default" : "empty"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
buildSections,
|
|
63
|
+
cantineMenuQueryOptions,
|
|
64
|
+
useCantineMenu
|
|
65
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CantineMenuType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Browsing state of the full-screen canteen modal: day, school and service.
|
|
4
|
+
*
|
|
5
|
+
* The school picked here stays local to the modal on purpose: it must not
|
|
6
|
+
* change the school shared with the other homepage widgets (see
|
|
7
|
+
* `useUserSchools`), only the menu being read.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useCantineModal(): {
|
|
10
|
+
schools: import('@edifice.io/client').School[];
|
|
11
|
+
selectedSchool: import('@edifice.io/client').School | undefined;
|
|
12
|
+
onSchoolChange: import('react').Dispatch<import('react').SetStateAction<string | undefined>>;
|
|
13
|
+
hasDinner: boolean;
|
|
14
|
+
menuType: CantineMenuType;
|
|
15
|
+
onMenuTypeChange: import('react').Dispatch<import('react').SetStateAction<CantineMenuType>>;
|
|
16
|
+
date: string;
|
|
17
|
+
canGoPrevious: boolean;
|
|
18
|
+
canGoNext: boolean;
|
|
19
|
+
onPreviousDay: () => void;
|
|
20
|
+
onNextDay: () => void;
|
|
21
|
+
sections: import('..').CantineSection[];
|
|
22
|
+
status: import('..').CantineStatus;
|
|
23
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useState, useMemo } from "react";
|
|
2
|
+
import { useUserSchools } from "../../../hooks/useUserSchools.js";
|
|
3
|
+
import { useCantineMenu } from "./useCantineMenu.js";
|
|
4
|
+
import useDate from "../../../../../hooks/useDate/useDate.js";
|
|
5
|
+
const DATE_RANGE_IN_DAYS = 40, DATE_FORMAT = "YYYY-MM-DD", addDays = (date, days) => {
|
|
6
|
+
const shifted = new Date(date);
|
|
7
|
+
return shifted.setDate(shifted.getDate() + days), shifted;
|
|
8
|
+
};
|
|
9
|
+
function useCantineModal() {
|
|
10
|
+
const {
|
|
11
|
+
schools,
|
|
12
|
+
selectedSchool: defaultSchool
|
|
13
|
+
} = useUserSchools(), {
|
|
14
|
+
formatDate
|
|
15
|
+
} = useDate(), [schoolId, setSchoolId] = useState(), [menuType, setMenuType] = useState("lunch"), [date, setDate] = useState(() => formatDate(/* @__PURE__ */ new Date(), DATE_FORMAT)), {
|
|
16
|
+
minDate,
|
|
17
|
+
maxDate
|
|
18
|
+
} = useMemo(() => {
|
|
19
|
+
const today = /* @__PURE__ */ new Date();
|
|
20
|
+
return {
|
|
21
|
+
minDate: formatDate(addDays(today, -DATE_RANGE_IN_DAYS), DATE_FORMAT),
|
|
22
|
+
maxDate: formatDate(addDays(today, DATE_RANGE_IN_DAYS), DATE_FORMAT)
|
|
23
|
+
};
|
|
24
|
+
}, [formatDate]), selectedSchool = schools.find((school) => school.id === schoolId) ?? defaultSchool, menu = useCantineMenu((selectedSchool == null ? void 0 : selectedSchool.UAI) ?? "", date, menuType), shiftDate = (days) => setDate((current) => formatDate(addDays(/* @__PURE__ */ new Date(`${current}T00:00:00`), days), DATE_FORMAT));
|
|
25
|
+
return {
|
|
26
|
+
schools,
|
|
27
|
+
selectedSchool,
|
|
28
|
+
onSchoolChange: setSchoolId,
|
|
29
|
+
hasDinner: menu.dinnerAvailable,
|
|
30
|
+
menuType: menu.menuType,
|
|
31
|
+
onMenuTypeChange: setMenuType,
|
|
32
|
+
date,
|
|
33
|
+
canGoPrevious: date > minDate,
|
|
34
|
+
canGoNext: date < maxDate,
|
|
35
|
+
onPreviousDay: () => shiftDate(-1),
|
|
36
|
+
onNextDay: () => shiftDate(1),
|
|
37
|
+
sections: menu.sections,
|
|
38
|
+
status: menu.status
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
useCantineModal
|
|
43
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './Cantine';
|
|
2
|
+
export { default as Cantine } from './Cantine';
|
|
3
|
+
export * from './CantineContainer';
|
|
4
|
+
export * from './CantineModal';
|
|
5
|
+
export { default as CantineModal } from './CantineModal';
|
|
6
|
+
export * from './CantineModalContainer';
|
|
7
|
+
export type { CantineCategory, CantineDish, CantineMenuType, CantineSection, CantineStatus, } from './types';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type CantineCategory = 'entree' | 'plat' | 'accompagnement' | 'laitage' | 'dessert';
|
|
2
|
+
/**
|
|
3
|
+
* Raw dish shape returned by the Webgerest upstream API, forwarded unmapped by
|
|
4
|
+
* app-registry. Everything besides `type` and `nom` is effectively optional.
|
|
5
|
+
*/
|
|
6
|
+
export interface CantineMenuItem {
|
|
7
|
+
type: string;
|
|
8
|
+
nom: string;
|
|
9
|
+
designationMenu?: string;
|
|
10
|
+
vegetarien?: boolean;
|
|
11
|
+
faitmaison?: boolean;
|
|
12
|
+
bio?: boolean;
|
|
13
|
+
local?: boolean;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface CantineMenuResponse {
|
|
17
|
+
menu?: CantineMenuItem[];
|
|
18
|
+
dinnerAvailable?: boolean;
|
|
19
|
+
dinnerMenu?: CantineMenuItem[];
|
|
20
|
+
}
|
|
21
|
+
export interface CantineDish {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
vegetarien: boolean;
|
|
25
|
+
faitmaison: boolean;
|
|
26
|
+
bio: boolean;
|
|
27
|
+
local: boolean;
|
|
28
|
+
allergens: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface CantineSection {
|
|
31
|
+
category: CantineCategory;
|
|
32
|
+
items: CantineDish[];
|
|
33
|
+
}
|
|
34
|
+
/** Both services of a given day, as exposed by app-registry. */
|
|
35
|
+
export interface CantineMenus {
|
|
36
|
+
lunch: CantineMenuItem[];
|
|
37
|
+
dinner: CantineMenuItem[];
|
|
38
|
+
/** True when the school also serves a dinner menu that day. */
|
|
39
|
+
dinnerAvailable: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type CantineStatus = 'loading' | 'default' | 'empty' | 'error';
|
|
42
|
+
export type CantineMenuType = 'lunch' | 'dinner';
|
|
@@ -22,11 +22,11 @@ const Communities = ({
|
|
|
22
22
|
height: 80
|
|
23
23
|
} }),
|
|
24
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"
|
|
26
|
-
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.teacher"
|
|
25
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.teacher") }),
|
|
26
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.teacher") })
|
|
27
27
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28
|
-
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.student"
|
|
29
|
-
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.student"
|
|
28
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.student") }),
|
|
29
|
+
/* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.student") })
|
|
30
30
|
] }) })
|
|
31
31
|
] }) }) })
|
|
32
32
|
] });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormEvent } from 'react';
|
|
2
|
+
export type GenerationHdfStatus = 'idle' | 'loading' | 'error' | 'account';
|
|
3
|
+
export interface GenerationHdfWallet {
|
|
4
|
+
label: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GenerationHdfProps {
|
|
8
|
+
handleActionClick: () => void;
|
|
9
|
+
status: GenerationHdfStatus;
|
|
10
|
+
cardNumber: string;
|
|
11
|
+
onCardNumberChange: (value: string) => void;
|
|
12
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
13
|
+
onEdit: () => void;
|
|
14
|
+
wallets: GenerationHdfWallet[];
|
|
15
|
+
}
|
|
16
|
+
export default function GenerationHdf({ handleActionClick, status, cardNumber, onCardNumberChange, onSubmit, onEdit, wallets, }: GenerationHdfProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import illuGenerationHdf from "@edifice.io/bootstrap/dist/images/homepage/illu-generation-hdf.svg";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import SvgIconExternalLink from "../../../icons/components/IconExternalLink.js";
|
|
5
|
+
import HomeCard from "../HomeCard/HomeCard.js";
|
|
6
|
+
import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
|
|
7
|
+
import Image from "../../../../components/Image/Image.js";
|
|
8
|
+
import FormControl from "../../../../components/Form/FormControl.js";
|
|
9
|
+
import Input from "../../../../components/Input/Input.js";
|
|
10
|
+
function GenerationHdf({
|
|
11
|
+
handleActionClick,
|
|
12
|
+
status,
|
|
13
|
+
cardNumber,
|
|
14
|
+
onCardNumberChange,
|
|
15
|
+
onSubmit,
|
|
16
|
+
onEdit,
|
|
17
|
+
wallets
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = useTranslation(), isAccount = status === "account", isLoading = status === "loading", isError = status === "error";
|
|
22
|
+
return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
|
|
23
|
+
/* @__PURE__ */ jsxs("div", { className: "generation-hdf__header", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("h3", { className: "generation-hdf__title", children: t("homepage.widget.generation-hdf.title") }),
|
|
25
|
+
/* @__PURE__ */ jsx(ButtonBeta, { "data-testid": "generation-hdf-button-open", "aria-label": t("homepage.widget.generation-hdf.open"), onClick: handleActionClick, leftIcon: /* @__PURE__ */ jsx(SvgIconExternalLink, {}), variant: "ghost", color: "tertiary" })
|
|
26
|
+
] }),
|
|
27
|
+
/* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsxs("div", { className: "generation-hdf", children: [
|
|
28
|
+
/* @__PURE__ */ jsx(Image, { src: illuGenerationHdf, alt: "Génération #HDF", className: "generation-hdf__logo" }),
|
|
29
|
+
isAccount ? /* @__PURE__ */ jsxs("div", { className: "generation-hdf__account", children: [
|
|
30
|
+
/* @__PURE__ */ jsx("h4", { className: "generation-hdf__account-title", children: t("homepage.widget.generation-hdf.wallets-title") }),
|
|
31
|
+
/* @__PURE__ */ jsx("ul", { className: "generation-hdf__wallets", children: wallets.map((wallet, index) => /* @__PURE__ */ jsxs("li", { className: "generation-hdf__wallet", children: [
|
|
32
|
+
/* @__PURE__ */ jsx("span", { className: "generation-hdf__wallet-label", children: wallet.label }),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { className: "generation-hdf__wallet-amount", children: wallet.amount })
|
|
34
|
+
] }, index)) })
|
|
35
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "generation-hdf__description", children: t("homepage.widget.generation-hdf.description") }),
|
|
36
|
+
/* @__PURE__ */ jsxs("form", { className: "generation-hdf__form", onSubmit, children: [
|
|
37
|
+
/* @__PURE__ */ jsxs(FormControl, { id: "generationHdfCardNumber", className: "generation-hdf__field", status: isError ? "invalid" : void 0, children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Input, { size: "md", type: "text", inputMode: "numeric", placeholder: t("homepage.widget.generation-hdf.placeholder"), value: cardNumber, onChange: (event) => onCardNumberChange(event.target.value), disabled: isAccount, maxLength: 50 }),
|
|
39
|
+
isError && /* @__PURE__ */ jsx(FormControl.Text, { children: t("homepage.widget.generation-hdf.error") })
|
|
40
|
+
] }),
|
|
41
|
+
isAccount ? /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "outline", color: "default", onClick: onEdit, children: t("homepage.widget.generation-hdf.edit") }) : /* @__PURE__ */ jsx(ButtonBeta, { type: "submit", variant: "outline", color: "default", isLoading, disabled: !cardNumber.trim(), children: t("homepage.widget.generation-hdf.submit") })
|
|
42
|
+
] })
|
|
43
|
+
] }) })
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
GenerationHdf as default
|
|
48
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import GenerationHdf from "./GenerationHdf.js";
|
|
3
|
+
import { useGenerationHdf } from "./useGenerationHdf.js";
|
|
4
|
+
function GenerationHdfContainer() {
|
|
5
|
+
const generationHdf = useGenerationHdf();
|
|
6
|
+
return /* @__PURE__ */ jsx(GenerationHdf, { handleActionClick: () => {
|
|
7
|
+
window.open("https://generation.hautsdefrance.fr", "_blank", "noopener,noreferrer");
|
|
8
|
+
}, ...generationHdf });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
GenerationHdfContainer
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatSolde(soldeStr: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function formatSolde(soldeStr) {
|
|
2
|
+
return typeof soldeStr != "string" || soldeStr.length === 0 ? soldeStr : soldeStr.length === 1 ? `0,0${soldeStr}` : soldeStr.length === 2 ? `0,${soldeStr}` : `${soldeStr.substring(0, soldeStr.length - 2)},${soldeStr.substring(soldeStr.length - 2)}`;
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
formatSolde
|
|
6
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormEvent } from 'react';
|
|
2
|
+
import { GenerationHdfStatus, GenerationHdfWallet } from './GenerationHdf';
|
|
3
|
+
export declare function useGenerationHdf(): {
|
|
4
|
+
status: GenerationHdfStatus;
|
|
5
|
+
cardNumber: string;
|
|
6
|
+
onCardNumberChange: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
7
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
8
|
+
onEdit: () => void;
|
|
9
|
+
wallets: GenerationHdfWallet[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { odeServices, USER_PREFS } from "@edifice.io/client";
|
|
2
|
+
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { formatSolde } from "./formatSolde.js";
|
|
5
|
+
function mapSalesToWallets(data) {
|
|
6
|
+
return (data.sales ?? []).map((sale) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const wallet = (_a = data.wallets) == null ? void 0 : _a.find((w) => w.code === sale.numPM);
|
|
9
|
+
return {
|
|
10
|
+
label: (wallet == null ? void 0 : wallet.libelle) ?? "",
|
|
11
|
+
amount: `${formatSolde(sale.solde)} €`
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async function fetchSales(cardNb) {
|
|
16
|
+
const http = odeServices.http(), data = await http.get("/cursus/sales", {
|
|
17
|
+
queryParams: {
|
|
18
|
+
cardNb
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (http.isResponseError())
|
|
22
|
+
throw new Error(http.latestResponse.statusText);
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function useGenerationHdf() {
|
|
26
|
+
const [cardNumber, setCardNumber] = useState(""), autoLoadTriggered = useRef(!1), preferenceQuery = useQuery({
|
|
27
|
+
queryKey: ["cursus", "preference"],
|
|
28
|
+
queryFn: () => odeServices.conf().getPreference(USER_PREFS.CURSUS)
|
|
29
|
+
}), salesMutation = useMutation({
|
|
30
|
+
mutationFn: async ({
|
|
31
|
+
cardNb,
|
|
32
|
+
persist
|
|
33
|
+
}) => {
|
|
34
|
+
const data = await fetchSales(cardNb);
|
|
35
|
+
return persist && await odeServices.conf().savePreference(USER_PREFS.CURSUS, {
|
|
36
|
+
cardNb
|
|
37
|
+
}), data;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (autoLoadTriggered.current || !preferenceQuery.data) return;
|
|
42
|
+
autoLoadTriggered.current = !0;
|
|
43
|
+
const storedCardNb = preferenceQuery.data.cardNb;
|
|
44
|
+
storedCardNb && (setCardNumber(storedCardNb), salesMutation.mutate({
|
|
45
|
+
cardNb: storedCardNb,
|
|
46
|
+
persist: !1
|
|
47
|
+
}));
|
|
48
|
+
}, [preferenceQuery.data, salesMutation]);
|
|
49
|
+
const status = preferenceQuery.data ? salesMutation.isPending ? "loading" : salesMutation.isError ? "error" : salesMutation.isSuccess ? "account" : "idle" : "loading", wallets = salesMutation.data ? mapSalesToWallets(salesMutation.data) : [];
|
|
50
|
+
return {
|
|
51
|
+
status,
|
|
52
|
+
cardNumber,
|
|
53
|
+
onCardNumberChange: setCardNumber,
|
|
54
|
+
onSubmit: (event) => {
|
|
55
|
+
event.preventDefault(), !salesMutation.isPending && salesMutation.mutate({
|
|
56
|
+
cardNb: cardNumber,
|
|
57
|
+
persist: !0
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
onEdit: () => {
|
|
61
|
+
odeServices.conf().savePreference(USER_PREFS.CURSUS, {}), setCardNumber(""), salesMutation.reset();
|
|
62
|
+
},
|
|
63
|
+
wallets
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
useGenerationHdf
|
|
68
|
+
};
|