From dc7701d583f1663febb2a23b19914533ffec14a8 Mon Sep 17 00:00:00 2001 From: Reza Rahemtola Date: Fri, 27 Oct 2023 20:29:27 +0200 Subject: [PATCH] feat(web/services): Areas displayed --- frontend/web/app/dashboard/services/page.tsx | 80 +++++++++++++++---- .../web/components/editor/ServicesList.tsx | 1 + frontend/web/locales/en-US.ts | 5 ++ frontend/web/locales/fr-FR.ts | 5 ++ frontend/web/locales/is-IS.ts | 5 ++ 5 files changed, 81 insertions(+), 15 deletions(-) diff --git a/frontend/web/app/dashboard/services/page.tsx b/frontend/web/app/dashboard/services/page.tsx index e95981af..13a13656 100644 --- a/frontend/web/app/dashboard/services/page.tsx +++ b/frontend/web/app/dashboard/services/page.tsx @@ -3,10 +3,11 @@ import { useAtom } from "jotai"; import { useEffect, useState } from "react"; import Image from "next/image"; +import { useTranslation } from "react-i18next"; import DashboardPageWrapper from "@/layouts/dashboard/DashboardPageWrapper"; import { servicesAtom } from "@/stores"; import services from "@/services"; -import { Service } from "@/types/services"; +import { Area, Service } from "@/types/services"; const ServiceLine = ({ service, @@ -16,23 +17,72 @@ const ServiceLine = ({ service: Service; selectedServiceId: string | null; setSelectedServiceId: (serviceId: string | null) => void; -}) => ( -
- setSelectedServiceId(service.id)} /> - -
-
-
- Service logo +}) => { + const [actions, setActions] = useState([]); + const [reactions, setReactions] = useState([]); + const { t } = useTranslation(); + + useEffect(() => { + (async () => { + const actionsResponse = await services.services.getServiceActions(service.id); + const reactionsResponse = await services.services.getServiceReactions(service.id); + + setActions(actionsResponse.data ?? []); + setReactions(reactionsResponse.data ?? []); + })(); + }, []); + + return ( +
+ setSelectedServiceId(service.id)} + /> + +
+
+
+ Service logo +
+

{service.id}

+
+
+ {actions.length > 0 && ( + <> +

{t("services.actions")}

+
    + {actions.map((action) => ( +
  • +

    {action.id}

    +

    {action.description}

    +
  • + ))} +
+ + )} + {reactions.length > 0 && ( + <> +

{t("services.reactions")}

+
    + {reactions.map((reaction) => ( +
  • +

    {reaction.id}

    +

    {reaction.description}

    +
  • + ))} +
+ + )} + + {actions.length === 0 && reactions.length === 0 && ( +

{t("services.noArea")}

+ )}
-

{service.id}

-
-
-

TODO: Actions and Reactions displayed

-
-); + ); +}; const ServicesPage = () => { const [cachedServices, setCachedServices] = useAtom(servicesAtom); diff --git a/frontend/web/components/editor/ServicesList.tsx b/frontend/web/components/editor/ServicesList.tsx index d6794dc4..cb24d50f 100644 --- a/frontend/web/components/editor/ServicesList.tsx +++ b/frontend/web/components/editor/ServicesList.tsx @@ -1,4 +1,5 @@ import Image from "next/image"; + import { Service } from "@/types/services"; import { splitArrayInChunks } from "@/utils/arrays"; diff --git a/frontend/web/locales/en-US.ts b/frontend/web/locales/en-US.ts index 86c906b9..0ff86641 100644 --- a/frontend/web/locales/en-US.ts +++ b/frontend/web/locales/en-US.ts @@ -67,6 +67,11 @@ const translations = { logout: "Logout", }, }, + services: { + actions: "Actions", + reactions: "Reactions", + noArea: "This service doesn't have any action or reaction", + }, landing: { actions: { downloadApk: " Download APK", diff --git a/frontend/web/locales/fr-FR.ts b/frontend/web/locales/fr-FR.ts index 1a9350d0..dd754be8 100644 --- a/frontend/web/locales/fr-FR.ts +++ b/frontend/web/locales/fr-FR.ts @@ -67,6 +67,11 @@ const translations = { logout: "Déconnexion", }, }, + services: { + actions: "Actions", + reactions: "Réactions", + noArea: "Ce service n'a pas d'action ou de réaction", + }, landing: { actions: { downloadApk: " Télécharger l'APK", diff --git a/frontend/web/locales/is-IS.ts b/frontend/web/locales/is-IS.ts index d59789b2..816c891e 100644 --- a/frontend/web/locales/is-IS.ts +++ b/frontend/web/locales/is-IS.ts @@ -67,6 +67,11 @@ const translations = { logout: "Aftengdu", }, }, + services: { + actions: "Aðgerðir", + reactions: "Viðbrögð", + noArea: "Þessi þjónusta hefur engar aðgerðir eða viðbrögð", + }, landing: { actions: { downloadApk: " Sækja APK",