UNPKG

ts-clean-core

Version:
85 lines 3.41 kB
// "use strict"; // import { IDataStoreProvider } from "../boundaries/IDataStoreProvider"; // import { ICatalogProvider } from "../boundaries/ICatalogProvider"; // import { ICatalogPresenter } from "../boundaries/ICatalogPresenter"; // import { // CatalogPresentationDS, // CustomerPresentationDS, // EquipmentPresentationDS, // LeasePresentationDS, // } from "../dataschemas/CatalogPresentation.ds"; // import { PrepareCatalogDS } from "../dataschemas/PrepareCatalog.ds"; // import { // GetBusinessInputDS, // GetBusinessOutputDS, // } from "../dataschemas/DataStore/index"; // import { Equipment } from "../domain/Equipment"; // /** // * When the user wants to view the dashboard. // * // * 1. Make sure the user is logged in and is a valid user of the business. - otherwise kick to sign-in and retire session. // * 2. Gather input from the user: // * - get the Business name. // * - retreive the users state. // * 3. Using the gathered info: // * - Show the last view the user was looking at from their state. // * - Retreive a list of customers from the provided Data Store. // * - Prepare to present the customer : name, equipment amount, expected monthly lease payment, and the date they were added. // */ // export class CatalogInteractor implements ICatalogProvider { // public constructor( // private catalogPresenter: ICatalogPresenter, // private dataAccess: IDataStoreProvider // ) {} // public prepareCatalogForPresentation(prepareCatalog: PrepareCatalogDS): void { // // Retreive data and build a catalog for presentation. // const getBusinessInput = <GetBusinessInputDS>{ // name: prepareCatalog.name, // }; // const result = this.dataAccess.getBusiness(getBusinessInput); // // console.log('Retreived data: ', JSON.stringify(result)); // if (result.error) // this.catalogPresenter.receiveCatalogForPresentation(< // CatalogPresentationDS // >{ // catalog: {}, // error: result.error, // }); // if (!result.business) // this.catalogPresenter.receiveCatalogForPresentation(< // CatalogPresentationDS // >{ // catalog: {}, // error: new Error("Something went wrong."), // }); // // Must Convert GetBusinessOutputDS to CatalogPresentationDS // let customers: Record<string, CustomerPresentationDS>; // let equipment: Record<string, EquipmentPresentationDS>; // let leases: Record<string, LeasePresentationDS>; // Object.values(result.business.customers).forEach((item, idx) => { // customers[item.name] = <CustomerPresentationDS>{ name: item.name }; // }); // Object.values(result.business.equipment).forEach((equip, idx) => { // equipment[equip.id] = <EquipmentPresentationDS>{ // id: equip.id, // year: equip.year, // make: equip.make, // model: equip.model, // miles: equip.miles, // purchase_price: equip.purchase_price, // lease_price: equip.lease_price, // }; // }); // const catalogPresentationData = <CatalogPresentationDS>{ // catalog: { // customers: customers, // equipment: equipment, // leases: {}, // }, // }; // this.catalogPresenter.receiveCatalogForPresentation( // catalogPresentationData // ); // } // } //# sourceMappingURL=CatalogInteractor.usecase.js.map