This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
ef99866
commit fbe73e1
Showing
17 changed files
with
414 additions
and
58 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
75 changes: 75 additions & 0 deletions
75
apps/app/src/pages/operator/trash-bin/report/detailed-report.page.tsx
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,75 @@ | ||
import { IonContent, IonPage } from "@ionic/react"; | ||
import { useGetReportById } from "./get-report.query"; | ||
import { useHistory, useParams } from "react-router-dom"; | ||
import { Button, Card, CardContent, CardHeader, Skeleton } from "@trashtrack/ui"; | ||
import { InterfaceReport } from "./reports.page"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export function DetailedReportPage() { | ||
const history = useHistory(); | ||
const { report_id } = useParams<{ report_id: string }>(); | ||
const { data: reportData, isError, error, isLoading } = useGetReportById(Number(report_id)); | ||
const [imageUrl, setImageUrl] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
if (!isLoading && reportData) { | ||
const uint8Array = new Uint8Array(reportData.data.imageData); | ||
const blob = new Blob([uint8Array], { type: "image/jpeg" }); | ||
setImageUrl(URL.createObjectURL(blob)); | ||
} | ||
}, [isLoading, reportData]); | ||
|
||
return ( | ||
<IonPage> | ||
<IonContent className="ion-padding" fullscreen> | ||
<div className="pt-12"> | ||
<h1 className="font-bold text-left text-xl">TrashTrack</h1> | ||
<p className="text-xs text-left text-slate-600">Detailed Report for TrashBin ID: {report_id}</p> | ||
</div> | ||
<div className="flex flex-col pt-8 gap-2"> | ||
{isError && ( | ||
<Card className="flex flex-col mt-4"> | ||
<CardContent className="pt-4"> | ||
<p className="text-center text-xs">{JSON.stringify(error)}</p> | ||
</CardContent> | ||
</Card> | ||
)} | ||
{isLoading ? ( | ||
<Card className="flex flex-col mt-4"> | ||
<CardContent className="pt-4"> | ||
<CardHeader> | ||
<Skeleton className="h-4 w-20" /> | ||
</CardHeader> | ||
<CardContent className="flex flex-col gap-2"> | ||
<Skeleton className="h-4 w-40" /> | ||
<Skeleton className="h-4 w-40" /> | ||
<Skeleton className="h-4 w-40" /> | ||
</CardContent> | ||
</CardContent> | ||
</Card> | ||
) : ( | ||
<Card className="flex flex-col mt-4"> | ||
<CardContent className="pt-4"> | ||
<div className="flex flex-col gap-2"> | ||
<p className="text-xs text-left">{reportData.data.name}</p> | ||
<img | ||
src={imageUrl ? imageUrl : "https://via.placeholder.com/150"} | ||
className="w-full h-object-cover" | ||
alt="" | ||
/> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
)} | ||
<Card className="flex flex-col mt-4"> | ||
<CardContent className="pt-4"> | ||
<Button variant="secondary" onClick={() => history.goBack()}> | ||
Back | ||
</Button> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
</IonContent> | ||
</IonPage> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/app/src/pages/operator/trash-bin/report/get-report.query.tsx
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,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { API_URL } from "@trashtrack/utils"; | ||
import { CapacitorHttp } from "@capacitor/core"; | ||
|
||
export const useGetReportById = (reportId: number) => { | ||
return useQuery({ | ||
queryKey: ["getReportById", reportId], | ||
queryFn: () => | ||
CapacitorHttp.request({ | ||
url: API_URL + `/report/id/${reportId}`, | ||
method: "GET", | ||
}).then((res) => res.data), | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
apps/app/src/pages/operator/trash-bin/report/get-reports.query.tsx
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,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { API_URL } from "@trashtrack/utils"; | ||
import { CapacitorHttp } from "@capacitor/core"; | ||
|
||
export const useGetReports = () => { | ||
return useQuery({ | ||
queryKey: ["getReports"], | ||
queryFn: () => | ||
CapacitorHttp.request({ | ||
url: API_URL + `/report`, | ||
method: "GET", | ||
}).then((res) => res.data), | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
apps/app/src/pages/operator/trash-bin/report/get-trash-bin.query.tsx
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 { useQuery } from "@tanstack/react-query"; | ||
import { API_URL } from "@trashtrack/utils"; | ||
import { CapacitorHttp } from "@capacitor/core"; | ||
|
||
export const useGetTrashBinById = (trashBinId: number, userId: number) => { | ||
return useQuery({ | ||
queryKey: ["getTrashBinById", trashBinId, userId], | ||
queryFn: () => | ||
CapacitorHttp.request({ | ||
url: API_URL + `/trash-bin/id/${trashBinId}`, | ||
method: "GET", | ||
}).then((res) => res.data), | ||
enabled: !!userId, | ||
}); | ||
}; |
24 changes: 0 additions & 24 deletions
24
apps/app/src/pages/operator/trash-bin/report/report-action.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.