diff --git a/.gitignore b/.gitignore index ffc786d..8a909e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/js/ -/node_modules/ \ No newline at end of file +node_modules/ +build/**/* +public/js/app.min.js \ No newline at end of file diff --git a/app/client/class/API.ts b/app/client/class/API.ts index a086ddc..d4f0e67 100644 --- a/app/client/class/API.ts +++ b/app/client/class/API.ts @@ -9,17 +9,43 @@ import apiErrorHandler from "../errors/apiErrorHandler"; export default abstract class API { public static async fetchAPI( url: string, - data?: object - ): Promise { - return await fetch(url, { - method: "POST", + data?: object, + method: string = "POST" + ): Promise { + const response = await fetch(url, { + method, headers: { "Content-Type": "application/json", }, - body: JSON.stringify(data) - }) - .then((e) => e.json()) - .then((res) => (Object.keys(res).length === 0 ? API_ERROR : res)); + body: JSON.stringify(data), + }); + const responseJson = await response.json(); + + if (response.ok) { + return Object.keys(responseJson).length === 0 ? API_ERROR : responseJson; + } + return (responseJson as any).message; + } + + public static async fetchRedirectAPI( + url: string, + data?: object, + method: string = "POST" + ): Promise { + const response = await fetch(url, { + method, + headers: { + "Content-Type": "application/json", + }, + redirect: "follow", + body: JSON.stringify(data), + }); + const responseJson = await response.json(); + + if (response.ok) { + return Object.keys(responseJson).length === 0 ? API_ERROR : responseJson; + } + return (responseJson as any).message; } /** @@ -27,7 +53,7 @@ export default abstract class API { * @param apiResponse An API method return * @returns if the api is or not an Error */ - public static isApiError(apiResponse: Product[] | apiError | Product): boolean { + public static isApiError(apiResponse: any | apiError): boolean { if (typeof apiResponse === "string") { apiErrorHandler("Ha ocurrido un error."); return true; diff --git a/app/client/class/App.ts b/app/client/class/App.ts index 960325d..ffc65b0 100644 --- a/app/client/class/App.ts +++ b/app/client/class/App.ts @@ -1,4 +1,5 @@ // LISTENERES +import loginRegisterListener from "../listeners/loginRegisterListener"; import menuHandlerListener from "../listeners/menuHandlerListener"; import closeCartListener from "../listeners/closeCartListener"; import paginatorListener from "../listeners/paginatorListener"; @@ -7,17 +8,22 @@ import shopListener from "../listeners/shopListener"; // CLASSES import Favorites from "./Favorites"; +import Router from "./Router"; +import Users from "./Users"; import Cart from "./Cart"; import UI from "./UI"; // SCRIPTS import updateQuantityProducts from "../scripts/updateQuantityProducts"; +import loadUsers from "../scripts/loadUsers"; import loadTable from "../scripts/loadTable"; import { CURRENT_PAGE } from "../config"; +import favoritesListener from "../listeners/favoritesListener"; export default class App { public ui: UI; public cart: Cart; + public users: Users; public favorites: Favorites; private PREPARE: { [index: string]: string; @@ -25,11 +31,13 @@ export default class App { products: "productsPrepare", product: "productPrepare", cart: "cartPrepare", + users: "usersPrepare" }; constructor(HTML_APP: HTMLElement) { this.ui = new UI(HTML_APP); this.cart = new Cart(); + this.users = new Users(); this.favorites = new Favorites(); } @@ -52,14 +60,15 @@ export default class App { * Loads all listeners for Products. */ private productsPrepare(): void { + this.productPrepare(); paginatorListener(); - shopListener(this.cart); } /** * Loads all listeners for Product. */ private productPrepare(): void { + favoritesListener(this.users, this.favorites); shopListener(this.cart); } @@ -70,4 +79,18 @@ export default class App { closeCartListener(this.cart); loadTable(this.cart); } + + /** + * Loads all listeners for Users. + */ + private async usersPrepare(): Promise { + if (this.users.isLogued()) { + if (!Router.getParam(1)) { + return Router.follow(`/users/${this.users.getUser()}`); + } + return await loadUsers(this.users, this.favorites); + } + + loginRegisterListener(); + } } diff --git a/app/client/class/Cart.ts b/app/client/class/Cart.ts index 407705d..cd882bf 100644 --- a/app/client/class/Cart.ts +++ b/app/client/class/Cart.ts @@ -1,4 +1,5 @@ import CartStructure from "../interfaces/CartStructure"; +import CartProduct from "../interfaces/CartProduct"; import { cartProductsList } from "../types/cart"; @@ -6,7 +7,6 @@ import Storage from "./Storage"; import { SS_CART } from "../config"; import cartErrorHandler from "../errors/cartErrorHandler"; -import CartProduct from "../interfaces/CartProduct"; export default class Cart extends Storage { private products: any = []; diff --git a/app/client/class/Favorites.ts b/app/client/class/Favorites.ts index 66bf7db..59cb2e6 100644 --- a/app/client/class/Favorites.ts +++ b/app/client/class/Favorites.ts @@ -1,61 +1,28 @@ import { favoritesArray } from "../types/favorites"; import { productID } from "../types/products"; -import Storage from "./Storage"; +import Router from "./Router"; +import API from "./API"; -import { SS_FAVORITES } from "../config"; +import UsersStorage from "./UsersStorage"; -export default class Favorites extends Storage { +export default class Favorites extends UsersStorage { constructor() { - super(SS_FAVORITES, []); + super(); } - public addToFavorites(productID: productID): void { - const favoritesSet: Set = new Set(this.getStorage()).add(productID); - this.updateFavorites(favoritesSet); - } - - public removeFromFavorite(productID: number): void { - const favoritesSet: Set = new Set(this.getStorage()) - favoritesSet.delete(productID); - this.updateFavorites(favoritesSet); - } - - public handleFavorite(productID: number): void { - const favoritesSet: Set = new Set(this.getStorage()); - if (favoritesSet.has(productID)) { - favoritesSet.delete(productID); - return - } - favoritesSet.add(productID); - } - - /** - * @return if the Cart is empty or not. - */ - public isEmpty(): boolean { - return this.getStorage().length === 0; + public async toggleFavorites(productID: productID): Promise { + return await API.fetchAPI(this.getFavoritesAPI(`${productID}`), {}, "PUT"); } /** * @return favorites products. */ - public getFavorites(): favoritesArray { - return this.getStorage(); + public async getFavorites(): Promise { + return (await API.fetchAPI(this.getFavoritesAPI())).favorites; } - /** - * @return favorites products. - */ - public isFavorite(id: number): boolean { - return this.getStorage().includes(id);; - } - - /** - * Update the Favorites Products Storage. - */ - private updateFavorites(favoritesSet: Set): void { - const favoritesArray: favoritesArray = [...favoritesSet]; - this.updateStorage(favoritesArray); + private getFavoritesAPI(productID: string = ""): string { + return Router.createURL(`/favorites/${this.getUser()}/${productID}`); } } diff --git a/app/client/class/Router.ts b/app/client/class/Router.ts index 925d355..9b08563 100644 --- a/app/client/class/Router.ts +++ b/app/client/class/Router.ts @@ -1,22 +1,21 @@ +import { htmlFileName } from "../types/search"; + export default class Router { - public static followWithParams( - path: string, - params: any - ): void { - window.location.replace( - window.location.origin + path + Router.stringfyParams(params) - ); + public static follow(path: string): void { + window.location.replace(window.location.origin + path); } - public static followWithCurrentParams( - path: string - ): void { + public static followWithQuery(path: string, query: any): void { window.location.replace( - window.location.origin + path + Router.getParams() + window.location.origin + path + Router.stringfyQuery(query) ); } - public static getParams(): string { + public static followWithCurrentQuery(path: string): void { + window.location.replace(window.location.origin + path + Router.getQuery()); + } + + public static getQuery(): string { return window.location.search; } @@ -24,12 +23,20 @@ export default class Router { return window.location.origin + path; } - private static stringfyParams(params: any): string { + public static getPage(): htmlFileName { + return window.location.pathname.split("/")[1] as htmlFileName; + } + + public static getParam(nParam: number): string { + return window.location.pathname.split("/")[nParam + 1]; + } + + private static stringfyQuery(query: any): string { return ( "?" + - Object.keys(params) - .map((key) => `${key}=params[key]`) + Object.keys(query) + .map((key) => `${key}=${query[key]}`) .join("&") ); } -} \ No newline at end of file +} diff --git a/app/client/class/UI.ts b/app/client/class/UI.ts index ca9f7e9..2217403 100644 --- a/app/client/class/UI.ts +++ b/app/client/class/UI.ts @@ -31,10 +31,8 @@ export default class UI { maxPage: number ): void { const innerHTML: string = products - .map((product: Product): string => - ProductsCardComponent(product, favorites.isFavorite(product.id)) - ) + .map((product: Product): string => ProductsCardComponent(product)) .join(""); - PaginatorComponenet(page || 1, maxPage) + PaginatorComponenet(page || 1, maxPage); } } diff --git a/app/client/class/Users.ts b/app/client/class/Users.ts new file mode 100644 index 0000000..f9840f0 --- /dev/null +++ b/app/client/class/Users.ts @@ -0,0 +1,45 @@ +import API from "./API"; +import Router from "./Router"; +import UsersStorage from "./UsersStorage"; + +export default class Users extends UsersStorage { + constructor() { + super(); + } + + public async loginUser(email: string, password: string): Promise { + const response = await API.fetchAPI(Router.createURL("/users"), { email, password }); + if (API.isApiError(response)) { + return response.message + } + this.updateStorage({ + id: response.id, + email, + password + }) + } + + public async registerUser(email: string, password: string): Promise { + const response = await API.fetchAPI(Router.createURL("/users"), { email, password }, "PUT"); + if (API.isApiError(response)) { + return response.message + } + this.updateStorage({ + id: response.id, + email, + password + }) + } + + public getEmail() { + return super.getEmail(); + } + + public getUser() { + return super.getUser(); + } + + public isLogued() { + return super.isLogued(); + } +} diff --git a/app/client/class/UsersStorage.ts b/app/client/class/UsersStorage.ts new file mode 100644 index 0000000..c0f0282 --- /dev/null +++ b/app/client/class/UsersStorage.ts @@ -0,0 +1,25 @@ +import User from "../interfaces/User"; + +import Storage from "./Storage"; + +export default class UsersStorage extends Storage { + constructor() { + super("user", { + id: null, + email: "", + password: "", + }); + } + + protected getUser(): number { + return +this.getStorage().id; + } + + protected getEmail(): string { + return this.getStorage().email; + } + + protected isLogued(): boolean { + return !!this.getStorage().id; + } +} diff --git a/app/client/config.ts b/app/client/config.ts index ae25043..97f6c72 100644 --- a/app/client/config.ts +++ b/app/client/config.ts @@ -1,13 +1,15 @@ import { apiError, apiURL } from "./types/api"; import { htmlFileName } from "./types/search"; +import Router from "./class/Router"; + // HTML const SEARCH_INPUT_S: HTMLElement = document.getElementById("search-input-s"); const SEARCH_INPUT: HTMLElement = document.getElementById("search-input"); const QUANTITY_PRODUCTS_INDICATOR: HTMLElement = document.getElementById("quantityProducts") // GENERAL -const CURRENT_PAGE: htmlFileName = window.location.pathname.split("/")[1] as htmlFileName; +const CURRENT_PAGE: htmlFileName = Router.getPage(); const PAGES: htmlFileName[] = ["index", "cart", "products", "product", "error"]; const DEFAULT_HTML_FILE: htmlFileName = "index"; const SEARCH_PAIR_INPUTS: { diff --git a/app/client/handlers/loginHandler.ts b/app/client/handlers/loginHandler.ts new file mode 100644 index 0000000..c5dcac1 --- /dev/null +++ b/app/client/handlers/loginHandler.ts @@ -0,0 +1,21 @@ +import app from "../main"; + +// HTML +const LOGIN_FORM: HTMLFormElement = document.getElementById( + "js-loginForm" +) as HTMLFormElement; + +export default async function loginHandler(): Promise { + const { email, password } = Object.fromEntries( + new FormData(LOGIN_FORM).entries() + ) as { + [index: string]: string; + }; + const response = await app.users.loginUser(email, password); + + if (response) { + return alert(response); + } + + return alert("Logueado con Éxito"); +} diff --git a/app/client/handlers/registerHandler.ts b/app/client/handlers/registerHandler.ts new file mode 100644 index 0000000..7b6386d --- /dev/null +++ b/app/client/handlers/registerHandler.ts @@ -0,0 +1,25 @@ +import app from "../main"; + +// HTML +const REGISTER_FORM: HTMLFormElement = document.getElementById( + "js-registerForm" +) as HTMLFormElement; + +export default async function registerHandler(): Promise { + const { email, password, passwordRepeat } = Object.fromEntries( + new FormData(REGISTER_FORM).entries() + ) as { [index: string]: string }; + + if (email && password === passwordRepeat) { + const response = await app.users.registerUser(email, password); + + console.log(response) + if (response) { + return alert(response); + } + + return alert("Registrado con Éxito"); + } + + return alert("Las contraseñas no coinciden."); +} diff --git a/app/client/interfaces/User.ts b/app/client/interfaces/User.ts new file mode 100644 index 0000000..5d58d89 --- /dev/null +++ b/app/client/interfaces/User.ts @@ -0,0 +1,5 @@ +export default interface User { + id: number, + email: string, + password: string +} \ No newline at end of file diff --git a/app/client/listeners/favoritesListener.ts b/app/client/listeners/favoritesListener.ts index 50b3d03..35a1cb4 100644 --- a/app/client/listeners/favoritesListener.ts +++ b/app/client/listeners/favoritesListener.ts @@ -1,17 +1,35 @@ -import app from "../main"; +import Favorites from "../class/Favorites"; +import Users from "../class/Users"; // HTML const FAVORITES_ICONS: HTMLCollectionOf = document.getElementsByClassName("favorites-icon"); // EVENTS -const SEARCH_INPUT_S_EVENT: string = "keyup"; +const FAVORITES_ICON_EVENT: string = "click"; + +export default async function favoritesListener( + users: Users, + favorites: Favorites +): Promise { + const favoritesArray = await favorites.getFavorites(); + const isLogued: boolean = users.isLogued(); -export default function favoritesListener(): void { Array.from(FAVORITES_ICONS).forEach((favorites_icon: Element): void => { - favorites_icon.addEventListener(SEARCH_INPUT_S_EVENT, (e) => { + const favoriteID: number = +(favorites_icon as HTMLElement).dataset.id; + + if (favoritesArray.includes(`${favoriteID}`)) { + favorites_icon.classList.add("selected"); + } + + favorites_icon.addEventListener(FAVORITES_ICON_EVENT, () => { + if (!isLogued) { + return alert("Necesitas estar Logueado!"); + } const productID: number = +(favorites_icon as HTMLElement).dataset.id; - app.favorites.handleFavorite(productID); + favorites.toggleFavorites(`${productID}`); + + favorites_icon.classList.toggle("selected"); }); }); -} +} \ No newline at end of file diff --git a/app/client/listeners/loginRegisterListener.ts b/app/client/listeners/loginRegisterListener.ts new file mode 100644 index 0000000..1e7fee0 --- /dev/null +++ b/app/client/listeners/loginRegisterListener.ts @@ -0,0 +1,15 @@ +import loginHandler from "../handlers/loginHandler"; +import registerHandler from "../handlers/registerHandler"; + +// HTML +const LOGIN_FORM_BTN: HTMLElement = document.getElementById("js-loginFormBTN"); +const REGISTER_FORM_BTN: HTMLElement = document.getElementById("js-registerFormBTN"); + +// EVENTS +const REGISTER_FORM_BTN_EVENT: string = "click"; +const LOGIN_FORM_BTN_EVENT: string = "click"; + +export default function loginRegisterListener(): void { + LOGIN_FORM_BTN.addEventListener(LOGIN_FORM_BTN_EVENT, loginHandler); + REGISTER_FORM_BTN.addEventListener(REGISTER_FORM_BTN_EVENT, registerHandler); +} \ No newline at end of file diff --git a/app/client/listeners/paginatorListener.ts b/app/client/listeners/paginatorListener.ts index 7d338e1..7672b15 100644 --- a/app/client/listeners/paginatorListener.ts +++ b/app/client/listeners/paginatorListener.ts @@ -14,7 +14,7 @@ export default function paginatorListener(): void { (e: Event): void => { const page: string = (e.target as HTMLElement).dataset.page; - Router.followWithCurrentParams(`/products/${page}`); + Router.followWithCurrentQuery(`/products/${page}`); } ); }); diff --git a/app/client/scripts/loadUsers.ts b/app/client/scripts/loadUsers.ts new file mode 100644 index 0000000..917a2c0 --- /dev/null +++ b/app/client/scripts/loadUsers.ts @@ -0,0 +1,17 @@ +import { favoritesArray } from "../types/favorites"; + +import Favorites from "../class/Favorites"; +import Users from "../class/Users"; + +// HTML; +const USER_EMAIL: HTMLElement = document.getElementById("user-email"); + +/** + * Loads the Table Body of the Cart View + */ +export default async function loadUsers(users: Users, favorites: Favorites): Promise { + USER_EMAIL.innerHTML = users.getEmail(); + + const favoritesArray: favoritesArray = await favorites.getFavorites(); + console.log(favoritesArray) +} diff --git a/app/client/scripts/sendSearchRequest.ts b/app/client/scripts/sendSearchRequest.ts index ea78ccf..2e8c294 100644 --- a/app/client/scripts/sendSearchRequest.ts +++ b/app/client/scripts/sendSearchRequest.ts @@ -5,8 +5,9 @@ export default function sendSearchRequest( input: HTMLInputElement ): void { //if (CURRENT_PAGE !== "products") { - return Router.followWithParams("/products", { - "search": input.value + console.log(input.value) + return Router.followWithQuery("/products", { + search: input.value }) //} } \ No newline at end of file diff --git a/app/client/types/products.ts b/app/client/types/products.ts index 6ce0d5b..e422eaf 100644 --- a/app/client/types/products.ts +++ b/app/client/types/products.ts @@ -1,4 +1,4 @@ -type productID = number; +type productID = string; export { productID diff --git a/app/client/types/search.ts b/app/client/types/search.ts index d731435..09b538c 100644 --- a/app/client/types/search.ts +++ b/app/client/types/search.ts @@ -5,7 +5,7 @@ type searchURLSetter = { search?: string } type searchParam = "htmlFileName" | "page" | "cod" | "search"; -type htmlFileName = "index" | "cart" | "product" | "products" | "error"; +type htmlFileName = "index" | "cart" | "product" | "products" | "error" | "users"; export { searchURLSetter, diff --git a/app/server/classes/API.ts b/app/server/classes/API.ts deleted file mode 100644 index 83cf69c..0000000 --- a/app/server/classes/API.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Product from "../interfaces/Product"; - -const fs = require("fs"); - -const { DATABASE_DIR } = require("../config"); - -const DATABASE_TABLE_PRODUCT: string = DATABASE_DIR + "/products.json"; -const PRODUCTS: Product[] = JSON.parse( - fs.readFileSync(DATABASE_TABLE_PRODUCT, "utf8") -); - -export default class API { - public static getProduct(id: number): Product { - return PRODUCTS.find((product: any) => product.id === id); - } - - public static getProducts( - search: string = "", - min: number = null, - max: number = null - ): Product[] { - const SEARCH_REGEX: RegExp = new RegExp(search); - return PRODUCTS.filter( - (product: Product) => - SEARCH_REGEX.test(product.title.toLowerCase()) && - API.inRange(product.price, min, max) - ); - } - - public static getProductsByIds(IDList: string[] = []): Product[] { - return PRODUCTS.filter((product: Product) => - IDList.includes(String(product.id)) - ); - } - - private static inRange( - elem: number, - min: number = null, - max: number = null - ): boolean { - return (min ? elem >= min : true) && (max ? elem <= max : true); - } -} diff --git a/app/server/classes/DataBase.ts b/app/server/classes/DataBase.ts new file mode 100644 index 0000000..9f8c7af --- /dev/null +++ b/app/server/classes/DataBase.ts @@ -0,0 +1,47 @@ +import Filter from "./Filter"; + +const fs = require("fs"); + +const { DATABASE_DIR } = require("../config"); + +export default class DataBase extends Filter { + private table: string; + private readonly tableNames = ["config", "products", "users", "favorites"]; + + constructor(tableName: string) { + super(); + this.table = this.returnTable(tableName); + } + + protected getTable(): any { + return this.table; + } + + protected setTable(tableName: string, tableData: any): void { + fs.writeFileSync(this.getTablePath(tableName), JSON.stringify(tableData)); + } + + protected returnTable(tableName: string): any { + if (this.tableNames.includes(tableName)) { + return JSON.parse(fs.readFileSync(this.getTablePath(tableName), "utf8")); + } + } + + protected getConfig(configEntry: string): any { + return this.returnConfig()[configEntry]; + } + + protected setConfig(configEntry: string, configData: any): void { + const config = this.returnConfig(); + config[configEntry] = configData; + this.setTable("config", config); + } + + private getTablePath(tableName: string): string { + return `${DATABASE_DIR}/${tableName}.json`; + } + + private returnConfig(): any { + return this.returnTable("config"); + } +} diff --git a/app/server/classes/FavoritesAPI.ts b/app/server/classes/FavoritesAPI.ts new file mode 100644 index 0000000..fa4a4e7 --- /dev/null +++ b/app/server/classes/FavoritesAPI.ts @@ -0,0 +1,72 @@ +import Favorites from "../interfaces/Favorites"; + +import { favoritesArray } from "../types/favorites"; + +import DataBase from "./DataBase"; + +export default class FavoritesAPI extends DataBase { + private params: any = {}; + private favorites: Favorites[] = []; + + constructor(params: any) { + super("favorites"); + this.params = params; + this.favorites = this.getTable(); + } + + public toggleFavorites(): boolean { + const { id } = this.params; + const userFavorites: Favorites = this.returnFavorites(); + + const favoritesSet: Set = new Set(userFavorites.favoritesProducts); + let state: boolean; + + if (favoritesSet.has(id)) { + favoritesSet.delete(id); + state = false; + } else { + favoritesSet.add(id); + state = true; + } + + userFavorites.favoritesProducts = Array.from(favoritesSet); + this.setFavorites(userFavorites); + return state; + } + + public isFavorite(id: number): boolean { + return this.getFavorites().includes(id); + } + + public getFavorites(): favoritesArray { + return this.returnFavorites().favoritesProducts; + } + + private returnFavorites(): Favorites { + const { userID } = this.params; + return ( + this.favorites.find((userFavorites) => userFavorites.id === userID) || { + id: userID, + favoritesProducts: [], + } + ); + } + + private setFavorites(data: Favorites) { + let noChange: boolean = true; + + const favorites: Favorites[] = this.favorites.map((userFavorites) => { + if (userFavorites.id === data.id) { + userFavorites = data; + noChange = false; + } + return userFavorites; + }); + + if (noChange) { + favorites.push(data); + } + + this.setTable("favorites", favorites); + } +} diff --git a/app/server/classes/Filter.ts b/app/server/classes/Filter.ts new file mode 100644 index 0000000..a2e5e4a --- /dev/null +++ b/app/server/classes/Filter.ts @@ -0,0 +1,9 @@ +export default class Filter { + protected inRange( + elem: number, + min: number = null, + max: number = null + ): boolean { + return (min ? elem >= min : true) && (max ? elem <= max : true); + } +} diff --git a/app/server/classes/ProductsAPI.ts b/app/server/classes/ProductsAPI.ts index db399a8..c95de1a 100644 --- a/app/server/classes/ProductsAPI.ts +++ b/app/server/classes/ProductsAPI.ts @@ -1,15 +1,19 @@ import Product from "../interfaces/Product"; -import API from "./API"; +import DataBase from "./DataBase"; -export default class ProductsAPI extends API { +export default class ProductsAPI extends DataBase { private params: any = {}; private body: any = {}; + private query: any = {}; + private products: Product[]; constructor(req: any) { - super(); + super("products"); this.params = req.params; this.body = req.body; + this.query = req.query; + this.products = this.getTable(); } public getProducts(): { @@ -18,13 +22,19 @@ export default class ProductsAPI extends API { page: number; } { const { page, min, max } = this.params; - const { search } = this.body; - const products: Product[] = API.getProducts(search, min, max); + const { search } = this.query; + const SEARCH_REGEX: RegExp = new RegExp(search); + + const products: Product[] = this.products.filter( + (product: Product) => + SEARCH_REGEX.test(product.title.toLowerCase()) && + this.inRange(product.price, min, max) + ); const maxPage: number = Math.ceil(products.length / 10); const currentPage: number = +page || 1; const firstProductIndex: number = (currentPage - 1) * 10; - + return { products: products.slice(firstProductIndex, firstProductIndex + 10), maxPage, @@ -33,6 +43,13 @@ export default class ProductsAPI extends API { } public getProductsById(): Product[] { - return API.getProductsByIds(this.body.IDList); + return this.products.filter((product: Product) => + this.body.IDList.includes(String(product.id)) + ); + } + + public getProduct(): Product { + const { id } = this.params; + return this.products.find((product: any) => product.id === +id); } -} \ No newline at end of file +} diff --git a/app/server/classes/UsersAPI.ts b/app/server/classes/UsersAPI.ts new file mode 100644 index 0000000..32184c0 --- /dev/null +++ b/app/server/classes/UsersAPI.ts @@ -0,0 +1,51 @@ +import User from "../interfaces/User"; +import DataBase from "./DataBase"; + +export default class UsersAPI extends DataBase { + private body: any = {}; + private users: User[]; + + constructor(req: any) { + super("users"); + this.body = req.body; + this.users = this.getTable(); + } + + private getUser(email: string): User { + return this.users.find((user: User) => user.email === email); + } + + private existUser(email: string): boolean { + return !!this.getUser(email); + } + + public setUser(): number | null { + const { email, password } = this.body; + + if (this.existUser(email)) { + return; + } + + const config = this.getConfig("users"); + config.maxID += 1; + this.setConfig("users", config); + + this.users.push({ + email, + password, + id: config.maxID, + }); + + this.setTable("users", this.users); + + return config.maxID; + } + + public validateUser(): number | null { + const { email, password } = this.body; + const user: User = this.getUser(email); + if (user && user.password === password) { + return user.id; + } + } +} diff --git a/app/server/components/ProductsCardComponent.ts b/app/server/components/ProductsCardComponent.ts index 26425d0..e3f242b 100644 --- a/app/server/components/ProductsCardComponent.ts +++ b/app/server/components/ProductsCardComponent.ts @@ -6,8 +6,7 @@ export default function ProductsCardComponent( id, price, title - }: Product, - isFavorite: boolean + }: Product ): string { return /* html */ `
@@ -16,7 +15,7 @@ export default function ProductsCardComponent( -
+
diff --git a/app/server/controllers/cart.get.ts b/app/server/controllers/cart.get.ts new file mode 100644 index 0000000..d2a58f5 --- /dev/null +++ b/app/server/controllers/cart.get.ts @@ -0,0 +1,3 @@ +module.exports = function indexGet(req: any, res: any) { + res.render('cart'); +} \ No newline at end of file diff --git a/app/server/controllers/favorites.post.ts b/app/server/controllers/favorites.post.ts new file mode 100644 index 0000000..7fa228d --- /dev/null +++ b/app/server/controllers/favorites.post.ts @@ -0,0 +1,10 @@ +import { favoritesArray } from "../types/favorites"; + +import FavoritesAPI from "../classes/FavoritesAPI"; + +module.exports = function favoritesPost(req: any, res: any) { + const favorites: favoritesArray = new FavoritesAPI(req.params).getFavorites(); + return res.json({ + favorites, + }); +}; diff --git a/app/server/controllers/favorites.put.ts b/app/server/controllers/favorites.put.ts new file mode 100644 index 0000000..11c0f40 --- /dev/null +++ b/app/server/controllers/favorites.put.ts @@ -0,0 +1,9 @@ +import FavoritesAPI from "../classes/FavoritesAPI"; + +module.exports = function favoritesPut(req: any, res: any) { + const createState: boolean = new FavoritesAPI(req.params).toggleFavorites(); + + res.json({ + createState, + }); +}; diff --git a/app/server/controllers/index.get.ts b/app/server/controllers/index.get.ts new file mode 100644 index 0000000..f148037 --- /dev/null +++ b/app/server/controllers/index.get.ts @@ -0,0 +1,3 @@ +module.exports = function indexGet(req: any, res: any) { + res.render('index'); +} \ No newline at end of file diff --git a/app/server/routes/product.controller.ts b/app/server/controllers/product.get.ts similarity index 57% rename from app/server/routes/product.controller.ts rename to app/server/controllers/product.get.ts index 14946d7..500f5c8 100644 --- a/app/server/routes/product.controller.ts +++ b/app/server/controllers/product.get.ts @@ -1,15 +1,14 @@ import Product from "../interfaces/Product"; -import API from "../classes/API"; +import ProductsAPI from "../classes/ProductsAPI"; import ProductSpecsComponent from "../components/ProductSpecsComponent"; -module.exports = function productController(req: any, res: any) { - const product: Product = API.getProduct(+req.params.id); +module.exports = function productGet(req: any, res: any) { + const product: Product = new ProductsAPI(req).getProduct(); const config: any = product; config.productSpecs = ProductSpecsComponent(product.caracts); - config.isFavorite = true; res.render("product", config); }; diff --git a/app/server/routes/products.controller.ts b/app/server/controllers/products.get.ts similarity index 89% rename from app/server/routes/products.controller.ts rename to app/server/controllers/products.get.ts index 10f4af9..e02aadd 100644 --- a/app/server/routes/products.controller.ts +++ b/app/server/controllers/products.get.ts @@ -7,11 +7,11 @@ import ProductsAPI from "../classes/ProductsAPI"; import ProductsCardComponent from "../components/ProductsCardComponent"; import PaginatorComponent from "../components/PaginatorComponent"; -module.exports = function productsController(req: any, res: any) { +module.exports = function productsGet(req: any, res: any) { const { products, page, maxPage } = new ProductsAPI(req).getProducts(); const productsHTML: htmlString = products - .map((product: Product): string => ProductsCardComponent(product, true)) + .map((product: Product): string => ProductsCardComponent(product)) .join(""); const paginatorHTML: htmlString = PaginatorComponent(page, maxPage); diff --git a/app/server/controllers/products.post.ts b/app/server/controllers/products.post.ts new file mode 100644 index 0000000..28cca6d --- /dev/null +++ b/app/server/controllers/products.post.ts @@ -0,0 +1,6 @@ +import ProductsAPI from "../classes/ProductsAPI"; + +module.exports = function productsPost(req: any, res: any) { + const response = new ProductsAPI(req).getProducts() + res.json(response); +} \ No newline at end of file diff --git a/app/server/controllers/productsIDs.post.ts b/app/server/controllers/productsIDs.post.ts new file mode 100644 index 0000000..ff1df34 --- /dev/null +++ b/app/server/controllers/productsIDs.post.ts @@ -0,0 +1,6 @@ +import ProductsAPI from "../classes/ProductsAPI"; + +module.exports = function productsIDsPost(req: any, res: any) { + const response = new ProductsAPI(req).getProductsById() + res.json(response); +} \ No newline at end of file diff --git a/app/server/controllers/users.get.ts b/app/server/controllers/users.get.ts new file mode 100644 index 0000000..4fe49e7 --- /dev/null +++ b/app/server/controllers/users.get.ts @@ -0,0 +1,7 @@ +module.exports = function usersGet(req: any, res: any) { + if (req.params.userID) { + + return res.render('users_logued'); + } + res.render('users'); +} \ No newline at end of file diff --git a/app/server/controllers/users.post.ts b/app/server/controllers/users.post.ts new file mode 100644 index 0000000..c080735 --- /dev/null +++ b/app/server/controllers/users.post.ts @@ -0,0 +1,13 @@ +import UsersAPI from "../classes/UsersAPI"; + +module.exports = function usersPost(req: any, res: any) { + const idUser: number = new UsersAPI(req).validateUser(); + if (idUser) { + return res.json({ + id: idUser, + }); + } + res.status(401).json({ + message: "Credenciales Inválidas", + }); +}; diff --git a/app/server/controllers/users.put.ts b/app/server/controllers/users.put.ts new file mode 100644 index 0000000..fcfce9f --- /dev/null +++ b/app/server/controllers/users.put.ts @@ -0,0 +1,13 @@ +import UsersAPI from "../classes/UsersAPI"; + +module.exports = function usersPost(req: any, res: any) { + const idUser: number | null = new UsersAPI(req).setUser(); + if (idUser) { + return res.json({ + id: idUser, + }); + } + res.status(401).send({ + message: "Usuario Existente", + }); +}; diff --git a/app/server/interfaces/Favorites.ts b/app/server/interfaces/Favorites.ts new file mode 100644 index 0000000..951f281 --- /dev/null +++ b/app/server/interfaces/Favorites.ts @@ -0,0 +1,6 @@ +import { favoritesArray } from "../types/favorites"; + +export default interface Favorites { + id: number, + favoritesProducts: favoritesArray +} \ No newline at end of file diff --git a/app/server/interfaces/User.ts b/app/server/interfaces/User.ts new file mode 100644 index 0000000..5d58d89 --- /dev/null +++ b/app/server/interfaces/User.ts @@ -0,0 +1,5 @@ +export default interface User { + id: number, + email: string, + password: string +} \ No newline at end of file diff --git a/app/server/routes.ts b/app/server/routes.ts index ddfbaef..ae1e2b9 100644 --- a/app/server/routes.ts +++ b/app/server/routes.ts @@ -1,33 +1,46 @@ -import ProductsAPI from "./classes/ProductsAPI"; - const { Router } = require("express"); const router = Router(); // CONTROLLERS -const productsController = require("./routes/products.controller"); -const productController = require("./routes/product.controller"); -const indexController = require("./routes/index.controller"); -const cartController = require("./routes/cart.controller"); +const productsGet = require("./controllers/products.get"); +const productGet = require("./controllers/product.get"); +const indexGet = require("./controllers/index.get"); +const usersGet = require("./controllers/users.get"); +const cartGet = require("./controllers/cart.get"); + +const productsIDsPost = require("./controllers/productsIDs.post"); +const favoritesPost = require("./controllers/favorites.post"); +const productsPost = require("./controllers/products.post"); +const usersPost = require("./controllers/users.post"); + +const favoritesPut = require("./controllers/favorites.put"); +const usersPut = require("./controllers/users.put"); + +router.get("/", indexGet); + +router.get("/products/:page", productsGet); +router.get("/products", productsGet); + +router.get("/product/:id", productGet); + +router.get("/users/:userID", usersGet); +router.get("/users", usersGet); -router.get("/", indexController); -router.get("/products/:page", productsController); -router.get("/products", productsController); -router.get("/product/:id", productController); -router.get("/cart", cartController); +router.get("/cart", cartGet); // POST -router.post("/products/ids", (req: any, res: any) => { - const response = new ProductsAPI(req).getProductsById() - res.json(response); -}); -router.post("/products/:page", (req: any, res: any) => { - const response = new ProductsAPI(req).getProducts() - res.json(response); -}); -router.post("/products", (req: any, res: any) => { - const response = new ProductsAPI(req).getProducts() - res.json(response); -}); +router.post("/products/ids", productsIDsPost); +router.post("/products/:page", productsPost); +router.post("/products", productsPost); + +router.post("/users", usersPost); + +router.post("/favorites/:userID", favoritesPost); + +// PUT +router.put("/users", usersPut); + +router.put("/favorites/:userID/:id", favoritesPut); router.use((req: any, res: any) => { diff --git a/app/server/routes/cart.controller.ts b/app/server/routes/cart.controller.ts deleted file mode 100644 index 0efd74e..0000000 --- a/app/server/routes/cart.controller.ts +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function indexController(req: any, res: any) { - res.render('cart'); -} \ No newline at end of file diff --git a/app/server/routes/index.controller.ts b/app/server/routes/index.controller.ts deleted file mode 100644 index 03a301e..0000000 --- a/app/server/routes/index.controller.ts +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function indexController(req: any, res: any) { - res.render('index'); -} \ No newline at end of file diff --git a/app/server/tsconfig.json b/app/server/tsconfig.json index dbba8ab..ac35a9c 100644 --- a/app/server/tsconfig.json +++ b/app/server/tsconfig.json @@ -52,7 +52,7 @@ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ diff --git a/build/client/class/API.js b/build/client/class/API.js deleted file mode 100644 index e8129f8..0000000 --- a/build/client/class/API.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var config_1 = require("../config"); -var apiErrorHandler_1 = __importDefault(require("../errors/apiErrorHandler")); -var API = /** @class */ (function () { - function API() { - } - API.fetchAPI = function (url, data) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch(url, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data) - }) - .then(function (e) { return e.json(); }) - .then(function (res) { return (Object.keys(res).length === 0 ? config_1.API_ERROR : res); })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - /** - * - * @param apiResponse An API method return - * @returns if the api is or not an Error - */ - API.isApiError = function (apiResponse) { - if (typeof apiResponse === "string") { - (0, apiErrorHandler_1.default)("Ha ocurrido un error."); - return true; - } - return false; - }; - return API; -}()); -exports.default = API; diff --git a/build/client/class/App.js b/build/client/class/App.js deleted file mode 100644 index 4dee013..0000000 --- a/build/client/class/App.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// LISTENERES -var menuHandlerListener_1 = __importDefault(require("../listeners/menuHandlerListener")); -var closeCartListener_1 = __importDefault(require("../listeners/closeCartListener")); -var paginatorListener_1 = __importDefault(require("../listeners/paginatorListener")); -var searchsListener_1 = __importDefault(require("../listeners/searchsListener")); -var shopListener_1 = __importDefault(require("../listeners/shopListener")); -// CLASSES -var Favorites_1 = __importDefault(require("./Favorites")); -var Cart_1 = __importDefault(require("./Cart")); -var UI_1 = __importDefault(require("./UI")); -// SCRIPTS -var updateQuantityProducts_1 = __importDefault(require("../scripts/updateQuantityProducts")); -var loadTable_1 = __importDefault(require("../scripts/loadTable")); -var config_1 = require("../config"); -var App = /** @class */ (function () { - function App(HTML_APP) { - this.PREPARE = { - products: "productsPrepare", - product: "productPrepare", - cart: "cartPrepare", - }; - this.ui = new UI_1.default(HTML_APP); - this.cart = new Cart_1.default(); - this.favorites = new Favorites_1.default(); - } - /** - * Loads and runs the needed listeners. - */ - App.prototype.fileLoader = function () { - var preparative = this.PREPARE[config_1.CURRENT_PAGE]; - if (preparative) { - this[preparative](); - } - (0, updateQuantityProducts_1.default)(this.cart.getQuantityProducts()); - (0, menuHandlerListener_1.default)(); - (0, searchsListener_1.default)(); - }; - /** - * Loads all listeners for Products. - */ - App.prototype.productsPrepare = function () { - (0, paginatorListener_1.default)(); - (0, shopListener_1.default)(this.cart); - }; - /** - * Loads all listeners for Product. - */ - App.prototype.productPrepare = function () { - (0, shopListener_1.default)(this.cart); - }; - /** - * Loads all listeners for Cart. - */ - App.prototype.cartPrepare = function () { - (0, closeCartListener_1.default)(this.cart); - (0, loadTable_1.default)(this.cart); - }; - return App; -}()); -exports.default = App; diff --git a/build/client/class/Cart.js b/build/client/class/Cart.js deleted file mode 100644 index f953260..0000000 --- a/build/client/class/Cart.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Storage_1 = __importDefault(require("./Storage")); -var config_1 = require("../config"); -var cartErrorHandler_1 = __importDefault(require("../errors/cartErrorHandler")); -var Cart = /** @class */ (function (_super) { - __extends(Cart, _super); - function Cart() { - var _this = _super.call(this, config_1.SS_CART, { - products: {}, - quantityProducts: 0, - }) || this; - _this.products = []; - return _this; - } - Cart.prototype.addToCart = function (id) { - var _a = this.getStorage(), products = _a.products, quantityProducts = _a.quantityProducts; - if (!products[id]) { - products[id] = 0; - } - products[id] += 1; - this.updateStorage({ - products: products, - quantityProducts: quantityProducts + 1, - }); - }; - Cart.prototype.removeFromCart = function (id) { - var _a = this.getStorage(), products = _a.products, quantityProducts = _a.quantityProducts; - if (products[id] === 1) - delete products[id]; - else - products[id] -= 1; - this.updateStorage({ - products: products, - quantityProducts: quantityProducts - 1, - }); - }; - Cart.prototype.close = function () { - this.deleteStorage(); - alert("Imagina que la compra finalizó"); - }; - /** - * @return if the Cart is empty or not. - */ - Cart.prototype.isEmpty = function () { - return this.getProducts().length === 0; - }; - /** - * @return if the Cart is empty or not. - */ - Cart.prototype.isCartError = function () { - if (this.isEmpty()) { - (0, cartErrorHandler_1.default)("El carrito está vacio."); - return true; - } - return false; - }; - /** - * @return the ID's of the products on cart. - */ - Cart.prototype.getProductsIDs = function () { - var _a; - return ((_a = this.getStorage()) === null || _a === void 0 ? void 0 : _a.products) || {}; - }; - /** - * @return the ID's of the products on cart. - */ - Cart.prototype.setProducts = function (products) { - this.products = products; - }; - /** - * @return the products on cart. - */ - Cart.prototype.getProducts = function () { - return this.products; - }; - Cart.prototype.getQuantityProducts = function () { - var _a; - return ((_a = this.getStorage()) === null || _a === void 0 ? void 0 : _a.quantityProducts) || 0; - }; - return Cart; -}(Storage_1.default)); -exports.default = Cart; diff --git a/build/client/class/Favorites.js b/build/client/class/Favorites.js deleted file mode 100644 index 019dd69..0000000 --- a/build/client/class/Favorites.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Storage_1 = __importDefault(require("./Storage")); -var config_1 = require("../config"); -var Favorites = /** @class */ (function (_super) { - __extends(Favorites, _super); - function Favorites() { - return _super.call(this, config_1.SS_FAVORITES, []) || this; - } - Favorites.prototype.addToFavorites = function (productID) { - var favoritesArray = this.getStorage(); - favoritesArray.push(productID); - this.updateStorage(favoritesArray); - }; - Favorites.prototype.removeProduct = function (productID) { - var favoritesArray = this.getStorage(); - this.updateStorage(favoritesArray.splice(favoritesArray.indexOf(productID), 1)); - }; - /** - * @return if the Cart is empty or not. - */ - Favorites.prototype.isEmpty = function () { - var cartResponse = this.getStorage(); - return cartResponse.length === 0; - }; - /** - * @return favorites products. - */ - Favorites.prototype.getFavorites = function () { - return this.getStorage(); - }; - /** - * @return favorites products. - */ - Favorites.prototype.isFavorite = function (id) { - return this.getStorage().includes(id); - ; - }; - return Favorites; -}(Storage_1.default)); -exports.default = Favorites; diff --git a/build/client/class/Router.js b/build/client/class/Router.js deleted file mode 100644 index c8b8cf4..0000000 --- a/build/client/class/Router.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Router = /** @class */ (function () { - function Router() { - } - Router.followWithParams = function (path, params) { - window.location.replace(window.location.origin + path + Router.stringfyParams(params)); - }; - Router.followWithCurrentParams = function (path) { - window.location.replace(window.location.origin + path + Router.getParams()); - }; - Router.getParams = function () { - return window.location.search; - }; - Router.createURL = function (path) { - return window.location.origin + path; - }; - Router.stringfyParams = function (params) { - return ("?" + - Object.keys(params) - .map(function (key) { return key + "=params[key]"; }) - .join("&")); - }; - return Router; -}()); -exports.default = Router; diff --git a/build/client/class/Storage.js b/build/client/class/Storage.js deleted file mode 100644 index 8b72826..0000000 --- a/build/client/class/Storage.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Storage = /** @class */ (function () { - function Storage(storageName, storageObject) { - this.storageName = storageName; - if (!sessionStorage.getItem(storageName)) { - sessionStorage.setItem(storageName, JSON.stringify(storageObject)); - } - } - Storage.prototype.updateStorage = function (storageObject) { - sessionStorage.setItem(this.storageName, JSON.stringify(storageObject)); - }; - Storage.prototype.deleteStorage = function () { - sessionStorage.removeItem(this.storageName); - }; - Storage.prototype.getStorage = function () { - return JSON.parse(sessionStorage.getItem(this.storageName)); - }; - return Storage; -}()); -exports.default = Storage; diff --git a/build/client/class/UI.js b/build/client/class/UI.js deleted file mode 100644 index 8aa3a3e..0000000 --- a/build/client/class/UI.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// COMPONENETS -var ProductsCardComponent_1 = __importDefault(require("../../server/components/ProductsCardComponent")); -var PaginatorComponent_1 = __importDefault(require("../../server/components/PaginatorComponent")); -var UI = /** @class */ (function () { - /** - * @param document where the HTMLElement will be inserted. - */ - function UI(document) { - this.document = document; - } - /** - * Render ProductsView - */ - UI.prototype.products = function (favorites, products, page, maxPage) { - var innerHTML = products - .map(function (product) { - return (0, ProductsCardComponent_1.default)(product, favorites.isFavorite(product.id)); - }) - .join(""); - (0, PaginatorComponent_1.default)(page || 1, maxPage); - }; - return UI; -}()); -exports.default = UI; diff --git a/build/client/components/CartEntryComponent.js b/build/client/components/CartEntryComponent.js deleted file mode 100644 index 1f304cf..0000000 --- a/build/client/components/CartEntryComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function CartEntryComponent(_a) { - var units = _a.units, price = _a.price, total = _a.total, id = _a.id, title = _a.title; - return /* html */ "\n \n \n
-1
\n
+1
\n \n \n \n " + title + "\n \n \n " + units + "\n $" + price + "\n $" + total + "\n \n "; -} -exports.default = CartEntryComponent; diff --git a/build/client/components/CartTableComponent.js b/build/client/components/CartTableComponent.js deleted file mode 100644 index e462262..0000000 --- a/build/client/components/CartTableComponent.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var CartEntryComponent_1 = __importDefault(require("./CartEntryComponent")); -function CartTableComponent(products) { - var total = 0; - var CartTable = Object.values(products) - .map(function (product) { - total += product.total; - return (0, CartEntryComponent_1.default)(product); - }) - .join(""); - return { CartTable: CartTable, total: total }; -} -exports.default = CartTableComponent; diff --git a/build/client/components/FavoritesEntryComponent.js b/build/client/components/FavoritesEntryComponent.js deleted file mode 100644 index 24cb174..0000000 --- a/build/client/components/FavoritesEntryComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function FavoritesEntryComponent(_a) { - var price = _a.price, id = _a.id, title = _a.title, body = _a.body; - return /* html */ "\n \n \n \n " + title + "\n \n \n \n " + body + "\n $" + price + "\n F\n \n "; -} -exports.default = FavoritesEntryComponent; diff --git a/build/client/components/FavoritesTableComponent.js b/build/client/components/FavoritesTableComponent.js deleted file mode 100644 index 9d25745..0000000 --- a/build/client/components/FavoritesTableComponent.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var FavoritesEntryComponent_1 = __importDefault(require("./FavoritesEntryComponent")); -function FavoritesTableComponent(products) { - return products - .map(function (product) { return (0, FavoritesEntryComponent_1.default)(product); }) - .join(""); -} -exports.default = FavoritesTableComponent; diff --git a/build/client/components/PaginatorComponent.js b/build/client/components/PaginatorComponent.js deleted file mode 100644 index 54053d6..0000000 --- a/build/client/components/PaginatorComponent.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function PaginatorComponenet(page, maxPage, positions) { - var left = positions.left, center = positions.center, right = positions.right; - return "\n " + createExteriorPaginator(1, "<<", maxPage, (page >= 3)) + "\n " + createMidPaginator(left, maxPage, page) + "\n " + createMidPaginator(center, maxPage, page) + "\n " + createMidPaginator(right, maxPage, page) + "\n " + createExteriorPaginator(maxPage, ">>", maxPage, (page <= maxPage)) + "\n "; -} -exports.default = PaginatorComponenet; -function createMidPaginator(thisPage, maxPage, currentPage) { - return (thisPage > 0 && thisPage <= maxPage) - ? "\n \n " + thisPage + "\n \n " - : ""; -} -function createExteriorPaginator(thisPage, content, maxPage, condition) { - return (condition && maxPage > 3) - ? "\n \n " + content + "\n \n " - : ""; -} diff --git a/build/client/components/ProductsCardComponent.js b/build/client/components/ProductsCardComponent.js deleted file mode 100644 index 46e742d..0000000 --- a/build/client/components/ProductsCardComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function ProductsCardComponent(_a, isFavorite) { - var image = _a.image, id = _a.id, price = _a.price, title = _a.title; - return /* html */ "\n
\n
\n \n \n \n
\n ★\n
\n
\n
\n
" + title + "
\n
$" + price + "
\n
\n Comprar\n
\n "; -} -exports.default = ProductsCardComponent; diff --git a/build/client/config.js b/build/client/config.js deleted file mode 100644 index 680784f..0000000 --- a/build/client/config.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SS_FAVORITES = exports.SS_CART = exports.API_ERROR = exports.API_POSTS = exports.CURRENT_PAGE = exports.DEFAULT_HTML_FILE = exports.PAGES = exports.SEARCH_PAIR_INPUTS = exports.QUANTITY_PRODUCTS_INDICATOR = void 0; -// HTML -var SEARCH_INPUT_S = document.getElementById("search-input-s"); -var SEARCH_INPUT = document.getElementById("search-input"); -var QUANTITY_PRODUCTS_INDICATOR = document.getElementById("quantityProducts"); -exports.QUANTITY_PRODUCTS_INDICATOR = QUANTITY_PRODUCTS_INDICATOR; -// GENERAL -var CURRENT_PAGE = window.location.pathname.split("/")[1]; -exports.CURRENT_PAGE = CURRENT_PAGE; -var PAGES = ["index", "cart", "products", "product", "error"]; -exports.PAGES = PAGES; -var DEFAULT_HTML_FILE = "index"; -exports.DEFAULT_HTML_FILE = DEFAULT_HTML_FILE; -var SEARCH_PAIR_INPUTS = { - "search-button-s": SEARCH_INPUT_S, - "search-button": SEARCH_INPUT -}; -exports.SEARCH_PAIR_INPUTS = SEARCH_PAIR_INPUTS; -// API -var API_POSTS = "https://jsonplaceholder.typicode.com/posts/"; -exports.API_POSTS = API_POSTS; -var API_ERROR = "ERROR"; -exports.API_ERROR = API_ERROR; -// SESSION_STORAGE -var SS_CART = "cart"; -exports.SS_CART = SS_CART; -var SS_FAVORITES = "favorites"; -exports.SS_FAVORITES = SS_FAVORITES; diff --git a/build/client/errors/apiErrorHandler.js b/build/client/errors/apiErrorHandler.js deleted file mode 100644 index da4c9ca..0000000 --- a/build/client/errors/apiErrorHandler.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function apiErrorHandler(errorMessage) { - alert(errorMessage); - //app.errorLoader(); -} -exports.default = apiErrorHandler; diff --git a/build/client/errors/cartErrorHandler.js b/build/client/errors/cartErrorHandler.js deleted file mode 100644 index d76db11..0000000 --- a/build/client/errors/cartErrorHandler.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function cartErrorHandler(errorMessage) { - alert(errorMessage); -} -exports.default = cartErrorHandler; diff --git a/build/client/handlers/increaseOneButtonHandler.js b/build/client/handlers/increaseOneButtonHandler.js deleted file mode 100644 index ded5309..0000000 --- a/build/client/handlers/increaseOneButtonHandler.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var getIdProductFromTable_1 = __importDefault(require("../scripts/getIdProductFromTable")); -var ADD_ONE_PRODUCT_BUTTON_EVENT = "click"; -function increaseOneButtonHandler(button, cart, callback) { - button.addEventListener(ADD_ONE_PRODUCT_BUTTON_EVENT, function (e) { - var ID = (0, getIdProductFromTable_1.default)(e); - cart.addToCart(ID); - callback(); - }); -} -exports.default = increaseOneButtonHandler; diff --git a/build/client/handlers/reduceOneButtonHandler.js b/build/client/handlers/reduceOneButtonHandler.js deleted file mode 100644 index 2b790ff..0000000 --- a/build/client/handlers/reduceOneButtonHandler.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var getIdProductFromTable_1 = __importDefault(require("../scripts/getIdProductFromTable")); -var REMOVE_ONE_PRODUCT_BUTTON_EVENT = "click"; -function reduceOneButtonHandler(button, cart, callback) { - button.addEventListener(REMOVE_ONE_PRODUCT_BUTTON_EVENT, function (e) { - var ID = (0, getIdProductFromTable_1.default)(e); - cart.removeFromCart(ID); - callback(); - }); -} -exports.default = reduceOneButtonHandler; diff --git a/build/client/handlers/searchButtonHandler.js b/build/client/handlers/searchButtonHandler.js deleted file mode 100644 index 219c727..0000000 --- a/build/client/handlers/searchButtonHandler.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var config_1 = require("../config"); -var sendSearchRequest_1 = __importDefault(require("../scripts/sendSearchRequest")); -function searchButtonHandler(e) { - var BUTTON = e.target; - (0, sendSearchRequest_1.default)(config_1.SEARCH_PAIR_INPUTS[BUTTON.id]); -} -exports.default = searchButtonHandler; diff --git a/build/client/handlers/searchInputHandler.js b/build/client/handlers/searchInputHandler.js deleted file mode 100644 index 97e373d..0000000 --- a/build/client/handlers/searchInputHandler.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var sendSearchRequest_1 = __importDefault(require("../scripts/sendSearchRequest")); -function searchInputHandler(e) { - if (e.keyCode === 13) { - (0, sendSearchRequest_1.default)(e.target); - } -} -exports.default = searchInputHandler; diff --git a/build/client/interfaces/ApiProduct.js b/build/client/interfaces/ApiProduct.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/ApiProduct.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/interfaces/BasicProduct.js b/build/client/interfaces/BasicProduct.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/BasicProduct.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/interfaces/CartProduct.js b/build/client/interfaces/CartProduct.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/CartProduct.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/interfaces/CartStructure.js b/build/client/interfaces/CartStructure.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/CartStructure.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/interfaces/Product.js b/build/client/interfaces/Product.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/Product.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/interfaces/SearchURLParams.js b/build/client/interfaces/SearchURLParams.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/interfaces/SearchURLParams.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/listeners/closeCartListener.js b/build/client/listeners/closeCartListener.js deleted file mode 100644 index dcae511..0000000 --- a/build/client/listeners/closeCartListener.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var loadTable_1 = __importDefault(require("../scripts/loadTable")); -var CLOSE_CART_EVENT = "click"; -var CLOSE_CART_ID = "js-closeCart"; -/** - * Close the Cart. - */ -function closeCartListener(cart) { - var CLOSE_CART = document.getElementById(CLOSE_CART_ID); - CLOSE_CART.addEventListener(CLOSE_CART_EVENT, function () { - cart.close(); - (0, loadTable_1.default)(); - }); -} -exports.default = closeCartListener; diff --git a/build/client/listeners/favoritesListener.js b/build/client/listeners/favoritesListener.js deleted file mode 100644 index 966c5ad..0000000 --- a/build/client/listeners/favoritesListener.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -// import searchInputHandler from "../handlers/searchInputHandler"; -// // HTML -// const FAVORITES_ICON: HTMLElement = document.getElementsByClassName("favorites-icon"); -// // EVENTS -// const SEARCH_INPUT_S_EVENT: string = "keyup"; -// export default function favoritesListener(): void { -// (FAVORITES_ICON as HTMLElement).addEventListener(SEARCH_INPUT_S_EVENT, searchInputHandler); -// } diff --git a/build/client/listeners/lastMomentShopListener.js b/build/client/listeners/lastMomentShopListener.js deleted file mode 100644 index 0ed351e..0000000 --- a/build/client/listeners/lastMomentShopListener.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var increaseOneButtonHandler_1 = __importDefault(require("../handlers/increaseOneButtonHandler")); -var reduceOneButtonHandler_1 = __importDefault(require("../handlers/reduceOneButtonHandler")); -// HTML -var REMOVE_ONE_PRODUCT_BUTTON = document.getElementsByClassName("reduceOneButton"); -var ADD_ONE_PRODUCT_BUTTON = document.getElementsByClassName("increaseOneButton"); -function lastMomentShopListener(callback, cart) { - Array.from(REMOVE_ONE_PRODUCT_BUTTON).forEach(function (reduceOneButton) { - (0, reduceOneButtonHandler_1.default)(reduceOneButton, cart, callback); - }); - Array.from(ADD_ONE_PRODUCT_BUTTON).forEach(function (increaseOneButton) { - (0, increaseOneButtonHandler_1.default)(increaseOneButton, cart, callback); - }); -} -exports.default = lastMomentShopListener; diff --git a/build/client/listeners/menuHandlerListener.js b/build/client/listeners/menuHandlerListener.js deleted file mode 100644 index 8fe206c..0000000 --- a/build/client/listeners/menuHandlerListener.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// HTML -var MENU_HANDLERS_BUTTONS = document.getElementsByClassName("openNav-button"); -var MENU_CONTAINER = document.getElementById("nav-container"); -// CSS CLASES -var MENU_CONTAINER_CLASS_SHOW = "active"; -// EVENTS -var MENU_HANDLERS_BUTTONS_EVENT = "click"; -function menuHandlerListener() { - Array.from(MENU_HANDLERS_BUTTONS).forEach(function (button) { - button.addEventListener(MENU_HANDLERS_BUTTONS_EVENT, function () { - MENU_CONTAINER.classList.toggle(MENU_CONTAINER_CLASS_SHOW); - }); - }); -} -exports.default = menuHandlerListener; diff --git a/build/client/listeners/paginatorListener.js b/build/client/listeners/paginatorListener.js deleted file mode 100644 index 9b69f8d..0000000 --- a/build/client/listeners/paginatorListener.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Router_1 = __importDefault(require("../class/Router")); -// HTML -var PAGINATOR_BUTTONS = document.getElementsByClassName("js-paginator"); -// EVENTS -var PAGINATOR_BUTTONS_EVENT = "click"; -function paginatorListener() { - Array.from(PAGINATOR_BUTTONS).forEach(function (button) { - button.addEventListener(PAGINATOR_BUTTONS_EVENT, function (e) { - var page = e.target.dataset.page; - Router_1.default.followWithCurrentParams("/products/" + page); - }); - }); -} -exports.default = paginatorListener; diff --git a/build/client/listeners/searchsListener.js b/build/client/listeners/searchsListener.js deleted file mode 100644 index 6e09e51..0000000 --- a/build/client/listeners/searchsListener.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var searchButtonHandler_1 = __importDefault(require("../handlers/searchButtonHandler")); -var searchInputHandler_1 = __importDefault(require("../handlers/searchInputHandler")); -// HTML -var SEARCH_BUTTON_S = document.getElementById("search-button-s"); -var SEARCH_BUTTON = document.getElementById("search-button"); -var SEARCH_INPUT_S = document.getElementById("search-input-s"); -var SEARCH_INPUT = document.getElementById("search-input"); -// EVENTS -var SEARCH_BUTTON_S_EVENT = "click"; -var SEARCH_BUTTON_EVENT = "click"; -var SEARCH_INPUT_S_EVENT = "keyup"; -var SEARCH_INPUT_EVENT = "keyup"; -function searchsListener() { - SEARCH_INPUT_S.addEventListener(SEARCH_INPUT_S_EVENT, searchInputHandler_1.default); - SEARCH_INPUT.addEventListener(SEARCH_INPUT_EVENT, searchInputHandler_1.default); - SEARCH_BUTTON_S.addEventListener(SEARCH_BUTTON_S_EVENT, searchButtonHandler_1.default); - SEARCH_BUTTON.addEventListener(SEARCH_BUTTON_EVENT, searchButtonHandler_1.default); -} -exports.default = searchsListener; diff --git a/build/client/listeners/shopListener.js b/build/client/listeners/shopListener.js deleted file mode 100644 index 7bc1be1..0000000 --- a/build/client/listeners/shopListener.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// SCRIPTS -var updateQuantityProducts_1 = __importDefault(require("../scripts/updateQuantityProducts")); -// HTML -var SHOP_BUTTONS = document.getElementsByClassName("shopButton"); -// EVENTS -var SHOP_BUTTONS_EVENT = "click"; -function shopListener(cart) { - var _this = this; - Array.from(SHOP_BUTTONS).forEach(function (button) { - button.addEventListener(SHOP_BUTTONS_EVENT, function (e) { return __awaiter(_this, void 0, void 0, function () { - var id; - return __generator(this, function (_a) { - id = +e.target.dataset.id; - cart.addToCart(id); - (0, updateQuantityProducts_1.default)(cart.getQuantityProducts()); - return [2 /*return*/]; - }); - }); }); - }); -} -exports.default = shopListener; diff --git a/build/client/main.js b/build/client/main.js deleted file mode 100644 index 097c4a8..0000000 --- a/build/client/main.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var App_1 = __importDefault(require("./class/App")); -var HTML_APP = document.getElementById("app"); -var app = new App_1.default(HTML_APP); -app.fileLoader(); -exports.default = app; diff --git a/build/client/scripts/getIdProductFromTable.js b/build/client/scripts/getIdProductFromTable.js deleted file mode 100644 index 5d1e863..0000000 --- a/build/client/scripts/getIdProductFromTable.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function getIdProductFromTable(e) { - var stringID = e.target.parentElement.dataset - .productId; - return Number(stringID); -} -exports.default = getIdProductFromTable; diff --git a/build/client/scripts/loadTable.js b/build/client/scripts/loadTable.js deleted file mode 100644 index 72f8b90..0000000 --- a/build/client/scripts/loadTable.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Router_1 = __importDefault(require("../class/Router")); -var API_1 = __importDefault(require("../class/API")); -// LISTENERS -var lastMomentShopListener_1 = __importDefault(require("../listeners/lastMomentShopListener")); -// SCRIPTS -var main_1 = __importDefault(require("../main")); -var updateQuantityProducts_1 = __importDefault(require("./updateQuantityProducts")); -var CartTableComponent_1 = __importDefault(require("../components/CartTableComponent")); -// HTML; -var tBodyCartID = "tBodyCart"; -var totalCartID = "totalCart"; -function setCartElements(tBodyCart, total) { - document.getElementById(tBodyCartID).innerHTML = tBodyCart; - document.getElementById(totalCartID).innerHTML = "$" + total; -} -function updateCart(cart) { - return __awaiter(this, void 0, void 0, function () { - var ProductsIDs, IDList, response, products; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ProductsIDs = cart.getProductsIDs(); - IDList = Object.keys(ProductsIDs); - return [4 /*yield*/, API_1.default.fetchAPI(Router_1.default.createURL("/products/ids"), { - IDList: IDList, - })]; - case 1: - response = _a.sent(); - if (!API_1.default.isApiError(response)) { - products = response.map(function (product) { - var cartProduct = product; - cartProduct.units = ProductsIDs[product.id]; - cartProduct.total = cartProduct.price * cartProduct.units; - return cartProduct; - }); - cart.setProducts(products); - } - return [2 /*return*/]; - } - }); - }); -} -/** - * Loads the Table Body of the Cart View - */ -function loadTable(cart) { - if (cart === void 0) { cart = main_1.default.cart; } - return __awaiter(this, void 0, void 0, function () { - var products, _a, total, CartTable; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, updateCart(cart)]; - case 1: - _b.sent(); - cart.isCartError(); - products = cart.getProducts(); - _a = (0, CartTableComponent_1.default)(products), total = _a.total, CartTable = _a.CartTable; - setCartElements(CartTable, total); - (0, lastMomentShopListener_1.default)(loadTable, cart); - (0, updateQuantityProducts_1.default)(cart.getQuantityProducts()); - return [2 /*return*/]; - } - }); - }); -} -exports.default = loadTable; diff --git a/build/client/scripts/sendSearchRequest.js b/build/client/scripts/sendSearchRequest.js deleted file mode 100644 index 2696acd..0000000 --- a/build/client/scripts/sendSearchRequest.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Router_1 = __importDefault(require("../class/Router")); -//import { CURRENT_PAGE } from "../config"; -function sendSearchRequest(input) { - //if (CURRENT_PAGE !== "products") { - return Router_1.default.followWithParams("/products", { - "search": input.value - }); - //} -} -exports.default = sendSearchRequest; diff --git a/build/client/scripts/updateQuantityProducts.js b/build/client/scripts/updateQuantityProducts.js deleted file mode 100644 index e04b104..0000000 --- a/build/client/scripts/updateQuantityProducts.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var config_1 = require("../config"); -function updateQuantityProducts(q) { - config_1.QUANTITY_PRODUCTS_INDICATOR.innerHTML = String(q); -} -exports.default = updateQuantityProducts; diff --git a/build/client/types/api.js b/build/client/types/api.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/api.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/cart.js b/build/client/types/cart.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/cart.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/favorites.js b/build/client/types/favorites.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/favorites.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/functions.js b/build/client/types/functions.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/functions.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/html.js b/build/client/types/html.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/html.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/products.js b/build/client/types/products.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/products.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/client/types/search.js b/build/client/types/search.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/client/types/search.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/api/products.api.js b/build/server/api/products.api.js deleted file mode 100644 index 95cbf41..0000000 --- a/build/server/api/products.api.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var API_1 = __importDefault(require("../classes/API")); -function productsApi(_a, body) { - var page = _a.page, search = _a.search, min = _a.min, max = _a.max; - if (body === void 0) { body = {}; } - var products = API_1.default.getProducts(search, body.IDList, min, max); - if (body) { - return { products: products }; - } - var maxPage = Math.ceil(products.length / 10); - var currentPage = +page || 1; - var firstProductIndex = (currentPage - 1) * 10; - return { - products: products.slice(firstProductIndex, firstProductIndex + 10), - maxPage: maxPage, - page: currentPage, - }; -} -exports.default = productsApi; diff --git a/build/server/app.js b/build/server/app.js deleted file mode 100644 index 5497c85..0000000 --- a/build/server/app.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var express = require('express'); -var ejs = require('ejs'); -var morgan = require('morgan'); -var ROUTES = require('./routes'); -var PUBLIC_DIR = require('./config').PUBLIC_DIR; -var app = express(); -// ["Primeros auxilios", "Diabetes", "Óptica", "Pediculosis", "Pédicos", "Suplementos Dietarios", "Suplementos Nutricionales", "Suplementos Deportivos", "Protección y Recuperación", "Fitness"]; -// settings -app.set('view engine', 'ejs'); -app.listen(4444); -// middlewares -app.use(morgan('dev')); -app.use(express.urlencoded({ extended: true })); -app.use(express.json()); -// static -app.use(express.static(PUBLIC_DIR)); -// routes -app.use(ROUTES); diff --git a/build/server/classes/API.js b/build/server/classes/API.js deleted file mode 100644 index 956b7d2..0000000 --- a/build/server/classes/API.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var fs = require("fs"); -var DATABASE_DIR = require("../config").DATABASE_DIR; -var DATABASE_TABLE_PRODUCT = DATABASE_DIR + "/products.json"; -var PRODUCTS = JSON.parse(fs.readFileSync(DATABASE_TABLE_PRODUCT, "utf8")); -var API = /** @class */ (function () { - function API() { - } - API.getProduct = function (id) { - return PRODUCTS.find(function (product) { return product.id === id; }); - }; - API.getProducts = function (search, min, max) { - if (search === void 0) { search = ""; } - if (min === void 0) { min = null; } - if (max === void 0) { max = null; } - var SEARCH_REGEX = new RegExp(search); - return PRODUCTS.filter(function (product) { - return SEARCH_REGEX.test(product.title.toLowerCase()) && - API.inRange(product.price, min, max); - }); - }; - API.getProductsByIds = function (IDList) { - if (IDList === void 0) { IDList = []; } - return PRODUCTS.filter(function (product) { - return IDList.includes(String(product.id)); - }); - }; - API.inRange = function (elem, min, max) { - if (min === void 0) { min = null; } - if (max === void 0) { max = null; } - return (min ? elem >= min : true) && (max ? elem <= max : true); - }; - return API; -}()); -exports.default = API; diff --git a/build/server/classes/ProductsAPI.js b/build/server/classes/ProductsAPI.js deleted file mode 100644 index bdf91f7..0000000 --- a/build/server/classes/ProductsAPI.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var API_1 = __importDefault(require("./API")); -var ProductsAPI = /** @class */ (function (_super) { - __extends(ProductsAPI, _super); - function ProductsAPI(req) { - var _this = _super.call(this) || this; - _this.params = {}; - _this.body = {}; - _this.params = req.params; - _this.body = req.body; - return _this; - } - ProductsAPI.prototype.getProducts = function () { - var _a = this.params, page = _a.page, search = _a.search, min = _a.min, max = _a.max; - var products = API_1.default.getProducts(search, min, max); - var maxPage = Math.ceil(products.length / 10); - var currentPage = +page || 1; - var firstProductIndex = (currentPage - 1) * 10; - return { - products: products.slice(firstProductIndex, firstProductIndex + 10), - maxPage: maxPage, - page: currentPage, - }; - }; - ProductsAPI.prototype.getProductsById = function () { - return API_1.default.getProductsByIds(this.body.IDList); - }; - return ProductsAPI; -}(API_1.default)); -exports.default = ProductsAPI; diff --git a/build/server/client/types/cart.js b/build/server/client/types/cart.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/client/types/cart.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/client/types/html.js b/build/server/client/types/html.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/client/types/html.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/components/CartEntryComponent.js b/build/server/components/CartEntryComponent.js deleted file mode 100644 index 3891910..0000000 --- a/build/server/components/CartEntryComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function CartEntryComponent(_a) { - var units = _a.units, price = _a.price, total = _a.total, id = _a.id, title = _a.title; - return /* html */ "\n \n \n
-1
\n
+1
\n \n \n \n " + title + "\n \n \n " + units + "\n $" + price + "\n $" + total + "\n \n "; -} -exports.default = CartEntryComponent; diff --git a/build/server/components/CartTableComponent.js b/build/server/components/CartTableComponent.js deleted file mode 100644 index 5ffec80..0000000 --- a/build/server/components/CartTableComponent.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var CartEntryComponent_1 = __importDefault(require("./CartEntryComponent")); -function CartTableComponent(products) { - return Object.values(products) - .map(function (product) { return (0, CartEntryComponent_1.default)(product); }) - .join(""); -} -exports.default = CartTableComponent; diff --git a/build/server/components/FavoritesEntryComponent.js b/build/server/components/FavoritesEntryComponent.js deleted file mode 100644 index ef50d5c..0000000 --- a/build/server/components/FavoritesEntryComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function FavoritesEntryComponent(_a) { - var price = _a.price, id = _a.id, title = _a.title, body = _a.body; - return /* html */ "\n \n \n \n " + title + "\n \n \n \n " + body + "\n $" + price + "\n F\n \n "; -} -exports.default = FavoritesEntryComponent; diff --git a/build/server/components/FavoritesTableComponent.js b/build/server/components/FavoritesTableComponent.js deleted file mode 100644 index 9d25745..0000000 --- a/build/server/components/FavoritesTableComponent.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var FavoritesEntryComponent_1 = __importDefault(require("./FavoritesEntryComponent")); -function FavoritesTableComponent(products) { - return products - .map(function (product) { return (0, FavoritesEntryComponent_1.default)(product); }) - .join(""); -} -exports.default = FavoritesTableComponent; diff --git a/build/server/components/PaginatorComponent.js b/build/server/components/PaginatorComponent.js deleted file mode 100644 index ab57373..0000000 --- a/build/server/components/PaginatorComponent.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function PaginatorComponenet(page, maxPage) { - var left = page - 1; - var center = page; - var right = page + 1; - if (page === 1) { - ++left; - ++center; - ++right; - } - else if (page === maxPage) { - --left; - --center; - --right; - } - return "\n " + exteriorPaginator(1, maxPage, "<<", page > 2) + "\n " + midPaginator(left, maxPage, page) + "\n " + midPaginator(center, maxPage, page) + "\n " + midPaginator(right, maxPage, page) + "\n " + exteriorPaginator(maxPage, maxPage, ">>", page < (maxPage - 1)) + "\n "; -} -exports.default = PaginatorComponenet; -function midPaginator(redirectPage, maxPage, currentPage) { - return redirectPage > 0 && redirectPage <= maxPage - ? "\n \n " + redirectPage + "\n \n " - : ""; -} -function exteriorPaginator(redirectPage, maxPage, content, condition) { - return condition && maxPage > 3 - ? "\n \n " + content + "\n \n " - : ""; -} diff --git a/build/server/components/ProductSpecComponent.js b/build/server/components/ProductSpecComponent.js deleted file mode 100644 index 27bc2b6..0000000 --- a/build/server/components/ProductSpecComponent.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function ProductSpecComponent(specTitle, specBody) { - return /* html */ "\n
\n " + specTitle + ": " + specBody + "\n
\n "; -} -exports.default = ProductSpecComponent; diff --git a/build/server/components/ProductSpecsComponent.js b/build/server/components/ProductSpecsComponent.js deleted file mode 100644 index c502aa5..0000000 --- a/build/server/components/ProductSpecsComponent.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var ProductSpecComponent_1 = __importDefault(require("./ProductSpecComponent")); -function ProductSpecsComponent(caracts) { - return Object.entries(caracts) - .map(function (_a) { - var key = _a[0], value = _a[1]; - return (0, ProductSpecComponent_1.default)(key, value); - }) - .join(""); -} -exports.default = ProductSpecsComponent; diff --git a/build/server/components/ProductsCardComponent.js b/build/server/components/ProductsCardComponent.js deleted file mode 100644 index f285bcc..0000000 --- a/build/server/components/ProductsCardComponent.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function ProductsCardComponent(_a, isFavorite) { - var image = _a.image, id = _a.id, price = _a.price, title = _a.title; - return /* html */ "\n
\n
\n
\n \n \n \n
\n ★\n
\n
\n
\n
\n
" + title + "
\n
$" + price + "
\n
\n Comprar\n
\n "; -} -exports.default = ProductsCardComponent; diff --git a/build/server/config.js b/build/server/config.js deleted file mode 100644 index 9eafcd3..0000000 --- a/build/server/config.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DATABASE_DIR = exports.PUBLIC_DIR = void 0; -var path = require('path'); -var ROOT_PATH = [__dirname, '..', '..']; -var ROOT = path.join.apply(path, ROOT_PATH); -var PUBLIC_DIR = path.join.apply(path, __spreadArray(__spreadArray([], ROOT_PATH, false), ['public'], false)); -exports.PUBLIC_DIR = PUBLIC_DIR; -var DATABASE_DIR = path.join.apply(path, __spreadArray(__spreadArray([], ROOT_PATH, false), ['database'], false)); -exports.DATABASE_DIR = DATABASE_DIR; diff --git a/build/server/interfaces/BasicProduct.js b/build/server/interfaces/BasicProduct.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/interfaces/BasicProduct.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/interfaces/CartProduct.js b/build/server/interfaces/CartProduct.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/interfaces/CartProduct.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/interfaces/CartStructure.js b/build/server/interfaces/CartStructure.js deleted file mode 100644 index 5fd3ac6..0000000 --- a/build/server/interfaces/CartStructure.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -// import { cartStructureProducts } from "../types/cart"; -// export default interface CartStructure { -// products: cartStructureProducts, -// quantityProducts: number, -// total: number -// } diff --git a/build/server/interfaces/Product.js b/build/server/interfaces/Product.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/interfaces/Product.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/interfaces/SearchURLParams.js b/build/server/interfaces/SearchURLParams.js deleted file mode 100644 index a411080..0000000 --- a/build/server/interfaces/SearchURLParams.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -// import { htmlFileName } from "../types/search"; -// export default interface SearchURLParams { -// htmlFileName: htmlFileName, -// page: string, -// id: string, -// search: string -// } diff --git a/build/server/routes.js b/build/server/routes.js deleted file mode 100644 index e228633..0000000 --- a/build/server/routes.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var ProductsAPI_1 = __importDefault(require("./classes/ProductsAPI")); -var Router = require("express").Router; -var router = Router(); -// CONTROLLERS -var productsController = require("./routes/products.controller"); -var productController = require("./routes/product.controller"); -var indexController = require("./routes/index.controller"); -var cartController = require("./routes/cart.controller"); -router.get("/", indexController); -router.get("/products/:page", productsController); -router.get("/products", productsController); -router.get("/product/:id", productController); -router.get("/cart", cartController); -// POST -router.post("/products/ids", function (req, res) { - var response = new ProductsAPI_1.default(req).getProductsById(); - res.json(response); -}); -router.post("/products/:page", function (req, res) { - var response = new ProductsAPI_1.default(req).getProducts(); - res.json(response); -}); -router.post("/products", function (req, res) { - var response = new ProductsAPI_1.default(req).getProducts(); - res.json(response); -}); -router.use(function (req, res) { - res.status(404).render("404"); -}); -module.exports = router; diff --git a/build/server/routes/cart.controller.js b/build/server/routes/cart.controller.js deleted file mode 100644 index 39e5c31..0000000 --- a/build/server/routes/cart.controller.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -module.exports = function indexController(req, res) { - res.render('cart'); -}; diff --git a/build/server/routes/index.controller.js b/build/server/routes/index.controller.js deleted file mode 100644 index 3c5fe6a..0000000 --- a/build/server/routes/index.controller.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -module.exports = function indexController(req, res) { - res.render('index'); -}; diff --git a/build/server/routes/product.controller.js b/build/server/routes/product.controller.js deleted file mode 100644 index fdb75b4..0000000 --- a/build/server/routes/product.controller.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var API_1 = __importDefault(require("../classes/API")); -var ProductSpecsComponent_1 = __importDefault(require("../components/ProductSpecsComponent")); -module.exports = function productController(req, res) { - var product = API_1.default.getProduct(+req.params.id); - var config = product; - config.productSpecs = (0, ProductSpecsComponent_1.default)(product.caracts); - config.isFavorite = true; - res.render("product", config); -}; diff --git a/build/server/routes/products.controller.js b/build/server/routes/products.controller.js deleted file mode 100644 index e4f1055..0000000 --- a/build/server/routes/products.controller.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var ProductsAPI_1 = __importDefault(require("../classes/ProductsAPI")); -var ProductsCardComponent_1 = __importDefault(require("../components/ProductsCardComponent")); -var PaginatorComponent_1 = __importDefault(require("../components/PaginatorComponent")); -module.exports = function productsController(req, res) { - var _a = new ProductsAPI_1.default(req).getProducts(), products = _a.products, page = _a.page, maxPage = _a.maxPage; - var productsHTML = products - .map(function (product) { return (0, ProductsCardComponent_1.default)(product, true); }) - .join(""); - var paginatorHTML = (0, PaginatorComponent_1.default)(page, maxPage); - res.render("products", { - productsHTML: productsHTML, - paginatorHTML: paginatorHTML, - }); -}; diff --git a/build/server/types/api.js b/build/server/types/api.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/api.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/cart.js b/build/server/types/cart.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/cart.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/favorites.js b/build/server/types/favorites.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/favorites.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/functions.js b/build/server/types/functions.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/functions.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/html.js b/build/server/types/html.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/html.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/products.js b/build/server/types/products.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/products.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/build/server/types/search.js b/build/server/types/search.js deleted file mode 100644 index c8ad2e5..0000000 --- a/build/server/types/search.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/database/config.json b/database/config.json new file mode 100644 index 0000000..f789d97 --- /dev/null +++ b/database/config.json @@ -0,0 +1 @@ +{"users":{"maxID":2}} \ No newline at end of file diff --git a/database/favorites.json b/database/favorites.json new file mode 100644 index 0000000..ab77c3e --- /dev/null +++ b/database/favorites.json @@ -0,0 +1,7 @@ +[{ + "id": 1, + "favoritesProducts": [] +}, { + "id": "2", + "favoritesProducts": ["12", "11", "14", "13"] +}] \ No newline at end of file diff --git a/database/users.json b/database/users.json new file mode 100644 index 0000000..65485b0 --- /dev/null +++ b/database/users.json @@ -0,0 +1,9 @@ +[{ + "id": 1, + "email": "gonzalobordon02@hotmail.com", + "password": "123" +}, { + "email": "xd", + "password": "12", + "id": 2 +}] \ No newline at end of file diff --git a/package.json b/package.json index 4ebafb5..4c40a65 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "start": "nodemon build/server/app.js" + "start": "nodemon build/server/app.js", + "runbuild": "tsc -b app/server/ && node build/server/app.js" }, "keywords": [], "author": "", diff --git a/public/css/index.css b/public/css/index.css index 850d795..ed05a96 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -68,13 +68,6 @@ form h5 { max-width: 600px; } -.contact-card { - margin: 20px; - padding: 20px; - border: 1px solid black; - border-radius: 5px; -} - .input-group { padding-bottom: 20px; } diff --git a/public/css/style.css b/public/css/style.css index cd1146d..c987ab1 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -161,6 +161,23 @@ footer { font-weight: bold; } +.contact-card { + margin: 20px; + padding: 20px 60px; + border: 1px solid black; + border-radius: 5px; +} + +.input-group { + padding: 0px 10px; +} + + +.input-group input { + width: 100%; + padding: 5px 10px; +} + /* @media (min-width: 576px) { } diff --git a/public/css/users.css b/public/css/users.css new file mode 100644 index 0000000..08d3a88 --- /dev/null +++ b/public/css/users.css @@ -0,0 +1,6 @@ +.users-container { + display: flex; + justify-content: space-evenly; + flex-wrap: wrap; + margin-block: 50px; +} \ No newline at end of file diff --git a/public/js/app.min.js b/public/js/app.min.js deleted file mode 100644 index 0d0cc95..0000000 --- a/public/js/app.min.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var t={24:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function a(t){try{c(r.next(t))}catch(t){u(t)}}function i(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,i)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,u,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function i(u){return function(i){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]{Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.followWithParams=function(e,n){window.location.replace(window.location.origin+e+t.stringfyParams(n))},t.followWithCurrentParams=function(e){window.location.replace(window.location.origin+e+t.getParams())},t.getParams=function(){return window.location.search},t.createURL=function(t){return window.location.origin+t},t.stringfyParams=function(t){return"?"+Object.keys(t).map((function(t){return t+"=params[key]"})).join("&")},t}();e.default=n},983:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){this.storageName=t,sessionStorage.getItem(t)||sessionStorage.setItem(t,JSON.stringify(e))}return t.prototype.updateStorage=function(t){sessionStorage.setItem(this.storageName,JSON.stringify(t))},t.prototype.deleteStorage=function(){sessionStorage.removeItem(this.storageName)},t.prototype.getStorage=function(){return JSON.parse(sessionStorage.getItem(this.storageName))},t}();e.default=n},930:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(236)),u=r(n(534)),a=function(){function t(t){this.document=t}return t.prototype.products=function(t,e,n,r){e.map((function(e){return(0,o.default)(e,t.isFavorite(e.id))})).join(""),(0,u.default)(n||1,r)},t}();e.default=a},497:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=t.units,n=t.price,r=t.total,o=t.id;return'\n \n \n
-1
\n
+1
\n \n \n \n '+t.title+'\n \n \n '+e+'\n $'+n+'\n $'+r+"\n \n "}},596:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(497));e.default=function(t){var e=0;return{CartTable:Object.values(t).map((function(t){return e+=t.total,(0,o.default)(t)})).join(""),total:e}}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SS_FAVORITES=e.SS_CART=e.API_ERROR=e.API_POSTS=e.CURRENT_PAGE=e.DEFAULT_HTML_FILE=e.PAGES=e.SEARCH_PAIR_INPUTS=e.QUANTITY_PRODUCTS_INDICATOR=void 0;var n=document.getElementById("search-input-s"),r=document.getElementById("search-input"),o=document.getElementById("quantityProducts");e.QUANTITY_PRODUCTS_INDICATOR=o;var u=window.location.pathname.split("/")[1];e.CURRENT_PAGE=u,e.PAGES=["index","cart","products","product","error"],e.DEFAULT_HTML_FILE="index";var a={"search-button-s":n,"search-button":r};e.SEARCH_PAIR_INPUTS=a,e.API_POSTS="https://jsonplaceholder.typicode.com/posts/",e.API_ERROR="ERROR",e.SS_CART="cart",e.SS_FAVORITES="favorites"},677:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){alert(t)}},2:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){alert(t)}},750:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(503));e.default=function(t,e,n){t.addEventListener("click",(function(t){var r=(0,o.default)(t);e.addToCart(r),n()}))}},455:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(503));e.default=function(t,e,n){t.addEventListener("click",(function(t){var r=(0,o.default)(t);e.removeFromCart(r),n()}))}},555:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(539),u=r(n(483));e.default=function(t){var e=t.target;(0,u.default)(o.SEARCH_PAIR_INPUTS[e.id])}},513:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(483));e.default=function(t){13===t.keyCode&&(0,o.default)(t.target)}},331:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(260));e.default=function(t){document.getElementById("js-closeCart").addEventListener("click",(function(){t.close(),(0,o.default)()}))}},849:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(750)),u=r(n(455)),a=document.getElementsByClassName("reduceOneButton"),i=document.getElementsByClassName("increaseOneButton");e.default=function(t,e){Array.from(a).forEach((function(n){(0,u.default)(n,e,t)})),Array.from(i).forEach((function(n){(0,o.default)(n,e,t)}))}},770:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=document.getElementsByClassName("openNav-button"),r=document.getElementById("nav-container");e.default=function(){Array.from(n).forEach((function(t){t.addEventListener("click",(function(){r.classList.toggle("active")}))}))}},764:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(632)),u=document.getElementsByClassName("js-paginator");e.default=function(){Array.from(u).forEach((function(t){t.addEventListener("click",(function(t){var e=t.target.dataset.page;o.default.followWithCurrentParams("/products/"+e)}))}))}},290:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=r(n(555)),u=r(n(513)),a=document.getElementById("search-button-s"),i=document.getElementById("search-button"),c=document.getElementById("search-input-s"),s=document.getElementById("search-input");e.default=function(){c.addEventListener("keyup",u.default),s.addEventListener("keyup",u.default),a.addEventListener("click",o.default),i.addEventListener("click",o.default)}},170:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function a(t){try{c(r.next(t))}catch(t){u(t)}}function i(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,i)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,u,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function i(u){return function(i){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=t.target.parentElement.dataset.productId;return Number(e)}},260:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function a(t){try{c(r.next(t))}catch(t){u(t)}}function i(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,i)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,u,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function i(u){return function(i){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]{Object.defineProperty(e,"__esModule",{value:!0});var r=n(539);e.default=function(t){r.QUANTITY_PRODUCTS_INDICATOR.innerHTML=String(t)}},534:(t,e)=>{function n(t,e,n){return t>0&&t<=e?'\n \n '+t+"\n \n ":""}function r(t,e,n,r){return r&&e>3?'\n \n '+n+"\n \n ":""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){var o=t-1,u=t,a=t+1;return 1===t?(++o,++u,++a):t===e&&(--o,--u,--a),"\n "+r(1,e,"<<",t>2)+"\n "+n(o,e,t)+"\n "+n(u,e,t)+"\n "+n(a,e,t)+"\n "+r(e,e,">>",t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){var n=t.image,r=t.id,o=t.price;return'\n
\n
\n \n \n \n
\n ★\n
\n
\n
\n
'+t.title+"
\n
$"+o+'
\n
\n Comprar\n
\n '}}},e={};!function n(r){var o=e[r];if(void 0!==o)return o.exports;var u=e[r]={exports:{}};return t[r].call(u.exports,u,u.exports,n),u.exports}(266)})(); \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index 14d76ca..537a128 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -34,6 +34,7 @@
Mensaje:
+ Enviar diff --git a/views/partials/header.ejs b/views/partials/header.ejs index 9ad53d8..8d7f3da 100644 --- a/views/partials/header.ejs +++ b/views/partials/header.ejs @@ -11,6 +11,7 @@ + Web diff --git a/views/partials/nav.ejs b/views/partials/nav.ejs index 3d270f7..f459ee8 100644 --- a/views/partials/nav.ejs +++ b/views/partials/nav.ejs @@ -3,6 +3,7 @@ Inicio Sobre Nosotros diff --git a/views/product.ejs b/views/product.ejs index 73c3b98..c0924cb 100644 --- a/views/product.ejs +++ b/views/product.ejs @@ -4,7 +4,7 @@
-
+
diff --git a/views/users.ejs b/views/users.ejs new file mode 100644 index 0000000..e9041c1 --- /dev/null +++ b/views/users.ejs @@ -0,0 +1,42 @@ +<%- include('partials/header') %> +
+
+
+

Inicia Sesión

+
+
+
Correo Electrónico:
+ +
+
+
Contraseña:
+ +
+ Iniciar Sesión +
+
+
+ +
+
+

Regístate

+
+
+
Correo Electrónico:
+ +
+
+
Contraseña:
+ +
+
+
Repite la Contraseña:
+ +
+ Registrarse +
+
+
+
+ +<%- include('partials/footer') %> \ No newline at end of file diff --git a/views/users_logued.ejs b/views/users_logued.ejs new file mode 100644 index 0000000..575053d --- /dev/null +++ b/views/users_logued.ejs @@ -0,0 +1,7 @@ +<%- include('partials/header') %> + +
+

Usuario:

+
+ +<%- include('partials/footer') %> \ No newline at end of file