Skip to content

Commit

Permalink
feat(web/services): Displayed in services page
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Oct 8, 2023
1 parent 651fefe commit 63e237d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
24 changes: 23 additions & 1 deletion frontend/web/app/dashboard/services/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
"use client";

import { useAtom } from "jotai";
import { useEffect } from "react";
import DashboardPageWrapper from "@/layouts/dashboard/DashboardPageWrapper";
import { servicesAtom } from "@/stores";
import services from "@/services";
import ServicesList from "@/components/editor/ServicesList";

const ServicesPage = () => {
const [cachedServices, setCachedServices] = useAtom(servicesAtom);

useEffect(() => {
(async () => {
const fetchedServices = await services.services.getAll();
setCachedServices(fetchedServices.data ?? []);
})();
}, []);

const ServicesPage = () => <DashboardPageWrapper title="Services" />;
return (
<DashboardPageWrapper title="Services">
<ServicesList services={cachedServices} nbPerLine={1} />
</DashboardPageWrapper>
);
};

export default ServicesPage;
2 changes: 1 addition & 1 deletion frontend/web/components/dashboard/menu/DashboardMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DashboardMenu = ({ isFull }: DashboardMenuProps) => (
</li>
<DashboardMenuLink icon="objects-column" title="Dashboard" href="/dashboard" isFull={isFull} />
<DashboardMenuLink icon="bolt" title="Library" href="/dashboard/library" isFull={isFull} />
<DashboardMenuLink icon="grid-2-plus" title="Apps" href="/dashboard/services" isFull={isFull} />
<DashboardMenuLink icon="grid-2-plus" title="Services" href="/dashboard/services" isFull={isFull} />
</ul>
);

Expand Down
8 changes: 5 additions & 3 deletions frontend/web/components/editor/ServicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const ServiceElement = ({
type ServicesListProps = {
services: Service[];
nbPerLine: number;
selectedServiceId: string | undefined;
setSelectedService: (serviceId: string) => void;
selectedServiceId?: string;
setSelectedService?: (serviceId: string) => void;
};
const ServicesList = ({ services, nbPerLine, selectedServiceId, setSelectedService }: ServicesListProps) => {
const servicesChunks = splitArrayInChunks(services, nbPerLine);
Expand All @@ -39,7 +39,9 @@ const ServicesList = ({ services, nbPerLine, selectedServiceId, setSelectedServi
{chunk.map((service) => (
<ServiceElement
service={service}
onClick={() => setSelectedService(service.id)}
onClick={() => {
if (setSelectedService) setSelectedService(service.id);
}}
key={service.id}
selected={selectedServiceId === service.id}
/>
Expand Down
4 changes: 1 addition & 3 deletions frontend/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const nextConfig = {
remotePatterns: [
{
protocol: "https",
hostname: "daisyui.com",
port: "",
pathname: "/**",
hostname: "**",
},
],
},
Expand Down

0 comments on commit 63e237d

Please sign in to comment.