dashboard.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. const home = require("./home.js");
  2. const ingredients = require("./ingredients.js");
  3. const recipeBook = require("./recipeBook.js");
  4. const orders = require("./orders.js");
  5. const transactions = require("./transactions.js");
  6. const addIngredients = require("./addIngredients.js");
  7. const ingredientDetails = require("./ingredientDetails.js");
  8. const newIngredient = require("./newIngredient.js");
  9. const newOrder = require("./newOrder.js");
  10. const newRecipe = require("./newRecipe.js");
  11. const newTransaction = require("./newTransaction.js");
  12. const orderDetails = require("./orderDetails.js");
  13. const recipeDetails = require("./recipeDetails.js");
  14. const transactionDetails = require("./transactionDetails.js");
  15. class Ingredient{
  16. constructor(id, name, category, unitType, unit, parent){
  17. this.id = id;
  18. this.name = name;
  19. this.category = category;
  20. this.unitType = unitType;
  21. this.unit = unit;
  22. this.parent = parent;
  23. }
  24. convert(quantity){
  25. if(this.unitType === "mass"){
  26. switch(this.unit){
  27. case "g": break;
  28. case "kg": quantity /= 1000; break;
  29. case "oz": quantity /= 28.3495; break;
  30. case "lb": quantity /= 453.5924; break;
  31. }
  32. }else if(this.unitType === "volume"){
  33. switch(this.unit){
  34. case "ml": quantity *= 1000; break;
  35. case "l": break;
  36. case "tsp": quantity *= 202.8842; break;
  37. case "tbsp": quantity *= 67.6278; break;
  38. case "ozfl": quantity *= 33.8141; break;
  39. case "cup": quantity *= 4.1667; break;
  40. case "pt": quantity *= 2.1134; break;
  41. case "qt": quantity *= 1.0567; break;
  42. case "gal": quantity /= 3.7854; break;
  43. }
  44. }else if(this.unitType === "length"){
  45. switch(this.unit){
  46. case "mm": quantity *= 1000; break;
  47. case "cm": quantity *= 100; break;
  48. case "m": break;
  49. case "in": quantity *= 39.3701; break;
  50. case "ft": quantity *= 3.2808; break;
  51. }
  52. }
  53. return quantity;
  54. }
  55. }
  56. class Recipe{
  57. constructor(id, name, price, ingredients, parent){
  58. this.id = id;
  59. this.name = name;
  60. this.price = price;
  61. this.parent = parent;
  62. this.ingredients = [];
  63. for(let i = 0; i < ingredients.length; i++){
  64. for(let j = 0; j < parent.ingredients.length; j++){
  65. if(ingredients[i].ingredient === parent.ingredients[j].ingredient.id){
  66. this.ingredients.push({
  67. ingredient: parent.ingredients[j].ingredient,
  68. quantity: ingredients[i].quantity
  69. });
  70. break;
  71. }
  72. }
  73. }
  74. }
  75. }
  76. class Transaction{
  77. constructor(id, date, recipes, parent){
  78. this.id = id;
  79. this.parent = parent;
  80. this.date = new Date(date);
  81. this.recipes = [];
  82. for(let i = 0; i < recipes.length; i++){
  83. for(let j = 0; j < parent.recipes.length; j++){
  84. if(recipes[i].recipe === parent.recipes[j].id){
  85. this.recipes.push({
  86. recipe: parent.recipes[j],
  87. quantity: recipes[i].quantity
  88. });
  89. break;
  90. }
  91. }
  92. }
  93. }
  94. }
  95. class Order{
  96. constructor(id, name, date, ingredients, parent){
  97. this.id = id;
  98. this.name = name;
  99. this.date = new Date(date);
  100. this.ingredients = [];
  101. this.parent = parent;
  102. for(let i = 0; i < ingredients.length; i++){
  103. for(let j = 0; j < parent.ingredients.length; j++){
  104. if(ingredients[i].ingredient === parent.ingredients[j].ingredient.id){
  105. this.ingredients.push({
  106. ingredient: parent.ingredients[j].ingredient,
  107. quantity: ingredients[i].quantity,
  108. price: ingredients[i].price
  109. });
  110. }
  111. }
  112. }
  113. }
  114. convertPrice(unitType, unit, price){
  115. if(unitType === "mass"){
  116. switch(unit){
  117. case "g": break;
  118. case "kg": price *= 1000; break;
  119. case "oz": price *= 28.3495; break;
  120. case "lb": price *= 453.5924; break;
  121. }
  122. }else if(unitType === "volume"){
  123. switch(unit){
  124. case "ml": price /= 1000; break;
  125. case "l": break;
  126. case "tsp": price /= 202.8842; break;
  127. case "tbsp": price /= 67.6278; break;
  128. case "ozfl": price /= 33.8141; break;
  129. case "cup": price /= 4.1667; break;
  130. case "pt": price /= 2.1134; break;
  131. case "qt": price /= 1.0567; break;
  132. case "gal": price *= 3.7854; break;
  133. }
  134. }else if(unitType === "length"){
  135. switch(unit){
  136. case "mm": price /= 1000; break;
  137. case "cm": price /= 100; break;
  138. case "m": break;
  139. case "in": price /= 39.3701; break;
  140. case "ft": price /= 3.2808; break;
  141. }
  142. }
  143. return price;
  144. }
  145. }
  146. class Merchant{
  147. constructor(oldMerchant, transactions){
  148. this.name = oldMerchant.name;
  149. this.pos = oldMerchant.pos;
  150. this.ingredients = [];
  151. this.recipes = [];
  152. this.transactions = [];
  153. this.orders = [];
  154. this.units = {
  155. mass: ["g", "kg", "oz", "lb"],
  156. volume: ["ml", "l", "tsp", "tbsp", "ozfl", "cup", "pt", "qt", "gal"],
  157. length: ["mm", "cm", "m", "in", "foot"]
  158. }
  159. for(let i = 0; i < oldMerchant.inventory.length; i++){
  160. this.ingredients.push({
  161. ingredient: new Ingredient(
  162. oldMerchant.inventory[i].ingredient._id,
  163. oldMerchant.inventory[i].ingredient.name,
  164. oldMerchant.inventory[i].ingredient.category,
  165. oldMerchant.inventory[i].ingredient.unitType,
  166. oldMerchant.inventory[i].defaultUnit,
  167. this
  168. ),
  169. quantity: oldMerchant.inventory[i].quantity
  170. });
  171. }
  172. for(let i = 0; i < oldMerchant.recipes.length; i++){
  173. this.recipes.push(new Recipe(
  174. oldMerchant.recipes[i]._id,
  175. oldMerchant.recipes[i].name,
  176. oldMerchant.recipes[i].price,
  177. oldMerchant.recipes[i].ingredients,
  178. this
  179. ));
  180. }
  181. for(let i = 0; i < transactions.length; i++){
  182. this.transactions.push(new Transaction(
  183. transactions[i]._id,
  184. transactions[i].date,
  185. transactions[i].recipes,
  186. this
  187. ));
  188. }
  189. }
  190. /*
  191. Updates all specified item in the merchant's inventory and updates the page
  192. If ingredient doesn't exist, add it
  193. ingredients = {
  194. ingredient: Ingredient object,
  195. quantity: new quantity,
  196. defaultUnit: the default unit to be displayed
  197. }
  198. remove = set true if removing
  199. isOrder = set true if this is coming from an order
  200. */
  201. editIngredients(ingredients, remove = false, isOrder = false){
  202. for(let i = 0; i < ingredients.length; i++){
  203. let isNew = true;
  204. for(let j = 0; j < merchant.ingredients.length; j++){
  205. if(merchant.ingredients[j].ingredient === ingredients[i].ingredient){
  206. if(remove){
  207. merchant.ingredients.splice(j, 1);
  208. }else if(!remove && isOrder){
  209. merchant.ingredients[j].quantity += ingredients[i].quantity;
  210. }else{
  211. merchant.ingredients[j].quantity = ingredients[i].quantity;
  212. }
  213. isNew = false;
  214. break;
  215. }
  216. }
  217. if(isNew){
  218. merchant.ingredients.push({
  219. ingredient: ingredients[i].ingredient,
  220. quantity: parseFloat(ingredients[i].quantity),
  221. defaultUnit: ingredients[i].defaultUnit
  222. });
  223. }
  224. }
  225. homeStrandObj.drawInventoryCheckCard();
  226. ingredientsStrandObj.populateByProperty("category");
  227. addIngredientsComp.isPopulated = false;
  228. closeSidebar();
  229. }
  230. /*
  231. Updates a recipe in the merchants list of recipes
  232. Can create, edit or remove
  233. recipe = [Recipe object]
  234. remove = will remove recipe when true
  235. */
  236. editRecipes(recipes, remove = false){
  237. let isNew = true;
  238. for(let i = 0; i < recipes.length; i++){
  239. for(let j = 0; j < this.recipes.length; j++){
  240. if(recipes[i] === this.recipes[j]){
  241. if(remove){
  242. this.recipes.splice(j, 1);
  243. }else{
  244. this.recipes[j] = recipes[i];
  245. }
  246. isNew = false;
  247. break;
  248. }
  249. }
  250. if(isNew){
  251. merchant.recipes.push(recipes[i]);
  252. }
  253. }
  254. transactionsStrandObj.isPopulated = false;
  255. recipeBookStrandObj.populateRecipes();
  256. closeSidebar();
  257. }
  258. /*
  259. Updates a list of orders in the merchants list of orders
  260. Create/edit/remove
  261. orders = [Order object]
  262. remove = will remove order when true
  263. */
  264. editOrders(orders, remove = false){
  265. for(let i = 0; i < orders.length; i++){
  266. let isNew = true;
  267. for(let j = 0; j < this.orders.length; j++){
  268. if(orders[i] === this.orders[j]){
  269. if(remove){
  270. this.orders.splice(j, 1);
  271. }else{
  272. this.orders[j] = orders[i];
  273. }
  274. isNew = false;
  275. break;
  276. }
  277. }
  278. if(isNew){
  279. this.orders.push(orders[i]);
  280. }
  281. }
  282. ordersStrandObj.populate();
  283. closeSidebar();
  284. }
  285. editTransactions(transaction, remove = false){
  286. let isNew = true;
  287. for(let i = 0; i < this.transactions.length; i++){
  288. if(this.transactions[i] === transaction){
  289. if(remove){
  290. this.transactions.splice(i, 1);
  291. }
  292. isNew = false;
  293. break;
  294. }
  295. }
  296. if(isNew){
  297. this.transactions.push(transaction);
  298. this.transactions.sort((a, b) => a.date > b.date ? 1 : -1);
  299. }
  300. transactionsStrandObj.isPopulated = false;
  301. transactionsStrandObj.display();
  302. closeSidebar();
  303. }
  304. /*
  305. Gets the indices of two dates from transactions
  306. Inputs
  307. from: starting date
  308. to: ending date (default to now)
  309. Output
  310. Array containing starting index and ending index
  311. Note: Will return false if it cannot find both necessary dates
  312. */
  313. transactionIndices(from, to = new Date()){
  314. let indices = [];
  315. for(let i = 0; i < this.transactions.length; i++){
  316. if(this.transactions[i].date > from){
  317. indices.push(i);
  318. break;
  319. }
  320. }
  321. for(let i = this.transactions.length - 1; i >=0; i--){
  322. if(this.transactions[i].date < to){
  323. indices.push(i);
  324. break;
  325. }
  326. }
  327. if(indices.length < 2){
  328. return false;
  329. }
  330. return indices;
  331. }
  332. revenue(indices){
  333. let total = 0;
  334. for(let i = indices[0]; i <= indices[1]; i++){
  335. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  336. for(let k = 0; k < this.recipes.length; k++){
  337. if(this.transactions[i].recipes[j].recipe === this.recipes[k]){
  338. total += this.transactions[i].recipes[j].quantity * this.recipes[k].price;
  339. }
  340. }
  341. }
  342. }
  343. return total / 100;
  344. }
  345. /*
  346. Gets the quantity of each ingredient sold between two dates (dateRange)
  347. Inputs
  348. dateRange: list containing a start date and an end date
  349. Return:
  350. [{
  351. ingredient: Ingredient object,
  352. quantity: quantity of ingredient sold
  353. }]
  354. */
  355. ingredientsSold(dateRange){
  356. if(!dateRange){
  357. return false;
  358. }
  359. let recipes = this.recipesSold(dateRange);
  360. let ingredientList = [];
  361. for(let i = 0; i < recipes.length; i++){
  362. for(let j = 0; j < recipes[i].recipe.ingredients.length; j++){
  363. let exists = false;
  364. for(let k = 0; k < ingredientList.length; k++){
  365. if(ingredientList[k].ingredient === recipes[i].recipe.ingredients[j].ingredient){
  366. exists = true;
  367. ingredientList[k].quantity += recipes[i].quantity * recipes[i].recipe.ingredients[j].quantity;
  368. break;
  369. }
  370. }
  371. if(!exists){
  372. ingredientList.push({
  373. ingredient: recipes[i].recipe.ingredients[j].ingredient,
  374. quantity: recipes[i].quantity * recipes[i].recipe.ingredients[j].quantity
  375. });
  376. }
  377. }
  378. }
  379. return ingredientList;
  380. }
  381. singleIngredientSold(dateRange, ingredient){
  382. let total = 0;
  383. for(let i = dateRange[0]; i < dateRange[1]; i++){
  384. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  385. for(let k = 0; k < this.transactions[i].recipes[j].recipe.ingredients.length; k++){
  386. if(this.transactions[i].recipes[j].recipe.ingredients[k].ingredient === ingredient.ingredient){
  387. total += this.transactions[i].recipes[j].recipe.ingredients[k].quantity;
  388. break;
  389. }
  390. }
  391. }
  392. }
  393. return total;
  394. }
  395. /*
  396. Gets the number of recipes sold between two dates (dateRange)
  397. Inputs:
  398. dateRange: array containing a start date and an end date
  399. Return:
  400. [{
  401. recipe: a recipe object
  402. quantity: quantity of the recipe sold
  403. }]
  404. */
  405. recipesSold(dateRange){
  406. let recipeList = [];
  407. for(let i = dateRange[0]; i <= dateRange[1]; i++){
  408. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  409. let exists = false;
  410. for(let k = 0; k < recipeList.length; k++){
  411. if(recipeList[k].recipe === this.transactions[i].recipes[j].recipe){
  412. exists = true;
  413. recipeList[k].quantity += this.transactions[i].recipes[j].quantity;
  414. break;
  415. }
  416. }
  417. if(!exists){
  418. recipeList.push({
  419. recipe: this.transactions[i].recipes[j].recipe,
  420. quantity: this.transactions[i].recipes[j].quantity
  421. });
  422. }
  423. }
  424. }
  425. return recipeList;
  426. }
  427. /*
  428. Create revenue data for graphing
  429. Input:
  430. dateRange: [start index, end index] (this.transactionIndices)
  431. Return:
  432. [total revenue for each day]
  433. */
  434. graphDailyRevenue(dateRange){
  435. if(!dateRange){
  436. return false;
  437. }
  438. let dataList = new Array(30).fill(0);
  439. let currentDate = this.transactions[dateRange[0]].date;
  440. let arrayIndex = 0;
  441. for(let i = dateRange[0]; i <= dateRange[1]; i++){
  442. if(this.transactions[i].date.getDate() !== currentDate.getDate()){
  443. currentDate = this.transactions[i].date;
  444. arrayIndex++;
  445. }
  446. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  447. dataList[arrayIndex] += (this.transactions[i].recipes[j].recipe.price / 100) * this.transactions[i].recipes[j].quantity;
  448. }
  449. }
  450. return dataList;
  451. }
  452. /*
  453. Groups all of the merchant's ingredients by their category
  454. Return: [{
  455. name: category name,
  456. ingredients: [Ingredient Object]
  457. }]
  458. */
  459. categorizeIngredients(){
  460. let ingredientsByCategory = [];
  461. for(let i = 0; i < this.ingredients.length; i++){
  462. let categoryExists = false;
  463. for(let j = 0; j < ingredientsByCategory.length; j++){
  464. if(this.ingredients[i].ingredient.category === ingredientsByCategory[j].name){
  465. ingredientsByCategory[j].ingredients.push(this.ingredients[i]);
  466. categoryExists = true;
  467. break;
  468. }
  469. }
  470. if(!categoryExists){
  471. ingredientsByCategory.push({
  472. name: this.ingredients[i].ingredient.category,
  473. ingredients: [this.ingredients[i]]
  474. });
  475. }
  476. }
  477. return ingredientsByCategory;
  478. }
  479. unitizeIngredients(){
  480. let ingredientsByUnit = [];
  481. for(let i = 0; i < this.ingredients.length; i++){
  482. let unitExists = false;
  483. for(let j = 0; j < ingredientsByUnit.length; j++){
  484. if(this.ingredients[i].ingredient.unit === ingredientsByUnit[j].name){
  485. ingredientsByUnit[j].ingredients.push(this.ingredients[i]);
  486. unitExists = true;
  487. break;
  488. }
  489. }
  490. if(!unitExists){
  491. ingredientsByUnit.push({
  492. name: this.ingredients[i].ingredient.unit,
  493. ingredients: [this.ingredients[i]]
  494. });
  495. }
  496. }
  497. return ingredientsByUnit;
  498. }
  499. getRecipesForIngredient(ingredient){
  500. let recipes = [];
  501. for(let i = 0; i < this.recipes.length; i++){
  502. for(let j = 0; j < this.recipes[i].ingredients.length; j++){
  503. if(this.recipes[i].ingredients[j].ingredient === ingredient){
  504. recipes.push(this.recipes[i]);
  505. }
  506. }
  507. }
  508. return recipes;
  509. }
  510. }
  511. let convertToMain = (unit, quantity)=>{
  512. let converted = 0;
  513. if(merchant.units.mass.includes(unit)){
  514. switch(unit){
  515. case "g": converted = quantity; break;
  516. case "kg": converted = quantity * 1000; break;
  517. case "oz": converted = quantity * 28.3495; break;
  518. case "lb": converted = quantity * 453.5924; break;
  519. }
  520. }else if(merchant.units.volume.includes(unit)){
  521. switch(unit){
  522. case "ml": converted = quantity / 1000; break;
  523. case "l": converted = quantity; break;
  524. case "tsp": converted = quantity / 202.8842; break;
  525. case "tbsp": converted = quantity / 67.6278; break;
  526. case "ozfl": converted = quantity / 33.8141; break;
  527. case "cup": converted = quantity / 4.1667; break;
  528. case "pt": converted = quantity / 2.1134; break;
  529. case "qt": converted = quantity / 1.0567; break;
  530. case "gal": converted = quantity * 3.7854; break;
  531. }
  532. }else if(merchant.units.length.includes(unit)){
  533. switch(unit){
  534. case "mm": converted = quantity / 1000; break;
  535. case "cm": converted = quantity / 100; break;
  536. case "m": converted = quantity; break;
  537. case "in": converted = quantity / 39.3701; break;
  538. case "ft": converted = quantity / 3.2808; break;
  539. }
  540. }else{
  541. converted = quantity;
  542. }
  543. return converted;
  544. }
  545. /*
  546. Switches to a different strand
  547. Input:
  548. name: name of the strand. Must end with "Strand"
  549. */
  550. window.changeStrand = (name)=>{
  551. closeSidebar();
  552. for(let strand of document.querySelectorAll(".strand")){
  553. strand.style.display = "none";
  554. }
  555. let buttons = document.querySelectorAll(".menuButton");
  556. for(let i = 0; i < buttons.length - 1; i++){
  557. buttons[i].classList = "menuButton";
  558. buttons[i].disabled = false;
  559. }
  560. let activeButton = {};
  561. switch(name){
  562. case 1:
  563. activeButton = document.getElementById("homeBtn");
  564. document.getElementById("homeStrand").style.display = "flex";
  565. home.display();
  566. break;
  567. case 2:
  568. activeButton = document.getElementById("ingredientsBtn");
  569. document.getElementById("ingredientsStrand").style.display = "flex";
  570. ingredients.display();
  571. break;
  572. case 3:
  573. activeButton = document.getElementById("recipeBookBtn");
  574. document.getElementById("recipeBookStrand").style.display = "flex";
  575. recipeBook.display();
  576. break;
  577. case 4:
  578. activeButton = document.getElementById("ordersBtn");
  579. document.getElementById("ordersStrand").style.display = "flex";
  580. orders.display();
  581. break;
  582. case 5:
  583. activeButton = document.getElementById("transactionsBtn");
  584. document.getElementById("transactionsStrand").style.display = "flex";
  585. transactions.display();
  586. break;
  587. }
  588. activeButton.classList = "menuButton active";
  589. activeButton.disabled = true;
  590. if(window.screen.availWidth <= 1000){
  591. closeMenu();
  592. }
  593. }
  594. //Close any open sidebar
  595. let closeSidebar = ()=>{
  596. let sidebar = document.querySelector("#sidebarDiv");
  597. for(let i = 0; i < sidebar.children.length; i++){
  598. sidebar.children[i].style.display = "none";
  599. }
  600. sidebar.classList = "sidebarHide";
  601. if(window.screen.availWidth <= 1000){
  602. document.querySelector(".contentBlock").style.display = "flex";
  603. document.getElementById("mobileMenuSelector").style.display = "block";
  604. document.getElementById("sidebarCloser").style.display = "none";
  605. }
  606. }
  607. /*
  608. Open a specific sidebar
  609. Input:
  610. sidebar: the outermost element of the sidebar (must contain class sidebar)
  611. */
  612. let openSidebar = (sidebar)=>{
  613. document.querySelector("#sidebarDiv").classList = "sidebar";
  614. let sideBars = document.querySelector("#sidebarDiv").children;
  615. for(let i = 0; i < sideBars.length; i++){
  616. sideBars[i].style.display = "none";
  617. }
  618. sidebar.style.display = "flex";
  619. if(window.screen.availWidth <= 1000){
  620. document.querySelector(".contentBlock").style.display = "none";
  621. document.getElementById("mobileMenuSelector").style.display = "none";
  622. document.getElementById("sidebarCloser").style.display = "block";
  623. }
  624. }
  625. let changeMenu = ()=>{
  626. let menu = document.querySelector(".menu");
  627. let buttons = document.querySelectorAll(".menuButton");
  628. if(!menu.classList.contains("menuMinimized")){
  629. menu.classList = "menu menuMinimized";
  630. for(let button of buttons){
  631. button.children[1].style.display = "none";
  632. }
  633. document.querySelector("#max").style.display = "none";
  634. document.querySelector("#min").style.display = "flex";
  635. }else if(menu.classList.contains("menuMinimized")){
  636. menu.classList = "menu";
  637. for(let button of buttons){
  638. button.children[1].style.display = "block";
  639. }
  640. setTimeout(()=>{
  641. document.querySelector("#max").style.display = "flex";
  642. document.querySelector("#min").style.display = "none";
  643. }, 150);
  644. }
  645. }
  646. let openMenu = ()=>{
  647. document.getElementById("menu").style.display = "flex";
  648. document.querySelector(".contentBlock").style.display = "none";
  649. document.getElementById("mobileMenuSelector").onclick = ()=>{closeMenu()};
  650. }
  651. let closeMenu = ()=>{
  652. document.getElementById("menu").style.display = "none";
  653. document.querySelector(".contentBlock").style.display = "flex";
  654. document.getElementById("mobileMenuSelector").onclick = ()=>{openMenu()};
  655. }
  656. if(window.screen.availWidth > 1000 && window.screen.availWidth <= 1400){
  657. changeMenu();
  658. document.getElementById("menuShifter2").style.display = "none";
  659. }
  660. merchant = new Merchant(data.merchant, data.transactions);
  661. home.display(merchant);