20 lines
518 B
TypeScript
20 lines
518 B
TypeScript
|
|
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 };
|
||
|
|
};
|