Buckets:
| 'use client'; | |
| import { useState } from 'react'; | |
| import { Job } from '@prisma/client'; | |
| import { apiClient } from '@/utils/api'; | |
| import usePollLoop from '@/hooks/usePollLoop'; | |
| export default function useJobByRef(jobRef: string | null, 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?job_ref=${jobRef}`) | |
| .then(res => res.data) | |
| .then(data => { | |
| console.log('Job:', data); | |
| setJob(data); | |
| setStatus('success'); | |
| }) | |
| .catch(error => { | |
| console.error('Error fetching job:', error); | |
| setStatus('error'); | |
| }); | |
| }; | |
| usePollLoop(refreshJob, reloadInterval, [jobRef]); | |
| return { job, setJob, status, refreshJob }; | |
| } | |
Xet Storage Details
- Size:
- 906 Bytes
- Xet hash:
- 963e0e9a2c4e509f207b3c88f9d5a39c6a045a3d71bc848c6b405acce1527796
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.