mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
28 lines
587 B
TypeScript
28 lines
587 B
TypeScript
import { ref } from 'vue';
|
|
|
|
interface Request {
|
|
id: number;
|
|
employee_last_name: string;
|
|
request_type: string;
|
|
status: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export function useRequests() {
|
|
const requests = ref<Request[]>([]);
|
|
|
|
const fetchRequests = async () => {
|
|
try {
|
|
const response = await fetch('/api/requests/');
|
|
if (!response.ok) throw new Error('Failed to fetch requests');
|
|
requests.value = await response.json();
|
|
} catch (error) {
|
|
console.error('Error fetching requests:', error);
|
|
}
|
|
};
|
|
|
|
return {
|
|
requests,
|
|
fetchRequests
|
|
};
|
|
} |