Add ability to submit to frigate+ from review panel

This commit is contained in:
Nicolas Mowen 2024-08-14 13:19:57 -06:00
parent 08ca6f8886
commit d3ad325473

View File

@ -8,7 +8,9 @@ import { getIconForLabel } from "@/utils/iconUtil";
import { useApiHost } from "@/api"; import { useApiHost } from "@/api";
import { ReviewSegment } from "@/types/review"; import { ReviewSegment } from "@/types/review";
import { Event } from "@/types/event"; import { Event } from "@/types/event";
import { useMemo } from "react"; import { useMemo, useState } from "react";
import { cn } from "@/lib/utils";
import { FrigatePlusDialog } from "../dialog/FrigatePlusDialog";
type ReviewDetailDialogProps = { type ReviewDetailDialogProps = {
review?: ReviewSegment; review?: ReviewSegment;
@ -24,6 +26,10 @@ export default function ReviewDetailDialog({
const apiHost = useApiHost(); const apiHost = useApiHost();
// upload
const [upload, setUpload] = useState<Event>();
// data // data
const { data: events } = useSWR<Event[]>( const { data: events } = useSWR<Event[]>(
@ -59,6 +65,16 @@ export default function ReviewDetailDialog({
} }
}} }}
> >
<FrigatePlusDialog
upload={upload}
onClose={() => setUpload(undefined)}
onEventUploaded={() => {
if (upload) {
upload.plus_id = "1234";
}
}}
/>
<Content <Content
className={ className={
isDesktop ? "sm:max-w-xl" : "max-h-[75dvh] overflow-hidden p-2 pb-4" isDesktop ? "sm:max-w-xl" : "max-h-[75dvh] overflow-hidden p-2 pb-4"
@ -127,7 +143,12 @@ export default function ReviewDetailDialog({
return ( return (
<img <img
key={event.id} key={event.id}
className="aspect-video select-none rounded-lg object-contain transition-opacity" className={cn(
"aspect-video select-none rounded-lg object-contain transition-opacity",
event.has_snapshot &&
event.plus_id == undefined &&
"cursor-pointer",
)}
style={ style={
isIOS isIOS
? { ? {
@ -142,6 +163,11 @@ export default function ReviewDetailDialog({
? `${apiHost}api/events/${event.id}/snapshot.jpg` ? `${apiHost}api/events/${event.id}/snapshot.jpg`
: `${apiHost}api/events/${event.id}/thumbnail.jpg` : `${apiHost}api/events/${event.id}/thumbnail.jpg`
} }
onClick={() => {
if (event.has_snapshot && event.plus_id == undefined) {
setUpload(event);
}
}}
/> />
); );
})} })}