From 8abc4396ac1d0447931afac628b99de29b5a2168 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Fri, 30 May 2025 21:27:59 +0200 Subject: [PATCH] feat: integrate admin store in api services tab --- web/src/pages/ApiServices/index.tsx | 186 ++++++++++++++++------------ 1 file changed, 109 insertions(+), 77 deletions(-) diff --git a/web/src/pages/ApiServices/index.tsx b/web/src/pages/ApiServices/index.tsx index 6260e55..f7e0e25 100644 --- a/web/src/pages/ApiServices/index.tsx +++ b/web/src/pages/ApiServices/index.tsx @@ -1,100 +1,132 @@ -import type { FC } from "react"; +import { useAdmin } from "@/store/admin"; +import { useEffect, type FC } from "react"; import { Link } from "react-router"; -const services = [ - { - id: "1", - name: "User Service", - clientId: "user-svc-001", - isActive: true, - createdAt: "2024-09-15T10:20:30Z", - updatedAt: "2025-01-10T12:00:00Z", - }, - { - id: "2", - name: "Billing Service", - clientId: "billing-svc-009", - isActive: false, - createdAt: "2024-10-01T08:45:10Z", - updatedAt: "2025-03-22T14:30:00Z", - }, - { - id: "3", - name: "Analytics Service", - clientId: "analytics-svc-777", - isActive: true, - createdAt: "2024-11-25T16:00:00Z", - updatedAt: "2025-02-05T10:15:45Z", - }, - { - id: "4", - name: "Email Service", - clientId: "email-svc-333", - isActive: false, - createdAt: "2023-07-10T13:00:00Z", - updatedAt: "2024-12-31T09:25:00Z", - }, -]; +// const services = [ +// { +// id: "1", +// name: "User Service", +// clientId: "user-svc-001", +// isActive: true, +// createdAt: "2024-09-15T10:20:30Z", +// updatedAt: "2025-01-10T12:00:00Z", +// }, +// { +// id: "2", +// name: "Billing Service", +// clientId: "billing-svc-009", +// isActive: false, +// createdAt: "2024-10-01T08:45:10Z", +// updatedAt: "2025-03-22T14:30:00Z", +// }, +// { +// id: "3", +// name: "Analytics Service", +// clientId: "analytics-svc-777", +// isActive: true, +// createdAt: "2024-11-25T16:00:00Z", +// updatedAt: "2025-02-05T10:15:45Z", +// }, +// { +// id: "4", +// name: "Email Service", +// clientId: "email-svc-333", +// isActive: false, +// createdAt: "2023-07-10T13:00:00Z", +// updatedAt: "2024-12-31T09:25:00Z", +// }, +// ]; const ApiServicesPage: FC = () => { + const apiServices = useAdmin((state) => state.apiServices); + const loading = useAdmin((state) => state.loadingApiServices); + const fetchApiServices = useAdmin((state) => state.fetchApiServices); + + useEffect(() => { + fetchApiServices(); + }, [fetchApiServices]); + return ( -
- - +
+
+

Search...

+
+ + {loading && ( +
+
+ Loading... +
+
+ )} + +
+ - - - - - - - {services.map((service) => ( - - - - - - + {!loading && apiServices.length === 0 ? ( + + - ))} + ) : ( + apiServices.map((service) => ( + + + + + + + + )) + )}
+ Name + Client ID + Is Active + Created At + Updated At
- - {service.name} - - - {service.clientId} - - - {service.isActive ? "Yes" : "No"} - - - {new Date(service.createdAt).toLocaleString()} - - {new Date(service.updatedAt).toLocaleString()} +
+ No services found.
+ + {service.name} + + + {service.client_id} + + + {service.is_active ? "Yes" : "No"} + + + {new Date(service.created_at).toLocaleString()} + + {new Date(service.updated_at).toLocaleString()} +