1import { d as defineStore, z as useRetailApi, aW as useRetailRegisterStore } from "./app-DHoh64oC.js"; 2import { x as ref } from "./vendor-CmzCb6hx.js"; 3const useRetailRentalsStore = defineStore("retailRentals", function() { 4 const { get, post } = useRetailApi(); 5 const rentals = ref([]); 6 const available = ref([]); 7 const isLoading = ref(false); 8 const filter = ref("available"); 9 async function loadAll() { 10 const registerStore = useRetailRegisterStore(); 11 const locationId = registerStore.locationId; 12 isLoading.value = true; 13 try { 14 const [rentalsData, availableData] = await Promise.all([ 15 get("rentals/list", { location_id: locationId }, { silent: true }), 16 get("rentals/list-available", { location_id: locationId }, { silent: true }) 17 ]); 18 rentals.value = rentalsData.rentals || []; 19 available.value = availableData.available || []; 20 } finally { 21 isLoading.value = false; 22 } 23 } 24 async function returnRental(rentalId) { 25 await post("rentals/return", { rental_id: rentalId }); 26 await loadAll(); 27 } 28 async function fetchSerialsForRental(productCode) { 29 const registerStore = useRetailRegisterStore(); 30 const data = await get("rentals/serials-for-rental", { 31 location_id: registerStore.locationId, 32 product_code: productCode 33 }, { silent: true }); 34 return data.serials || []; 35 } 36 async function addRentalFirearm(payload) { 37 await post("rentals/add-rental-firearm", payload); 38 await loadAll(); 39 } 40 async function updateRentalFirearm(payload) { 41 await post("rentals/update-rental-firearm", payload); 42 await loadAll(); 43 } 44 async function convertToUsed(payload) { 45 await post("rentals/convert-to-used", payload); 46 await loadAll(); 47 } 48 async function createRangeGunWorkOrder(inventoryId, statusId, locationId, employeeUserId, serialNumberId, fflId = null) { 49 await post("repair-cleaning/range-gun-repair-cleaning", { 50 in_store_use_location_inventory_id: inventoryId, 51 serial_number_id: serialNumberId, 52 repair_cleaning_status_id: statusId, 53 location_id: locationId, 54 employee_user_id: employeeUserId, 55 ...fflId ? { ffl_id: fflId } : {} 56 }); 57 await loadAll(); 58 } 59 function $reset() { 60 rentals.value = []; 61 available.value = []; 62 isLoading.value = false; 63 filter.value = "available"; 64 } 65 return { 66 rentals, 67 available, 68 isLoading, 69 filter, 70 loadAll, 71 returnRental, 72 fetchSerialsForRental, 73 convertToUsed, 74 addRentalFirearm, 75 updateRentalFirearm, 76 createRangeGunWorkOrder, 77 $reset 78 }; 79}); 80export { 81 useRetailRentalsStore as u 82};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.