Quantumbraid's picture
download
raw
891 Bytes
'use client';
import { useState } from 'react';
import { Job } from '@prisma/client';
import { apiClient } from '@/utils/api';
import usePollLoop from '@/hooks/usePollLoop';
export default function useJob(jobID: string, reloadInterval: null | number = null) {
const [job, setJob] = useState<Job | null>(null);
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
const refreshJob = () => {
setStatus('loading');
return apiClient
.get(`/api/jobs?id=${jobID}`)
.then(res => res.data)
.then(data => {
console.log('Job:', data);
setJob(data);
setStatus('success');
})
.catch(error => {
console.error('Error fetching datasets:', error);
setStatus('error');
});
};
usePollLoop(refreshJob, reloadInterval, [jobID]);
return { job, setJob, status, refreshJob };
}

Xet Storage Details

Size:
891 Bytes
·
Xet hash:
d3f2c23983be32c41b543ddd4287b819e4848f1355fd1958819b12eb1b9286ca

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.