Skip to content

Commit

Permalink
feat(web/services): Areas displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Oct 28, 2023
1 parent 42c55e2 commit dc7701d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 15 deletions.
80 changes: 65 additions & 15 deletions frontend/web/app/dashboard/services/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -16,23 +17,72 @@ const ServiceLine = ({
service: Service;
selectedServiceId: string | null;
setSelectedServiceId: (serviceId: string | null) => void;
}) => (
<div className="collapse collapse-arrow">
<input type="radio" checked={selectedServiceId === service.id} onChange={() => setSelectedServiceId(service.id)} />

<div className="collapse-title text-xl font-medium flex">
<div className="avatar">
<div className="mask mask-squircle w-8 h-8">
<Image src={service.imageUrl} alt="Service logo" width={500} height={500} />
}) => {
const [actions, setActions] = useState<Area[]>([]);
const [reactions, setReactions] = useState<Area[]>([]);
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 (
<div className="collapse collapse-arrow">
<input
type="radio"
checked={selectedServiceId === service.id}
onChange={() => setSelectedServiceId(service.id)}
/>

<div className="collapse-title text-2xl font-medium flex">
<div className="avatar">
<div className="mask mask-squircle w-8 h-8">
<Image src={service.imageUrl} alt="Service logo" width={500} height={500} />
</div>
</div>
<p className="ml-2">{service.id}</p>
</div>
<div className="collapse-content">
{actions.length > 0 && (
<>
<p className="font-semibold text-xl">{t("services.actions")}</p>
<ul className="list-disc ml-8">
{actions.map((action) => (
<li className="list-item" key={action.id}>
<p className="text-md font-medium">{action.id}</p>
<p className="text-sm">{action.description}</p>
</li>
))}
</ul>
</>
)}
{reactions.length > 0 && (
<>
<p className="font-semibold text-xl">{t("services.reactions")}</p>
<ul className="list-disc ml-8">
{reactions.map((reaction) => (
<li className="list-item" key={reaction.id}>
<p className="text-md font-medium">{reaction.id}</p>
<p className="text-sm">{reaction.description}</p>
</li>
))}
</ul>
</>
)}

{actions.length === 0 && reactions.length === 0 && (
<p className="font-semibold text-md">{t("services.noArea")}</p>
)}
</div>
<p className="ml-2">{service.id}</p>
</div>
<div className="collapse-content">
<p>TODO: Actions and Reactions displayed</p>
</div>
</div>
);
);
};

const ServicesPage = () => {
const [cachedServices, setCachedServices] = useAtom(servicesAtom);
Expand Down
1 change: 1 addition & 0 deletions frontend/web/components/editor/ServicesList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Image from "next/image";

import { Service } from "@/types/services";
import { splitArrayInChunks } from "@/utils/arrays";

Expand Down
5 changes: 5 additions & 0 deletions frontend/web/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions frontend/web/locales/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions frontend/web/locales/is-IS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dc7701d

Please sign in to comment.