product_give_back.js 976 B

123456789101112131415161718192021222324252627282930313233
  1. import { rents_screen } from "./rents_screen.js";
  2. import { reservation } from "./reservation.js";
  3. import { reservation_factory } from "./reservation_factory.js";
  4. import { product_give_back_request } from "./product_give_back_request.js";
  5. export class product_give_back extends rents_screen {
  6. get _name() {
  7. return "Product give back";
  8. }
  9. async _process() {
  10. try {
  11. this._info = "Processing...";
  12. const target = new reservation_factory()
  13. .email(this._email)
  14. .phone_number(this._phone)
  15. .product(this._target)
  16. .result();
  17. const request = new product_give_back_request(target);
  18. const response = await request.connect();
  19. if (!response.result) {
  20. throw new Error(response.cause);
  21. }
  22. this._success = "Success!";
  23. } catch (error) {
  24. this._error = String(error);
  25. }
  26. }
  27. }