Bug 32939: Use APIClient to fetch patrons
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>
(cherry picked from commit 66dd767813)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
753cb37244
commit
ecddc79178
|
|
@ -64,7 +64,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchPatron } from "../../fetch/erm.js"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
|
||||
export default {
|
||||
name: "UserRoles",
|
||||
|
|
@ -110,8 +110,9 @@ export default {
|
|||
let selected_patron_id =
|
||||
document.getElementById("selected_patron_id").value
|
||||
let patron
|
||||
const client = APIClient.patron
|
||||
// FIXME We are missing a "loading..."
|
||||
fetchPatron(selected_patron_id).then(p => {
|
||||
client.patrons.get(selected_patron_id).then(p => {
|
||||
patron = p
|
||||
this.user_roles[c].patron = patron
|
||||
this.user_roles[c].patron_str = $patron_to_html(patron)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import ERMAPIClient from "./erm-api-client";
|
||||
import PatronAPIClient from "./patron-api-client";
|
||||
|
||||
export const APIClient = {
|
||||
erm: new ERMAPIClient(),
|
||||
patron: new PatronAPIClient(),
|
||||
};
|
||||
|
|
@ -2,12 +2,6 @@ import { setError } from "../messages";
|
|||
|
||||
//TODO: all of these functions should be deleted and reimplemented in the components using ERMAPIClient
|
||||
|
||||
export const fetchPatron = function (patron_id) {
|
||||
if (!patron_id) return;
|
||||
const apiUrl = "/api/v1/patrons/" + patron_id;
|
||||
return myFetch(apiUrl);
|
||||
};
|
||||
|
||||
export const fetchVendors = function () {
|
||||
const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
|
||||
return myFetch(apiUrl);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import HttpClient from "./http-client";
|
||||
|
||||
export class PatronAPIClient extends HttpClient {
|
||||
constructor() {
|
||||
super({
|
||||
baseURL: "/api/v1/",
|
||||
});
|
||||
}
|
||||
|
||||
get patrons() {
|
||||
return {
|
||||
get: (id) =>
|
||||
this.get({
|
||||
endpoint: "patrons/" + id,
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default PatronAPIClient;
|
||||
Loading…
Reference in New Issue