-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0236f6
commit 22efb9c
Showing
8 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"use client"; | ||
|
||
import { useTranslation } from "react-i18next"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import DashboardPageWrapper from "@/layouts/dashboard/DashboardPageWrapper"; | ||
import { Activity } from "@/types/activity"; | ||
import services from "@/services"; | ||
|
||
const ActivityPage = () => { | ||
const { t } = useTranslation(); | ||
const [page, setPage] = useState(0); | ||
const [activities, setActivities] = useState<Activity[]>([]); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const fetchedActivities = await services.workflows.getActivities(page); | ||
setActivities(fetchedActivities.data ?? []); | ||
})(); | ||
}, [page]); | ||
|
||
return ( | ||
<DashboardPageWrapper title={t("activity.title")}> | ||
<table className="table"> | ||
<thead className="text-neutral-content"> | ||
<tr> | ||
<th>Time</th> | ||
<th>Workflow</th> | ||
<th>Activity</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{activities.map((activity) => ( | ||
<tr key={activity.id}> | ||
<td>{activity.createdAt}</td> | ||
<td>{activity.workflow.name}</td> | ||
<td>{activity.type}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
<div className="flex justify-around items-center mt-10"> | ||
<button | ||
className="btn btn-accent" | ||
onClick={() => { | ||
if (page > 0) setPage((prev) => prev - 1); | ||
}} | ||
> | ||
{t("editor.back")} | ||
</button> | ||
<span>Page {page + 1}</span> | ||
<button | ||
className="btn btn-accent" | ||
onClick={() => { | ||
if (activities.length >= 20) setPage((prev) => prev + 1); | ||
}} | ||
> | ||
{t("editor.next")} | ||
</button> | ||
</div> | ||
</DashboardPageWrapper> | ||
); | ||
}; | ||
|
||
export default ActivityPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ServiceReturn } from "@/types/api"; | ||
import { axiosInstance } from "@/services"; | ||
import { SERVICE_ERROR_UNKNOWN } from "@/config/services"; | ||
import { Activity } from "@/types/activity"; | ||
|
||
const getActivities = async (page: number): Promise<ServiceReturn<Activity[]>> => { | ||
try { | ||
const response = await axiosInstance.get<Activity[]>(`/activity?page=${page}&itemsPerPage=20`); | ||
return { data: response.data, error: undefined }; | ||
} catch (error) { | ||
return { data: null, error: SERVICE_ERROR_UNKNOWN }; | ||
} | ||
}; | ||
|
||
export default getActivities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export type Activity = { | ||
id: string; | ||
type: string; | ||
createdAt: string; | ||
workflowArea: { | ||
id: string; | ||
area: { | ||
id: string; | ||
serviceId: string; | ||
}; | ||
}; | ||
workflow: { | ||
id: string; | ||
name: string; | ||
}; | ||
}; |