30 lines
785 B
JavaScript
30 lines
785 B
JavaScript
import { ref } from "vue";
|
|
import { useLoadsStore } from "../stores/loads";
|
|
import api from "../lib/axios";
|
|
|
|
export default function useAttachments() {
|
|
|
|
const loading = ref(false);
|
|
const attachments = ref(null);
|
|
const loadStore = useLoadsStore();
|
|
|
|
const getAttachmentLoad = async() => {
|
|
try {
|
|
loading.value = true;
|
|
const endpoint = "/v1" + "/load-attachments/load/" + loadStore.currentLoad._id;
|
|
const {data} = await api.get(endpoint);
|
|
attachments.value = data;
|
|
} catch (error) {
|
|
attachments.value = null;
|
|
console.log(error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
return {
|
|
getAttachmentLoad,
|
|
loading,
|
|
attachments
|
|
}
|
|
} |