Bug 32939: Use APIClient to fetch vendors

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-02-21 10:50:02 +01:00 committed by Tomas Cohen Arazi
parent 66dd767813
commit 2d86a671f2
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 31 additions and 7 deletions

View File

@ -122,7 +122,7 @@
import { inject } from "vue"
import Breadcrumb from "../../components/Breadcrumb.vue"
import Dialog from "../../components/Dialog.vue"
import { fetchVendors } from "../../fetch/erm.js"
import { APIClient } from "../../fetch/api-client.js"
import "vue-select/dist/vue-select.css"
export default {
@ -154,7 +154,14 @@ export default {
}
},
beforeCreate() {
fetchVendors().then(vendors => (this.vendorStore.vendors = vendors))
const client = APIClient.acquisition
client.vendors.getAll().then(
vendors => {
this.vendors = vendors
this.initialized = true
},
error => {}
)
},
components: {
Breadcrumb,

View File

@ -0,0 +1,20 @@
import HttpClient from "./http-client";
export class AcquisitionAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/api/v1/acquisitions/",
});
}
get vendors() {
return {
getAll: (query) =>
this.get({
endpoint: "vendors?" + (query || "_per_page=-1"),
}),
};
}
}
export default AcquisitionAPIClient;

View File

@ -1,7 +1,9 @@
import ERMAPIClient from "./erm-api-client";
import PatronAPIClient from "./patron-api-client";
import AcquisitionAPIClient from "./acquisition-api-client";
export const APIClient = {
erm: new ERMAPIClient(),
patron: new PatronAPIClient(),
acquisition: new AcquisitionAPIClient(),
};

View File

@ -2,11 +2,6 @@ import { setError } from "../messages";
//TODO: all of these functions should be deleted and reimplemented in the components using ERMAPIClient
export const fetchVendors = function () {
const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
return myFetch(apiUrl);
};
const _createEditPackage = function (method, erm_package) {
let apiUrl = "/api/v1/erm/eholdings/local/packages";