From 55203eb537e74db23e413c290d2a165fe5488c11 Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 14:39:49 +0800 Subject: [PATCH 01/14] fix(app): sort trash bin page latesy by default --- .../trash-bin/trashbin/trashbin.page.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/app/src/pages/operator/trash-bin/trashbin/trashbin.page.tsx b/apps/app/src/pages/operator/trash-bin/trashbin/trashbin.page.tsx index 734909e..987711b 100644 --- a/apps/app/src/pages/operator/trash-bin/trashbin/trashbin.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/trashbin/trashbin.page.tsx @@ -13,6 +13,7 @@ import { useHistory } from "react-router-dom"; import { useState } from "react"; import Fuse from "fuse.js"; import { useTranslation } from "react-i18next"; +import dayjs from "dayjs"; export interface InterfaceTrashbin { id: number; @@ -41,14 +42,25 @@ export function TrashBinPage() { refetch(); }); + function filterAndSortLatest(data: InterfaceTrashbin[]) { + return data + .filter((trashbin) => dayjs(trashbin.createdAt)) + .sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()); + } + const fuseOptions = { keys: ["name"], threshold: 0.4, }; - const fuse = new Fuse(!isLoading ? (trashBinData.data as InterfaceTrashbin[]) : [], fuseOptions); + const fuse = new Fuse( + !isLoading ? (filterAndSortLatest(trashBinData.data) as InterfaceTrashbin[]) : [], + fuseOptions + ); const filteredData: InterfaceTrashbin[] = - !isLoading && searchTerm === "" ? trashBinData.data : fuse.search(searchTerm).map((result) => result.item); + !isLoading && searchTerm === "" + ? filterAndSortLatest(trashBinData.data) + : fuse.search(searchTerm).map((result) => result.item); function handleRefresh(event: CustomEvent) { queryClient.invalidateQueries({ From d02e269c349d77b8bf6db9bccfd9a6cd7c7c2a38 Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 14:46:05 +0800 Subject: [PATCH 02/14] fix(app): sort sub trash bin page latesy by default --- .../trashbin/sub-trashbin/subtrashbin.page.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx index de20e33..ba0f853 100644 --- a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx @@ -13,6 +13,7 @@ import { useState } from "react"; import Fuse from "fuse.js"; import { useGetSubTrashbins } from "./get-subtrashbins.query"; import { useTranslation } from "react-i18next"; +import dayjs from "dayjs"; export interface InterfaceSubTrashbin { id: number; @@ -20,6 +21,7 @@ export interface InterfaceSubTrashbin { name: string; maxCapacity: number; currentCapacity: number; + createdAt: string; } export function SubTrashbinPage() { @@ -44,13 +46,22 @@ export function SubTrashbinPage() { threshold: 0.4, }; + function filterAndSortLatest(data: InterfaceSubTrashbin[]) { + return data + .filter((subtrashbin) => dayjs(subtrashbin.createdAt)) + .sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()); + } + const filteredDataForId = !isLoading ? subtrashBinData.data.filter( (subtrashbin: InterfaceSubTrashbin) => subtrashbin.trashBinId === Number(trashbin_id) ) : []; - const fuse = new Fuse(!isLoading ? (filteredDataForId as InterfaceSubTrashbin[]) : [], fuseOptions); + const fuse = new Fuse( + !isLoading ? (filterAndSortLatest(filteredDataForId) as InterfaceSubTrashbin[]) : [], + fuseOptions + ); const filteredData: InterfaceSubTrashbin[] = !isLoading && searchTerm === "" ? filteredDataForId : fuse.search(searchTerm).map((result) => result.item); From 63a35679802153f2670b9a88b5d60cca238ee212 Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:05:29 +0800 Subject: [PATCH 03/14] fix(app): set history page filter type to latest #28 --- .../operator/trash-bin/trashbin/sub-trashbin/history.page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/history.page.tsx b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/history.page.tsx index d66597b..9a63d95 100644 --- a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/history.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/history.page.tsx @@ -26,7 +26,7 @@ export function TrashPage() { const history = useHistory(); const queryClient = useQueryClient(); const { trashbin_id, subtrashbin_id } = useParams<{ trashbin_id: string; subtrashbin_id: string }>(); - const [filterType, setFilterType] = useState<"latest" | "oldest" | "none">("none"); + const [filterType, setFilterType] = useState<"latest" | "oldest" | "none">("latest"); const { data: historyData, isLoading, isFetching, isError, error, refetch } = useGetHistories(); From 3e4c5968f54e37ed8f9de7a0f5478e2255c19481 Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:06:34 +0800 Subject: [PATCH 04/14] fix(app): set trash page filter type to latest #27 --- .../operator/trash-bin/trashbin/sub-trashbin/trash.page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/trash.page.tsx b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/trash.page.tsx index 3903163..47a8be8 100644 --- a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/trash.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/trash.page.tsx @@ -24,7 +24,7 @@ export function TrashPage() { const history = useHistory(); const queryClient = useQueryClient(); const { trashbin_id, subtrashbin_id } = useParams<{ trashbin_id: string; subtrashbin_id: string }>(); - const [filterType, setFilterType] = useState<"latest" | "oldest" | "none">("none"); + const [filterType, setFilterType] = useState<"latest" | "oldest" | "none">("latest"); const { t } = useTranslation(); const { data: trashData, isLoading, isFetching, isError, error, refetch } = useGetTrashes(); From 2387896d982b65e310d229d862dd276acc92731d Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:16:34 +0800 Subject: [PATCH 05/14] fix(app): sort reports by latest #29 --- .../pages/operator/trash-bin/report/reports.page.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/app/src/pages/operator/trash-bin/report/reports.page.tsx b/apps/app/src/pages/operator/trash-bin/report/reports.page.tsx index 01f83bf..bd52d2c 100644 --- a/apps/app/src/pages/operator/trash-bin/report/reports.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/report/reports.page.tsx @@ -11,6 +11,7 @@ import { useState } from "react"; import { InterfaceResult, useGetReportsWithTrashBins } from "./get-trash-and-report.query"; import Fuse from "fuse.js"; import { useTranslation } from "react-i18next"; +import dayjs from "dayjs"; export enum EnumResponseStatus { NOT_RESPONDED = "notResponded", @@ -105,13 +106,21 @@ export function ReportsPage() { threshold: 0.4, }; + function filterAndSortLatest(data: InterfaceReport[]) { + return data + .filter((report) => dayjs(report.createdAt)) + .sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()); + } + let data: InterfaceResult[] = []; const fuse = new Fuse(data, fuseOptions); if (isReportsLoading || isTrashBinsLoading) { console.log("Loading..."); } else { - data = reports.data.map((re: InterfaceReport) => { + const filter_by_latest_first = filterAndSortLatest(reports.data); + + data = filter_by_latest_first.map((re: InterfaceReport) => { const trashBin = trashBins.data.find((tb: InterfaceTrashbin) => tb.id === re.trashBinId); return { ...re, From 616f7ea1dce7a2d87575c6a03379a5a5b1a407bd Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:19:01 +0800 Subject: [PATCH 06/14] fix(app): sort trashbin on complaint page latest by default --- apps/app/src/pages/complain/form/tempat-sampah.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/app/src/pages/complain/form/tempat-sampah.tsx b/apps/app/src/pages/complain/form/tempat-sampah.tsx index c414aa9..d36d74c 100644 --- a/apps/app/src/pages/complain/form/tempat-sampah.tsx +++ b/apps/app/src/pages/complain/form/tempat-sampah.tsx @@ -6,6 +6,7 @@ import Fuse from "fuse.js"; import { useTrashBinQuery } from "../../../queries/get-trash-bin-query"; import { useTranslation } from "react-i18next"; +import dayjs from "dayjs"; interface TrashBin { id: number; @@ -13,6 +14,7 @@ interface TrashBin { description: string; latitude: number; longitude: number; + createdAt: string; } export function ComplainFormTempatSampah() { @@ -26,11 +28,19 @@ export function ComplainFormTempatSampah() { threshold: 0.4, }; - const fuse = new Fuse(!isLoading ? (data.data as TrashBin[]) : [], fuseOptions); + function filterAndSortLatest(data: TrashBin[]) { + return data + .filter((trashbin) => dayjs(trashbin.createdAt)) + .sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()); + } + + const fuse = new Fuse(!isLoading ? (filterAndSortLatest(data.data) as TrashBin[]) : [], fuseOptions); // eslint-disable-next-line @typescript-eslint/no-explicit-any const filteredData: any[] = - !isLoading && searchTerm === "" ? data.data : fuse.search(searchTerm).map((result) => result.item); + !isLoading && searchTerm === "" + ? filterAndSortLatest(data.data) + : fuse.search(searchTerm).map((result) => result.item); return ( From 40eb62181ac245e6468388d21e749b70151e204d Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:25:20 +0800 Subject: [PATCH 07/14] fix(app): sort riwayat laporan on complain by latest by default --- apps/app/src/pages/complain/form/report-history.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/app/src/pages/complain/form/report-history.tsx b/apps/app/src/pages/complain/form/report-history.tsx index d5036d5..a302758 100644 --- a/apps/app/src/pages/complain/form/report-history.tsx +++ b/apps/app/src/pages/complain/form/report-history.tsx @@ -16,6 +16,7 @@ import { EnumResponseStatus, InterfaceReport } from "../../operator/trash-bin/re import { useGetTrashBinById } from "../../operator/trash-bin/report/get-trash-bin.query"; import { useTranslation } from "react-i18next"; import { t } from "i18next"; +import dayjs from "dayjs"; function ReportStatus({ status }: { status: EnumResponseStatus }) { return ( @@ -105,6 +106,12 @@ export function ComplainReportHistory() { refetch(); }); + function filterAndSortLatest(data: InterfaceReport[]) { + return data + .filter((report) => dayjs(report.createdAt)) + .sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()); + } + function handleRefresh(event: CustomEvent) { queryClient.invalidateQueries({ queryKey: ["getRepgetReportByNikorts", String(nik)], @@ -114,6 +121,8 @@ export function ComplainReportHistory() { event.detail.complete(); } + const sortedData = reportData ? filterAndSortLatest(reportData.data) : []; + return ( @@ -153,7 +162,7 @@ export function ComplainReportHistory() { ) : ( - reportData.data.map((report: InterfaceReport) => ( + sortedData.map((report: InterfaceReport) => ( history.push(`/complain/tabs/form/report-history/feedback/${report.id}`)} key={report.id} From 50daed48c5057a5f8c8739e9b268c86a4b486992 Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 15:35:31 +0800 Subject: [PATCH 08/14] fix(app): remove disabling feedback button and show view feedback on status complete #30 --- apps/app/src/locales/en.json | 1 + apps/app/src/locales/id.json | 1 + .../pages/operator/trash-bin/report/detailed-report.page.tsx | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/app/src/locales/en.json b/apps/app/src/locales/en.json index d16091f..c72008f 100644 --- a/apps/app/src/locales/en.json +++ b/apps/app/src/locales/en.json @@ -310,6 +310,7 @@ "status": "Report Status", "photo": "Report Photo", "submitFeedback": "Submit Feedback", + "view_feedback": "Feedback", "action": "Actions", "actions": { "title": "Report Actions", diff --git a/apps/app/src/locales/id.json b/apps/app/src/locales/id.json index e025107..00eab65 100644 --- a/apps/app/src/locales/id.json +++ b/apps/app/src/locales/id.json @@ -310,6 +310,7 @@ "status": "Status Laporan", "photo": "Foto Laporan", "submitFeedback": "Kirim Tanggapan", + "view_feedback": "Tanggapan", "actions": { "title": "Tindakan Laporan", "loading": "Loading...", diff --git a/apps/app/src/pages/operator/trash-bin/report/detailed-report.page.tsx b/apps/app/src/pages/operator/trash-bin/report/detailed-report.page.tsx index 371ce2d..4f8a0a9 100644 --- a/apps/app/src/pages/operator/trash-bin/report/detailed-report.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/report/detailed-report.page.tsx @@ -279,10 +279,11 @@ export function DetailedReportPage() {
Date: Sat, 2 Mar 2024 15:47:18 +0800 Subject: [PATCH 09/14] fix(app): disable create tanggapan aru and hapus on status completed #30 --- .../report/report-feedback/feedback.page.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/app/src/pages/operator/trash-bin/report/report-feedback/feedback.page.tsx b/apps/app/src/pages/operator/trash-bin/report/report-feedback/feedback.page.tsx index 2f5815f..33784aa 100644 --- a/apps/app/src/pages/operator/trash-bin/report/report-feedback/feedback.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/report/report-feedback/feedback.page.tsx @@ -17,6 +17,8 @@ import { CapacitorHttp } from "@capacitor/core"; import { queryClient } from "../../../../../main"; import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { EnumResponseStatus, InterfaceReport } from "../reports.page"; +import { useGetReportsWithTrashBins } from "../get-trash-and-report.query"; export interface InterfaceFeedback { id: number; @@ -99,6 +101,17 @@ export function FeedbackPage() { const [isOpen, setIsOpen] = useState(false); const { t } = useTranslation(); + const { reports, trashBins, isReportsLoading, isTrashBinsLoading } = useGetReportsWithTrashBins(); + let filter_report: InterfaceReport = !isReportsLoading + ? reports.data.find((report: InterfaceReport) => report.id === Number(report_id)) + : { id: 0, trashBinId: 0, status: "", createdAt: "" }; + + if (isReportsLoading || isTrashBinsLoading) { + console.log("Loading..."); + } else { + filter_report = reports.data.find((report: InterfaceReport) => report.id === Number(report_id)); + } + const { data: feedbackData, isError, error, isLoading, refetch, isRefetching } = useGetFeedbacks(); const filteredData = !isLoading ? feedbackData.data.filter((feedback: InterfaceFeedback) => feedback.reportId === Number(report_id)) @@ -123,6 +136,7 @@ export function FeedbackPage() {
From 6b40a5f23c4dc17167c631d004f66ac6a1c37ace Mon Sep 17 00:00:00 2001 From: elizielx Date: Sat, 2 Mar 2024 16:13:34 +0800 Subject: [PATCH 11/14] fix(app): show capacity on subtrashbin list page #32 --- apps/app/src/locales/en.json | 1 + apps/app/src/locales/id.json | 1 + .../trashbin/sub-trashbin/subtrashbin.page.tsx | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/app/src/locales/en.json b/apps/app/src/locales/en.json index c72008f..7b96d1e 100644 --- a/apps/app/src/locales/en.json +++ b/apps/app/src/locales/en.json @@ -243,6 +243,7 @@ "view_subtrashbin": "View Sub Trash Bin", "view_trash": "View Trash", "view_history": "View History", + "capacity": "Capacity", "trash": { "subtitle": "Trash", "filter_oldest": "Filter by Oldest", diff --git a/apps/app/src/locales/id.json b/apps/app/src/locales/id.json index 00eab65..4527b4e 100644 --- a/apps/app/src/locales/id.json +++ b/apps/app/src/locales/id.json @@ -243,6 +243,7 @@ "view_subtrashbin": "Lihat Sub Tempat Sampah", "view_trash": "Lihat Sampah", "view_history": "Lihat Riwayat", + "capacity": "Kapasitas", "trash": { "subtitle": "Sampah", "filter_oldest": "Filter Terlama", diff --git a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx index ba0f853..4b232b3 100644 --- a/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx +++ b/apps/app/src/pages/operator/trash-bin/trashbin/sub-trashbin/subtrashbin.page.tsx @@ -143,7 +143,17 @@ export function SubTrashbinPage() {
-

{subtrashbin.name}

+

{subtrashbin.name}

+

+ {t("operator.subtrashbin.capacity")}:{" "} + {subtrashbin?.currentCapacity === 0 + ? 0 + : 100 - + (((subtrashbin?.currentCapacity as number) / + (subtrashbin?.maxCapacity ?? 0)) as number) * + 100} + % / 100% +