- implement setup page with video feed and preview functionality
This commit is contained in:
19
src/features/setup/hooks/useVideoPreview.ts
Normal file
19
src/features/setup/hooks/useVideoPreview.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { cambase } from "../../../app/config";
|
||||
|
||||
const fetchVideoPreview = async () => {
|
||||
const response = await fetch(`${cambase}/Colour-preview`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch video preview");
|
||||
}
|
||||
return response.blob();
|
||||
};
|
||||
|
||||
export const useVideoPreview = () => {
|
||||
const videoPreviewQuery = useQuery({
|
||||
queryKey: ["videoPreview"],
|
||||
queryFn: fetchVideoPreview,
|
||||
refetchInterval: 100,
|
||||
});
|
||||
return { videoPreviewQuery };
|
||||
};
|
||||
Reference in New Issue
Block a user