How to use toTime method in Playwright Internal

Best JavaScript code snippet using playwright-internal

userController.js

Source:userController.js Github

copy

Full Screen

1const userModel = require("../Models/userModel");2const coachCategoryHeaderpageModel = require("../Models/coachCategoryHeaderModel");3const bcrypt = require("bcrypt");4const jwt = require("jsonwebtoken");5const fs = require("fs");6const firebase = require("firebase/auth");7const { send } = require("process");8const { ObjectId } = require("mongoose").Types;9const { query } = require("express");10require("dotenv").config();11const dotenv = require("dotenv");12var moment = require("moment");13dotenv.config();14const nodemailer = require("nodemailer");15// Quick blocks16const axios = require("axios").default;17async function getQBSessionToken() {18 var data = JSON.stringify({19 application_id: "95771",20 auth_key: "X4EzAusgQsK75nK",21 timestamp: "1645437241",22 nonce: "7334",23 signature: "206cd408a3785aaa66d3c9fe02c7885acf182b04",24 });25 var config = {26 method: "post",27 url: "https://api.quickblox.com/session.json",28 headers: {29 "Content-Type": "application/json",30 },31 data: data,32 };33 let token;34 await axios(config)35 .then(function (response) {36 //console.log(JSON.stringify(response.data.session.token));37 return (token = response.data.session.token);38 })39 .catch(function (error) {40 //console.log(error);41 return (token = error);42 });43 return token;44}45async function createQBUser(token, email, phone, userType) {46 var data = JSON.stringify({47 user: {48 login: email,49 password: `QB@${phone}`,50 full_name: phone,51 phone: phone,52 tag_list: userType,53 age_over16: true,54 },55 });56 var config = {57 method: "post",58 url: "https://api.quickblox.com/users.json",59 headers: {60 "QB-Token": token,61 "Content-Type": "application/json",62 },63 data: data,64 };65 let QBuser;66 await axios(config)67 .then(function (response) {68 //console.log(JSON.stringify(response.data));69 return (QBuser = response.data.user);70 })71 .catch(function (error) {72 // console.log(error);73 return (QBuser = error);74 });75 return QBuser;76}77module.exports = {78 //Create User79 async create(req, res) {80 let trainerAvailability = [81 {82 day: "Monday",83 date: "03-01-2022",84 slots: [85 {86 toTime: "01 AM",87 fromTime: "02 AM",88 status: 1, // 0-Active, 1- Inactive89 },90 {91 toTime: "02 AM",92 fromTime: "03 AM",93 status: 1, // 0-Active, 1- Inactive94 },95 {96 toTime: "03 AM",97 fromTime: "04 AM",98 status: 1, // 0-Active, 1- Inactive99 },100 {101 toTime: "04 AM",102 fromTime: "05 AM",103 status: 1, // 0-Active, 1- Inactive104 },105 {106 toTime: "05 AM",107 fromTime: "06 AM",108 status: 1, // 0-Active, 1- Inactive109 },110 {111 toTime: "06 AM",112 fromTime: "07 AM",113 status: 1, // 0-Active, 1- Inactive114 },115 {116 toTime: "07 AM",117 fromTime: "08 AM",118 status: 1, // 0-Active, 1- Inactive119 },120 {121 toTime: "08 AM",122 fromTime: "09 AM",123 status: 1, // 0-Active, 1- Inactive124 },125 {126 toTime: "09 AM",127 fromTime: "10 AM",128 status: 1, // 0-Active, 1- Inactive129 },130 {131 toTime: "10 AM",132 fromTime: "11 AM",133 status: 1, // 0-Active, 1- Inactive134 },135 {136 toTime: "11 AM",137 fromTime: "12 PM",138 status: 1, // 0-Active, 1- Inactive139 },140 {141 toTime: "12 PM",142 fromTime: "01 PM",143 status: 1, // 0-Active, 1- Inactive144 },145 {146 toTime: "01 PM",147 fromTime: "02 PM",148 status: 1, // 0-Active, 1- Inactive149 },150 {151 toTime: "02 PM",152 fromTime: "03 PM",153 status: 1, // 0-Active, 1- Inactive154 },155 {156 toTime: "03 PM",157 fromTime: "04 PM",158 status: 1, // 0-Active, 1- Inactive159 },160 {161 toTime: "04 PM",162 fromTime: "05 PM",163 status: 1, // 0-Active, 1- Inactive164 },165 {166 toTime: "05 PM",167 fromTime: "06 PM",168 status: 1, // 0-Active, 1- Inactive169 },170 {171 toTime: "06 PM",172 fromTime: "07 PM",173 status: 1, // 0-Active, 1- Inactive174 },175 {176 toTime: "07 PM",177 fromTime: "08 PM",178 status: 1, // 0-Active, 1- Inactive179 },180 {181 toTime: "08 PM",182 fromTime: "09 PM",183 status: 1, // 0-Active, 1- Inactive184 },185 {186 toTime: "09 PM",187 fromTime: "10 PM",188 status: 1, // 0-Active, 1- Inactive189 },190 {191 toTime: "10 PM",192 fromTime: "11 PM",193 status: 1, // 0-Active, 1- Inactive194 },195 {196 toTime: "11 PM",197 fromTime: "12 AM",198 status: 1, // 0-Active, 1- Inactive199 },200 {201 toTime: "12 AM",202 fromTime: "01 AM",203 status: 1, // 0-Active, 1- Inactive204 },205 ],206 status: 1, // 0- Active, 1- Inactive207 },208 {209 day: "Tuesday",210 date: "04-01-2022",211 slots: [212 {213 toTime: "01 AM",214 fromTime: "02 AM",215 status: 1, // 0-Active, 1- Inactive216 },217 {218 toTime: "02 AM",219 fromTime: "03 AM",220 status: 1, // 0-Active, 1- Inactive221 },222 {223 toTime: "03 AM",224 fromTime: "04 AM",225 status: 1, // 0-Active, 1- Inactive226 },227 {228 toTime: "04 AM",229 fromTime: "05 AM",230 status: 1, // 0-Active, 1- Inactive231 },232 {233 toTime: "05 AM",234 fromTime: "06 AM",235 status: 1, // 0-Active, 1- Inactive236 },237 {238 toTime: "06 AM",239 fromTime: "07 AM",240 status: 1, // 0-Active, 1- Inactive241 },242 {243 toTime: "07 AM",244 fromTime: "08 AM",245 status: 1, // 0-Active, 1- Inactive246 },247 {248 toTime: "08 AM",249 fromTime: "09 AM",250 status: 1, // 0-Active, 1- Inactive251 },252 {253 toTime: "09 AM",254 fromTime: "10 AM",255 status: 1, // 0-Active, 1- Inactive256 },257 {258 toTime: "10 AM",259 fromTime: "11 AM",260 status: 1, // 0-Active, 1- Inactive261 },262 {263 toTime: "11 AM",264 fromTime: "12 PM",265 status: 1, // 0-Active, 1- Inactive266 },267 {268 toTime: "12 PM",269 fromTime: "01 PM",270 status: 1, // 0-Active, 1- Inactive271 },272 {273 toTime: "01 PM",274 fromTime: "02 PM",275 status: 1, // 0-Active, 1- Inactive276 },277 {278 toTime: "02 PM",279 fromTime: "03 PM",280 status: 1, // 0-Active, 1- Inactive281 },282 {283 toTime: "03 PM",284 fromTime: "04 PM",285 status: 1, // 0-Active, 1- Inactive286 },287 {288 toTime: "04 PM",289 fromTime: "05 PM",290 status: 1, // 0-Active, 1- Inactive291 },292 {293 toTime: "05 PM",294 fromTime: "06 PM",295 status: 1, // 0-Active, 1- Inactive296 },297 {298 toTime: "06 PM",299 fromTime: "07 PM",300 status: 1, // 0-Active, 1- Inactive301 },302 {303 toTime: "07 PM",304 fromTime: "08 PM",305 status: 1, // 0-Active, 1- Inactive306 },307 {308 toTime: "08 PM",309 fromTime: "09 PM",310 status: 1, // 0-Active, 1- Inactive311 },312 {313 toTime: "09 PM",314 fromTime: "10 PM",315 status: 1, // 0-Active, 1- Inactive316 },317 {318 toTime: "10 PM",319 fromTime: "11 PM",320 status: 1, // 0-Active, 1- Inactive321 },322 {323 toTime: "11 PM",324 fromTime: "12 AM",325 status: 1, // 0-Active, 1- Inactive326 },327 {328 toTime: "12 AM",329 fromTime: "01 AM",330 status: 1, // 0-Active, 1- Inactive331 },332 ],333 status: 1, // 0- Active, 1- Inactive334 },335 {336 day: "Wednesday",337 date: "05-01-2022",338 slots: [339 {340 toTime: "01 AM",341 fromTime: "02 AM",342 status: 1, // 0-Active, 1- Inactive343 },344 {345 toTime: "02 AM",346 fromTime: "03 AM",347 status: 1, // 0-Active, 1- Inactive348 },349 {350 toTime: "03 AM",351 fromTime: "04 AM",352 status: 1, // 0-Active, 1- Inactive353 },354 {355 toTime: "04 AM",356 fromTime: "05 AM",357 status: 1, // 0-Active, 1- Inactive358 },359 {360 toTime: "05 AM",361 fromTime: "06 AM",362 status: 1, // 0-Active, 1- Inactive363 },364 {365 toTime: "06 AM",366 fromTime: "07 AM",367 status: 1, // 0-Active, 1- Inactive368 },369 {370 toTime: "07 AM",371 fromTime: "08 AM",372 status: 1, // 0-Active, 1- Inactive373 },374 {375 toTime: "08 AM",376 fromTime: "09 AM",377 status: 1, // 0-Active, 1- Inactive378 },379 {380 toTime: "09 AM",381 fromTime: "10 AM",382 status: 1, // 0-Active, 1- Inactive383 },384 {385 toTime: "10 AM",386 fromTime: "11 AM",387 status: 1, // 0-Active, 1- Inactive388 },389 {390 toTime: "11 AM",391 fromTime: "12 PM",392 status: 1, // 0-Active, 1- Inactive393 },394 {395 toTime: "12 PM",396 fromTime: "01 PM",397 status: 1, // 0-Active, 1- Inactive398 },399 {400 toTime: "01 PM",401 fromTime: "02 PM",402 status: 1, // 0-Active, 1- Inactive403 },404 {405 toTime: "02 PM",406 fromTime: "03 PM",407 status: 1, // 0-Active, 1- Inactive408 },409 {410 toTime: "03 PM",411 fromTime: "04 PM",412 status: 1, // 0-Active, 1- Inactive413 },414 {415 toTime: "04 PM",416 fromTime: "05 PM",417 status: 1, // 0-Active, 1- Inactive418 },419 {420 toTime: "05 PM",421 fromTime: "06 PM",422 status: 1, // 0-Active, 1- Inactive423 },424 {425 toTime: "06 PM",426 fromTime: "07 PM",427 status: 1, // 0-Active, 1- Inactive428 },429 {430 toTime: "07 PM",431 fromTime: "08 PM",432 status: 1, // 0-Active, 1- Inactive433 },434 {435 toTime: "08 PM",436 fromTime: "09 PM",437 status: 1, // 0-Active, 1- Inactive438 },439 {440 toTime: "09 PM",441 fromTime: "10 PM",442 status: 1, // 0-Active, 1- Inactive443 },444 {445 toTime: "10 PM",446 fromTime: "11 PM",447 status: 1, // 0-Active, 1- Inactive448 },449 {450 toTime: "11 PM",451 fromTime: "12 AM",452 status: 1, // 0-Active, 1- Inactive453 },454 {455 toTime: "12 AM",456 fromTime: "01 AM",457 status: 1, // 0-Active, 1- Inactive458 },459 ],460 status: 1, // 0- Active, 1- Inactive461 },462 {463 day: "Thursday",464 date: "06-01-2022",465 slots: [466 {467 toTime: "01 AM",468 fromTime: "02 AM",469 status: 1, // 0-Active, 1- Inactive470 },471 {472 toTime: "02 AM",473 fromTime: "03 AM",474 status: 1, // 0-Active, 1- Inactive475 },476 {477 toTime: "03 AM",478 fromTime: "04 AM",479 status: 1, // 0-Active, 1- Inactive480 },481 {482 toTime: "04 AM",483 fromTime: "05 AM",484 status: 1, // 0-Active, 1- Inactive485 },486 {487 toTime: "05 AM",488 fromTime: "06 AM",489 status: 1, // 0-Active, 1- Inactive490 },491 {492 toTime: "06 AM",493 fromTime: "07 AM",494 status: 1, // 0-Active, 1- Inactive495 },496 {497 toTime: "07 AM",498 fromTime: "08 AM",499 status: 1, // 0-Active, 1- Inactive500 },501 {502 toTime: "08 AM",503 fromTime: "09 AM",504 status: 1, // 0-Active, 1- Inactive505 },506 {507 toTime: "09 AM",508 fromTime: "10 AM",509 status: 1, // 0-Active, 1- Inactive510 },511 {512 toTime: "10 AM",513 fromTime: "11 AM",514 status: 1, // 0-Active, 1- Inactive515 },516 {517 toTime: "11 AM",518 fromTime: "12 PM",519 status: 1, // 0-Active, 1- Inactive520 },521 {522 toTime: "12 PM",523 fromTime: "01 PM",524 status: 1, // 0-Active, 1- Inactive525 },526 {527 toTime: "01 PM",528 fromTime: "02 PM",529 status: 1, // 0-Active, 1- Inactive530 },531 {532 toTime: "02 PM",533 fromTime: "03 PM",534 status: 1, // 0-Active, 1- Inactive535 },536 {537 toTime: "03 PM",538 fromTime: "04 PM",539 status: 1, // 0-Active, 1- Inactive540 },541 {542 toTime: "04 PM",543 fromTime: "05 PM",544 status: 1, // 0-Active, 1- Inactive545 },546 {547 toTime: "05 PM",548 fromTime: "06 PM",549 status: 1, // 0-Active, 1- Inactive550 },551 {552 toTime: "06 PM",553 fromTime: "07 PM",554 status: 1, // 0-Active, 1- Inactive555 },556 {557 toTime: "07 PM",558 fromTime: "08 PM",559 status: 1, // 0-Active, 1- Inactive560 },561 {562 toTime: "08 PM",563 fromTime: "09 PM",564 status: 1, // 0-Active, 1- Inactive565 },566 {567 toTime: "09 PM",568 fromTime: "10 PM",569 status: 1, // 0-Active, 1- Inactive570 },571 {572 toTime: "10 PM",573 fromTime: "11 PM",574 status: 1, // 0-Active, 1- Inactive575 },576 {577 toTime: "11 PM",578 fromTime: "12 AM",579 status: 1, // 0-Active, 1- Inactive580 },581 {582 toTime: "12 AM",583 fromTime: "01 AM",584 status: 1, // 0-Active, 1- Inactive585 },586 ],587 status: 1, // 0- Active, 1- Inactive588 },589 {590 day: "Friday",591 date: "07-01-2022",592 slots: [593 {594 toTime: "10 AM",595 fromTime: "11 AM",596 status: 1,597 },598 {599 toTime: "11 AM",600 fromTime: "12 PM",601 status: 1,602 },603 {604 toTime: "12 PM",605 fromTime: "1 PM",606 status: 1,607 },608 {609 toTime: "1 PM",610 fromTime: "2 PM",611 status: 1,612 },613 {614 toTime: "2 PM",615 fromTime: "3 PM",616 status: 1,617 },618 {619 toTime: "3 PM",620 fromTime: "4 PM",621 status: 1,622 },623 {624 toTime: "4 PM",625 fromTime: "5 PM",626 status: 1,627 },628 {629 toTime: "5 PM",630 fromTime: "6 PM",631 status: 1,632 },633 {634 toTime: "6 PM",635 fromTime: "7 PM",636 status: 1,637 },638 {639 toTime: "7 PM",640 fromTime: "8 PM",641 status: 1,642 },643 {644 toTime: "8 PM",645 fromTime: "9 PM",646 status: 1,647 },648 {649 toTime: "9 PM",650 fromTime: "10 PM",651 status: 1,652 },653 ],654 status: 1, // 0- Active, 1- Inactive655 },656 {657 day: "Saturday",658 date: "08-01-2022",659 slots: [660 {661 toTime: "01 AM",662 fromTime: "02 AM",663 status: 1, // 0-Active, 1- Inactive664 },665 {666 toTime: "02 AM",667 fromTime: "03 AM",668 status: 1, // 0-Active, 1- Inactive669 },670 {671 toTime: "03 AM",672 fromTime: "04 AM",673 status: 1, // 0-Active, 1- Inactive674 },675 {676 toTime: "04 AM",677 fromTime: "05 AM",678 status: 1, // 0-Active, 1- Inactive679 },680 {681 toTime: "05 AM",682 fromTime: "06 AM",683 status: 1, // 0-Active, 1- Inactive684 },685 {686 toTime: "06 AM",687 fromTime: "07 AM",688 status: 1, // 0-Active, 1- Inactive689 },690 {691 toTime: "07 AM",692 fromTime: "08 AM",693 status: 1, // 0-Active, 1- Inactive694 },695 {696 toTime: "08 AM",697 fromTime: "09 AM",698 status: 1, // 0-Active, 1- Inactive699 },700 {701 toTime: "09 AM",702 fromTime: "10 AM",703 status: 1, // 0-Active, 1- Inactive704 },705 {706 toTime: "10 AM",707 fromTime: "11 AM",708 status: 1, // 0-Active, 1- Inactive709 },710 {711 toTime: "11 AM",712 fromTime: "12 PM",713 status: 1, // 0-Active, 1- Inactive714 },715 {716 toTime: "12 PM",717 fromTime: "01 PM",718 status: 1, // 0-Active, 1- Inactive719 },720 {721 toTime: "01 PM",722 fromTime: "02 PM",723 status: 1, // 0-Active, 1- Inactive724 },725 {726 toTime: "02 PM",727 fromTime: "03 PM",728 status: 1, // 0-Active, 1- Inactive729 },730 {731 toTime: "03 PM",732 fromTime: "04 PM",733 status: 1, // 0-Active, 1- Inactive734 },735 {736 toTime: "04 PM",737 fromTime: "05 PM",738 status: 1, // 0-Active, 1- Inactive739 },740 {741 toTime: "05 PM",742 fromTime: "06 PM",743 status: 1, // 0-Active, 1- Inactive744 },745 {746 toTime: "06 PM",747 fromTime: "07 PM",748 status: 1, // 0-Active, 1- Inactive749 },750 {751 toTime: "07 PM",752 fromTime: "08 PM",753 status: 1, // 0-Active, 1- Inactive754 },755 {756 toTime: "08 PM",757 fromTime: "09 PM",758 status: 1, // 0-Active, 1- Inactive759 },760 {761 toTime: "09 PM",762 fromTime: "10 PM",763 status: 1, // 0-Active, 1- Inactive764 },765 {766 toTime: "10 PM",767 fromTime: "11 PM",768 status: 1, // 0-Active, 1- Inactive769 },770 {771 toTime: "11 PM",772 fromTime: "12 AM",773 status: 1, // 0-Active, 1- Inactive774 },775 {776 toTime: "12 AM",777 fromTime: "01 AM",778 status: 1, // 0-Active, 1- Inactive779 },780 ],781 status: 1, // 0- Active, 1- Inactive782 },783 {784 day: "Sunday",785 date: "09-01-2022",786 slots: [787 {788 toTime: "01 AM",789 fromTime: "02 AM",790 status: 1, // 0-Active, 1- Inactive791 },792 {793 toTime: "02 AM",794 fromTime: "03 AM",795 status: 1, // 0-Active, 1- Inactive796 },797 {798 toTime: "03 AM",799 fromTime: "04 AM",800 status: 1, // 0-Active, 1- Inactive801 },802 {803 toTime: "04 AM",804 fromTime: "05 AM",805 status: 1, // 0-Active, 1- Inactive806 },807 {808 toTime: "05 AM",809 fromTime: "06 AM",810 status: 1, // 0-Active, 1- Inactive811 },812 {813 toTime: "06 AM",814 fromTime: "07 AM",815 status: 1, // 0-Active, 1- Inactive816 },817 {818 toTime: "07 AM",819 fromTime: "08 AM",820 status: 1, // 0-Active, 1- Inactive821 },822 {823 toTime: "08 AM",824 fromTime: "09 AM",825 status: 1, // 0-Active, 1- Inactive826 },827 {828 toTime: "09 AM",829 fromTime: "10 AM",830 status: 1, // 0-Active, 1- Inactive831 },832 {833 toTime: "10 AM",834 fromTime: "11 AM",835 status: 1, // 0-Active, 1- Inactive836 },837 {838 toTime: "11 AM",839 fromTime: "12 PM",840 status: 1, // 0-Active, 1- Inactive841 },842 {843 toTime: "12 PM",844 fromTime: "01 PM",845 status: 1, // 0-Active, 1- Inactive846 },847 {848 toTime: "01 PM",849 fromTime: "02 PM",850 status: 1, // 0-Active, 1- Inactive851 },852 {853 toTime: "02 PM",854 fromTime: "03 PM",855 status: 1, // 0-Active, 1- Inactive856 },857 {858 toTime: "03 PM",859 fromTime: "04 PM",860 status: 1, // 0-Active, 1- Inactive861 },862 {863 toTime: "04 PM",864 fromTime: "05 PM",865 status: 1, // 0-Active, 1- Inactive866 },867 {868 toTime: "05 PM",869 fromTime: "06 PM",870 status: 1, // 0-Active, 1- Inactive871 },872 {873 toTime: "06 PM",874 fromTime: "07 PM",875 status: 1, // 0-Active, 1- Inactive876 },877 {878 toTime: "07 PM",879 fromTime: "08 PM",880 status: 1, // 0-Active, 1- Inactive881 },882 {883 toTime: "08 PM",884 fromTime: "09 PM",885 status: 1, // 0-Active, 1- Inactive886 },887 {888 toTime: "09 PM",889 fromTime: "10 PM",890 status: 1, // 0-Active, 1- Inactive891 },892 {893 toTime: "10 PM",894 fromTime: "11 PM",895 status: 1, // 0-Active, 1- Inactive896 },897 {898 toTime: "11 PM",899 fromTime: "12 AM",900 status: 1, // 0-Active, 1- Inactive901 },902 {903 toTime: "12 AM",904 fromTime: "01 AM",905 status: 1, // 0-Active, 1- Inactive906 },907 ],908 status: 1, // 0- Active, 1- Inactive909 },910 ];911 try {912 // Get user input913 const {914 firstName,915 lastName,916 email,917 password,918 phone,919 dob,920 experience,921 specialization,922 language,923 gender,924 } = req.body;925 if (926 !req.body.email &&927 !req.body.firstName &&928 !req.body.lastName &&929 !req.body.phone930 ) {931 return res.status(400).send({ message: "Content can not be empty!" });932 }933 console.log("check all data require", req.body);934 // Validate user input935 if (!(email && password && firstName && lastName && phone)) {936 return res.status(400).json("All input is required!");937 }938 //Encrypt user password939 encryptedPassword = await bcrypt.hash(password, 10);940 if (req.body.userType === "admin") {941 // check if user already exist942 const oldUser = await userModel.findOne({ email });943 if (oldUser) {944 return res.status(409).json("User Already Exist. Please Login");945 } else {946 const user = await userModel.create({947 firstName,948 lastName,949 email: email.toLowerCase(), // sanitize: convert email to lowercase950 password: encryptedPassword,951 phone,952 });953 const updatedUser = await userModel.findOneAndUpdate(954 { _id: user._id },955 { $set: { userType: req.body.userType } },956 { new: true }957 );958 res.json({959 message: "User created successfully!!",960 user: updatedUser,961 });962 }963 } else if (req.body.userType === "trainer") {964 //quickblox sesion965 // const getSession = await getQBSessionToken();966 // check if user already exist967 const oldUser = await userModel.findOne({ email });968 if (oldUser) {969 return res.status(409).send("User Already Exist. Please Login");970 } else {971 const user = await userModel.create({972 firstName,973 lastName,974 email: email.toLowerCase(), // sanitize: convert email to lowercase975 password: encryptedPassword,976 phone,977 dob,978 experience,979 specialization,980 trainerAvailabilities: trainerAvailability,981 language,982 gender,983 });984 // let QBarr = [] ;985 // if (getSession) {986 // const QBreg = await createQBUser(getSession, req.body.phone, req.body.email, req.body.userType);987 // // console.log("QBBBBBBRegistration ::::::::::::::: ", QBreg)988 // if(QBreg){989 // QBarr.push(QBreg)990 // }991 // }992 const updatedUser = await userModel.findOneAndUpdate(993 { _id: user._id },994 // { $set: { userType: req.body.userType, quickBloxData: QBarr } },995 { $set: { userType: req.body.userType } },996 { new: true }997 );998 res.send({999 message: "User created successfully!!",1000 user: updatedUser,1001 });1002 // console.log(user,'heloooooooooo')1003 }1004 } else if (req.body.userType === "user") {1005 //quickblox sesion1006 // const getSession = await getQBSessionToken();1007 // check if user already exist1008 const oldUser = await userModel.findOne({ email });1009 if (oldUser) {1010 return res.status(409).send("User Already Exist. Please Login");1011 } else {1012 const user = await userModel.create({1013 firstName,1014 lastName,1015 email: email.toLowerCase(), // sanitize: convert email to lowercase1016 password: encryptedPassword,1017 phone,1018 });1019 // let QBarr = [] ;1020 // if (getSession) {1021 // const QBreg = await createQBUser(getSession, req.body.phone, req.body.email, req.body.userType );1022 // // console.log("QBBBBBBRegistration ::::::::::::::: ", QBreg)1023 // if(QBreg){1024 // QBarr.push(QBreg)1025 // }1026 // }1027 const updatedUser = await userModel.findOneAndUpdate(1028 { _id: user._id },1029 // { $set: { userType: req.body.userType, quickBloxData: QBarr } },1030 { $set: { userType: req.body.userType } },1031 { new: true }1032 );1033 res.send({1034 message: "User created successfully!!",1035 user: updatedUser,1036 });1037 }1038 } else {1039 res.status(500).send({ message: "type is invalid" });1040 }1041 } catch (error) {1042 console.log("error ::: ", error);1043 res.status(500).json({1044 message: error.message || "Some error occurred while creating user",1045 });1046 }1047 },1048 //User Login1049 async login(req, res) {1050 try {1051 //console.log("body", req.body);1052 const user = await userModel.findOne({1053 email: req.body.email,1054 status: 0,1055 });1056 const validPassword = await bcrypt.compare(1057 req.body.password,1058 user.password1059 );1060 if (!validPassword) {1061 return res.status(400).json({ error: "Password is invalid!" });1062 }1063 if (!user) {1064 return res1065 .status(400)1066 .json({ message: "Email & passsword incorrect!" });1067 }1068 const token = await jwt.sign({ id: user._id }, process.env.TOKEN_JWT, {1069 expiresIn: "6000d",1070 });1071 res.setHeader("x-auth-token", token);1072 res1073 .status(200)1074 .send({ message: "user login successfully", user: user, token });1075 } catch (error) {1076 console.log("error ::: ", error);1077 return res1078 .status(500)1079 .send({ error: error.message, message: "something went wrong!" });1080 }1081 },1082 // Get All User1083 async getAllUser(req, res, next) {1084 try {1085 const page = parseInt(req.query.page);1086 const limit = parseInt(req.query.limit);1087 const skipIndex = (page - 1) * limit;1088 const data = {};1089 const typeObje = { userType: req.query.userType };1090 data.data = await userModel1091 .find(typeObje)1092 .sort({ _id: 1 })1093 .limit(limit)1094 .skip(skipIndex)1095 .exec();1096 res.paginateddata = data;1097 const total = await userModel.find(typeObje).count();1098 res1099 .status(200)1100 .send({ message: "data got successfully", data: data, total });1101 next();1102 } catch (err) {1103 console.log("error ::: ", err);1104 return res.status(500).send(err.message);1105 }1106 },1107 // Get User By ID1108 async getUserById(req, res) {1109 try {1110 const userID = await userModel.findById(req.params.id);1111 res.status(200).json({1112 message: "User Record!",1113 data: userID,1114 });1115 } catch (error) {1116 res.status(404).json({ message: error.message });1117 }1118 },1119 // Get User1120 async getUser(req, res) {1121 try {1122 const userID = await userModel.findById(req.auth.id);1123 res.status(200).json({1124 message: "User Record!",1125 data: userID,1126 });1127 } catch (error) {1128 res.status(404).json({ message: error.message });1129 }1130 },1131 //update Users by ID1132 async updateUserById(req, res) {1133 try {1134 let certificationArray = [];1135 if (req.files.certification) {1136 req.files.certification.forEach((imagePath) => {1137 certificationArray.push(imagePath.path);1138 });1139 }1140 const userID = await userModel.findById({ _id: req.params.id });1141 if (!userID) {1142 return res.status(500).json({ error: "User ID is invalid!" });1143 }1144 if (userID.profileImage != null && req.files.profileImage) {1145 fs.unlink("./" + userID.profileImage, function (err) {1146 if (err) throw err;1147 // if no error, file has been deleted successfully1148 console.log("File deleted!");1149 });1150 }1151 if (userID.certification != null && req.files.certification) {1152 userID.certification.forEach((data) => {1153 fs.unlink("./" + data, function (err) {1154 if (err) throw err;1155 // if no error, file has been deleted successfully1156 console.log("File deleted!::::::::::");1157 });1158 });1159 }1160 if (userID.signature != null && req.files.signature) {1161 fs.unlink("./" + userID.signature, function (err) {1162 if (err) throw err;1163 // if no error, file has been deleted successfully1164 console.log("File deleted!");1165 });1166 }1167 const body = req.body;1168 const profile = req.files.profileImage1169 ? req.files.profileImage[0].path1170 : userID.profile;1171 const certificates = req.files.certification1172 ? certificationArray1173 : userID.certification;1174 const sign = req.files.signature1175 ? req.files.signature[0].path1176 : userID.signature;1177 const updatedUser = await userModel.findByIdAndUpdate(1178 { _id: req.params.id },1179 // { $set: bodyData},1180 {1181 $set: {1182 firstName: body.firstName,1183 lastName: body.lastName,1184 phone: body.phone,1185 specialization: body.specialization,1186 experience: body.experience,1187 dob: body.dob,1188 height: body.height,1189 weight: body.weight,1190 about: body.about,1191 city: body.city,1192 zipCode: body.zipCode,1193 country: body.country,1194 categoryTypeTrainer: body.categoryTypeTrainer,1195 profileImage: profile,1196 certification: certificates,1197 signature: sign,1198 },1199 },1200 { new: true }1201 );1202 res.status(200).json({1203 message: "User Records Updated Successfully!",1204 data: updatedUser,1205 });1206 } catch (error) {1207 res.status(500).send(error.message);1208 }1209 },1210 //Update Users1211 async updateUser(req, res) {1212 try {1213 let certificationArray = [];1214 if (req.files.certification) {1215 req.files.certification.forEach((imagePath) => {1216 certificationArray.push(imagePath.path);1217 });1218 }1219 const userID = await userModel.findById(req.auth.id);1220 if (!userID) {1221 return res.status(500).json({ error: "User ID is invalid!" });1222 }1223 if (userID.profileImage != null && req.files.profileImage) {1224 fs.unlink("./" + userID.profileImage, function (err) {1225 if (err) throw err;1226 // if no error, file has been deleted successfully1227 console.log("File deleted!");1228 });1229 }1230 if (userID.certification != null && req.files.certification) {1231 userID.certification.forEach((data) => {1232 fs.unlink("./" + data, function (err) {1233 if (err) throw err;1234 // if no error, file has been deleted successfully1235 console.log("File deleted!::::::::::");1236 });1237 });1238 }1239 if (userID.signature != null && req.files.signature) {1240 fs.unlink("./" + userID.signature, function (err) {1241 if (err) throw err;1242 // if no error, file has been deleted successfully1243 console.log("File deleted!");1244 });1245 }1246 const body = req.body;1247 const profile = req.files.profileImage1248 ? req.files.profileImage[0].path1249 : userID.profile;1250 const certificates = req.files.certification1251 ? certificationArray1252 : userID.certification;1253 const sign = req.files.signature1254 ? req.files.signature[0].path1255 : userID.signature;1256 const updatedUser = await userModel.findByIdAndUpdate(1257 { _id: req.auth.id },1258 {1259 $set: {1260 firstName: body.firstName,1261 lastName: body.lastName,1262 phone: body.phone,1263 specialization: body.specialization,1264 experience: body.experience,1265 dob: body.dob,1266 height: body.height,1267 weight: body.weight,1268 about: body.about,1269 city: body.city,1270 zipCode: body.zipCode,1271 country: body.country,1272 profileImage: profile,1273 certification: certificates,1274 signature: sign,1275 },1276 },1277 { new: true }1278 );1279 res.status(200).json({1280 message: "User Records Updated Successfully!",1281 data: updatedUser,1282 });1283 } catch (error) {1284 res.status(500).send(error.message);1285 }1286 },1287 //Get Users Count By Type1288 async getCountByType(req, res) {1289 try {1290 const typeObje = { userType: req.query.userType };1291 const total = await userModel.find(typeObje).count();1292 res.status(200).send({ message: "Total User Counts!", data: total });1293 } catch (error) {1294 res.status(500).send(error.message);1295 }1296 },1297 //Search User Date1298 async userSearch(req, res) {1299 try {1300 const data = req.params.id;1301 const regex = new RegExp(data, "i");1302 const condition = {1303 $or: [1304 { firstName: { $regex: regex } },1305 { lastName: { $regex: regex } },1306 { phone: { $regex: regex } },1307 { email: { $regex: regex } },1308 { experience: { $regex: regex } },1309 { specialization: { $regex: regex } },1310 { categoryTypeTrainer: { $regex: regex } },1311 ],1312 };1313 const queryData = await userModel.find(condition);1314 if (!queryData) {1315 return res.status(400).send("Error, No Data Found...!");1316 }1317 return res1318 .status(200)1319 .send({ message: "Search Data Got Successfully!", data: queryData });1320 } catch (error) {1321 res.status(500).send(error.message);1322 }1323 },1324 //search by gender and categorytrainer or language1325 async trainerSearch(req, res) {1326 try {1327 // const data = req.params.id;1328 const categoryTrainer = req.query.categoryTrainer;1329 const gender = req.query.gender;1330 const slots = req.query.slots;1331 const language = req.query.language;1332 const cond = {};1333 if (1334 categoryTrainer !== null &&1335 gender !== null &&1336 slots !== null &&1337 language !== null1338 ) {1339 cond.categoryTrainer = categoryTrainer;1340 cond.gender = gender;1341 cond.slots = slots;1342 cond.language = language;1343 }1344 const queryData = await userModel.find(cond);1345 if (!queryData) {1346 return res.status(400).send("Error, No data Found...!");1347 }1348 return res1349 .status(200)1350 .send({ message: "Sesrch Data Got Successfully!", data: queryData });1351 } catch (error) {1352 res.status(500).send(error.message);1353 }1354 },1355 // Update User Status1356 async updateStatus(req, res) {1357 try {1358 const userID = await userModel.findById({ _id: req.params.id });1359 if (!userID) {1360 res.status(404).json({ message: "User ID is not valid!" });1361 }1362 const userStatus = await userModel.findByIdAndUpdate(1363 { _id: req.params.id },1364 { $set: { status: req.body.status } },1365 { new: true }1366 );1367 res.send({1368 message: "User Status Updated Successfully!",1369 data: userStatus,1370 });1371 } catch (error) {1372 res.status(500).send(error.message);1373 }1374 },1375 //update categoryTrainer like basic and stander1376 async updateCategoryTrainer(req, res) {1377 try {1378 const userId = await userModel.findById({ _id: req.params.id });1379 if (!userId) {1380 res.status(404).json({ message: "user Id is not valid" });1381 }1382 const userCategoryTrainer = await userModel.findByIdAndUpdate(1383 { _id: req.params.id },1384 { $set: { categoryTrainer: req.body.categoryTrainer } }, // basic and stander and premium1385 { new: true }1386 );1387 res.send({1388 message: "user Category Trainer update Successfully!",1389 data: userCategoryTrainer,1390 });1391 } catch (error) {1392 res.status(500).send(error.message);1393 }1394 },1395 // Create Fitness Calculator1396 async createCalculator(req, res) {1397 try {1398 let caloriesArray = [];1399 if (req.body.calorieNeeds) {1400 req.body.calorieNeeds.forEach((calory) => {1401 caloriesArray.push(calory);1402 });1403 }1404 const userID = await userModel.findById(req.auth.id);1405 const userCal = userID.fitnessCalcultor;1406 if (!userID) {1407 return res.status(500).send("Id is not valid");1408 }1409 userCal.push({1410 _id: ObjectId(),1411 gender: req.body.gender,1412 age: req.body.age,1413 height: req.body.height,1414 weight: req.body.weight,1415 activity: req.body.activity,1416 neck: req.body.neck,1417 waist: req.body.waist,1418 hip: req.body.hip,1419 goal: req.body.goal,1420 bmi: req.body.bmi,1421 bmr: req.body.bmr,1422 idealBodyWeight: req.body.idealBodyWeight,1423 tdee: req.body.tdee,1424 calorieNeeds: caloriesArray,1425 });1426 const createdCal = await userModel.findOneAndUpdate(1427 { _id: req.auth.id },1428 { $set: { fitnessCalcultor: userCal } },1429 { new: true }1430 );1431 res.send({1432 message: "Fitness Details Added successfully",1433 data: createdCal,1434 });1435 } catch (error) {1436 res.status(500).send(error.message);1437 }1438 },1439 // Update Fitness Calculator1440 async updateCalculator(req, res) {1441 try {1442 let caloriesArray = [];1443 if (req.body.calorieNeeds) {1444 req.body.calorieNeeds.forEach((calory) => {1445 caloriesArray.push(calory);1446 });1447 }1448 // console.log("dddddd::", caloriesArray)1449 const userID = await userModel.findById(req.auth.id);1450 indexId = req.body;1451 const userCal = userID.fitnessCalcultor;1452 const checkIdx = userCal.findIndex(1453 (fitnesId) => fitnesId._id == indexId.fitnesId1454 );1455 // console.log("IDDDD::::::", checkIdx)1456 if (checkIdx != -1) {1457 userCal[checkIdx].gender = indexId.gender;1458 userCal[checkIdx].age = indexId.age;1459 userCal[checkIdx].height = indexId.height;1460 userCal[checkIdx].weight = indexId.weight;1461 userCal[checkIdx].activity = indexId.activity;1462 userCal[checkIdx].neck = indexId.neck;1463 userCal[checkIdx].waist = indexId.waist;1464 userCal[checkIdx].hip = indexId.hip;1465 userCal[checkIdx].goal = indexId.goal;1466 userCal[checkIdx].bmi = indexId.bmi;1467 userCal[checkIdx].bmr = indexId.bmr;1468 userCal[checkIdx].idealBodyWeight = indexId.idealBodyWeight;1469 userCal[checkIdx].tdee = indexId.tdee;1470 userCal[checkIdx].calorieNeeds = caloriesArray;1471 userCal[checkIdx].updatedDate = indexId.updatedDate;1472 }1473 // console.log("ddddddaaaaaaaaaaaatttttt::",userCal )1474 const updatedCal = await userModel.findOneAndUpdate(1475 { _id: req.auth.id },1476 { $set: { fitnessCalcultor: userCal } },1477 { new: true }1478 );1479 res.send({1480 message: "Fitness Details Updated successfully",1481 data: updatedCal,1482 });1483 } catch (error) {1484 res.status(500).send(error.message);1485 }1486 },1487 //admin create a category using get a coach page change( header heading img and paragrph)1488 async createHeaderGetACoachAdmin(req, res) {1489 try {1490 const typeimg = req.files.imageTypeTrainer[0].path;1491 if (1492 !req.body.headingTrainer &&1493 !req.body.paragraphTypeTrainer &&1494 !typeimg &&1495 !req.body.getCoachHeaderCategory1496 ) {1497 return res.status(400).send({ message: "Content can not be empty!" });1498 } else {1499 const createGetACoachHeaderTariner =1500 await coachCategoryHeaderpageModel.create({1501 headingTrainer: req.body.headingTrainer,1502 paragraphTypeTrainer: req.body.paragraphTypeTrainer,1503 imageTypeTrainer: req.files.imageTypeTrainer[0].path,1504 getCoachHeaderCategory: req.body.getCoachHeaderCategory,1505 });1506 res.send({1507 message: "Get a Coach category header created successfully!!",1508 data: createGetACoachHeaderTariner,1509 });1510 }1511 } catch (error) {1512 console.log("error ::: ", error);1513 res.status(500).json({1514 message: error.message || "Some error occurred while creating Coach",1515 });1516 }1517 },1518 // admin get a category All using a get a coach field ( header heading img and paragrph)1519 async getHeaderGetACoachAdmin(req, res, next) {1520 try {1521 const page = parseInt(req.query.page);1522 const limit = parseInt(req.query.limit);1523 const skipIndex = (page - 1) * limit;1524 const data = {};1525 data.data = await coachCategoryHeaderpageModel1526 .find()1527 .sort({ _id: 1 })1528 .limit(limit)1529 .skip(skipIndex)1530 .exec();1531 res.paginateddata = data;1532 const total = await coachCategoryHeaderpageModel.count();1533 res.status(200).send({1534 message: "Category data got successfully!",1535 data: data,1536 total,1537 });1538 next();1539 } catch (err) {1540 console.log("error ::: ", err);1541 return res.status(500).send(err.message);1542 }1543 },1544 // search Category Coach1545 async getHeaderCoachSearch(req, res) {1546 try {1547 const data = req.params.id;1548 const regex = new RegExp(data, "i");1549 const condition = {1550 $or: [1551 { getCoachHeaderCategory: { $regex: regex } },1552 { headingTrainer: { $regex: regex } },1553 { paragraphTypeTrainer: { $regex: regex } },1554 { imageTypeTrainer: { $regex: regex } },1555 ],1556 };1557 const queryData = await coachCategoryHeaderpageModel.find(condition);1558 if (!queryData) {1559 return res.status(400).send("Error, No Data Found...!");1560 }1561 return res1562 .status(200)1563 .send({ message: "Search Data Got Successfully!", data: queryData });1564 } catch (error) {1565 res.status(500).send(error.message);1566 }1567 },1568 // Create Rating1569 async insertRating(req, res) {1570 try {1571 console.log("dddddddddd::::", req.body, req.params.id);1572 const trainerID = await userModel.findById({ _id: req.params.id });1573 if (!trainerID) {1574 res.status(404).json({ message: "Trainer Id is not valid!" });1575 }1576 const rating = await userModel.findByIdAndUpdate(1577 { _id: req.params.id },1578 { $set: { rating: req.body.rating } },1579 { new: true }1580 );1581 res.send({ message: "Rating Submitted Successfully!", data: rating });1582 } catch (error) {1583 res.status(500).send(error.message);1584 }1585 },1586 // Upload Trainer Video1587 async insertTrainerVideoGallary(req, res) {1588 try {1589 const videoPtah = req.file.path;1590 const trainerID = await userModel.findById({ _id: req.params.id });1591 const trainerVidID = trainerID.trainerVideo;1592 if (!trainerID) {1593 return res.status(500).send("Id is not valid");1594 }1595 trainerVidID.push({1596 _id: ObjectId(),1597 vidTitle: req.body.vidTitle,1598 vidDescription: req.body.vidDescription,1599 vidPath: videoPtah,1600 });1601 const insertVideo = await userModel.findByIdAndUpdate(1602 { _id: req.params.id },1603 { $set: { trainerVideo: trainerVidID } },1604 { new: true }1605 );1606 res.send({ message: "Video Uploaded Successfully!", data: insertVideo });1607 } catch (error) {1608 res.status(500).send(error.message);1609 }1610 },1611 //show all video trainer1612 async showVideoTrainer(req, res) {1613 try {1614 const trainerId = await userModel.findById({ _id: req.params.id });1615 res.status(200).json({1616 message: "Video Record Show!",1617 data: trainerId,1618 });1619 } catch (error) {1620 res.status(404).json({ message: error.message });1621 }1622 },1623 // update trainer uploaded videos1624 async updateTrainerVideoGallery(req, res) {1625 try {1626 const trainerID = await userModel.findById(req.auth.id);1627 indexId = req.body;1628 const trainerVideoID = trainerID.trainerVideo;1629 const checkIdx = trainerVideoID.findIndex(1630 (videoID) => videoID._id == indexId.videoID1631 );1632 if (checkIdx != -1) {1633 trainerVideoID[checkIdx].vidTitle = indexId.vidTitle;1634 trainerVideoID[checkIdx].vidDescription = indexId.vidDescription;1635 if (trainerVideoID[checkIdx].vidPath != null) {1636 fs.unlink("./" + trainerVideoID[checkIdx].vidPath, function (err) {1637 if (err) throw err;1638 // if no error, file has been deleted successfully1639 console.log("File deleted!");1640 });1641 }1642 trainerVideoID[checkIdx].vidPath = req.file.path;1643 }1644 const updateTrainerVideo = await userModel.findOneAndUpdate(1645 { _id: req.auth.id },1646 { $set: { trainerVideo: trainerVideoID } },1647 { new: true }1648 );1649 res.send({1650 message: "Video Details Updated successfully",1651 data: updateTrainerVideo,1652 });1653 } catch (error) {1654 res.status(500).send(error, message);1655 }1656 },1657 // Delete Trainer Video1658 async deleteTrainerVideoGallery(req, res) {1659 try {1660 const updateTrainerVideo = await userModel.updateOne(1661 { _id: req.auth.id },1662 { $pull: { trainerVideo: { _id: req.params.id } } },1663 { new: true }1664 );1665 res.send({ message: "Video Details Deleted successfully!" });1666 } catch (error) {1667 res.status(500).send(error.message);1668 }1669 },1670 // Delete admin ==== trainer Video1671 async deleteAdminTrainerVideoGallery(req, res) {1672 try {1673 const updateAdminTrainerVideo = await userModel.updateOne(1674 { _id: req.params.trainerId },1675 { $pull: { trainerVideo: { _id: req.params.id } } },1676 { new: true }1677 );1678 res.send({ message: "Video Details Deleted successfully!" });1679 } catch (error) {1680 res.status(500).send(error.message);1681 }1682 },1683 // Get Trainer Video1684 async getTrainerVideo(req, res) {1685 try {1686 const trainerID = await userModel.findById(req.auth.id);1687 ids = req.params.id;1688 const trainerVideoID = trainerID.trainerVideo;1689 const videoData = trainerVideoID.find((x) => x.id === ids);1690 res1691 .status(200)1692 .send({ message: "Video Get Successfully!", data: videoData });1693 } catch (error) {1694 res.status(500).send(error.message);1695 }1696 },1697 //update Trainer Availability1698 async updateTrainerAvailability(req, res) {1699 try {1700 let slotArray = [];1701 req.body.slots.forEach((slotData) => {1702 slotArray.push(slotData);1703 });1704 const trainerID = await userModel.findOne({ _id: req.params.id });1705 console.log(req.body, "IDDDDDD", trainerID);1706 const indexId = req.body;1707 const trainerAvailabilityDetails = trainerID.trainerAvailabilities;1708 const checkIdx = trainerAvailabilityDetails.findIndex(1709 (availId) => availId._id == indexId.availId1710 );1711 if (checkIdx != -1) {1712 trainerAvailabilityDetails[checkIdx].date = indexId.date;1713 trainerAvailabilityDetails[checkIdx].slots = slotArray;1714 trainerAvailabilityDetails[checkIdx].status = 0;1715 }1716 const updateAvailability = await userModel.findOneAndUpdate(1717 { _id: req.params.id },1718 { $set: { trainerAvailabilities: trainerAvailabilityDetails } },1719 { new: true }1720 );1721 console.log("uuuuuuuuuTTT", updateAvailability);1722 res.send({1723 message: "Trainer Availability has been updated successfully!",1724 data: updateAvailability,1725 });1726 } catch (error) {1727 res.status(500).send(error.message);1728 }1729 },1730 //vacation Trainer add sucessfully go mail for admin1731 async vacationTrainer(req, res) {1732 try {1733 const userID = await userModel.findById(req.auth.id);1734 const userVacation = userID.vacationTrainer;1735 if (!userID) {1736 return res.status(500).send("Id is not valid");1737 }1738 userVacation.push({1739 _id: ObjectId(),1740 startDate: req.body.startDate,1741 endDate: req.body.endDate,1742 reasons: req.body.reasons,1743 });1744 const createdVacation = await userModel.findOneAndUpdate(1745 { _id: req.auth.id },1746 { $set: { vacationTrainer: userVacation } },1747 { new: true }1748 );1749 //make mailable object1750 const transporter = nodemailer.createTransport({1751 service: "gmail",1752 auth: {1753 user: process.env.SMTP_TO_EMAIL,1754 pass: process.env.SMTP_TO_PASSWORD,1755 },1756 });1757 transporter1758 .sendMail({1759 from: "'" + process.env.SMTP_TO_EMAIL + "'", // sender address1760 to: "nitin@softkiwi.co.in", // list of receivers1761 subject:1762 "Vaction Leave for trainer Start Date and End Date ✔ no@reply auto Gen", // Subject line1763 text: `1764 Trainer Name: ${req.body.firstName}-${req.body.lastName}1765 Start Date:1766 ${req.body.startDate}1767 Reasons: ${req.body.reasons} 1768 1769 End Date: ${req.body.endDate}1770 `, // plain text body1771 html: `1772 1773 <h1>From: ${req.body.firstName}-${req.body.lastName}</h1>1774 <p> Email: ${req.body.email}<p>1775 <p>Trainer</p>1776 <p>Date ${req.body.startDate}</p>1777 <hr/>1778 <h1>To,</h1>1779 <h3>Fitezo Admin</h3>1780 <p><b>Subject</b> Application for leave Reasons: ${req.body.reasons} </h3> <p>1781 <hr/>1782 <p>Dear Fitezo Admin</p>,1783 <p>I am writing this letter to inform you that I need leaves for Start Date:1784 ${req.body.startDate}, End Date: ${req.body.endDate}</p><hr/><h3>1785 <p> I will be back End Date: ${req.body.endDate} next day. I was working on at present. I hope you are fine with this, and if required you can reach me any time through mobile.</p>1786 <p>Thanks for considering my leave application and helping me in a tough situation.</p>1787 <p> Thanking You,<p>1788 1789 <p> Yours sincerely,</p>1790 <h4>${req.body.firstName}' ${req.body.lastName}</h4>1791 1792 `, // html body1793 })1794 .then((info) => {1795 console.log({ info });1796 })1797 .catch(console.error);1798 res.status(200).send({1799 message: "Vacation Date Added successfully",1800 data: createdVacation,1801 });1802 } catch (error) {1803 res.status(500).send(error.message);1804 }1805 },1806 //vacation Trainer notifications admin side1807 async VacationNotificationTrainer(req, res) {1808 try {1809 //const userId = await userModel.findById({_id : req.params.id});1810 const trainer = await userModel.find({1811 userType: "trainer",1812 vacationTrainer: { $exists: true, $ne: [] },1813 "vacationTrainer.status": 0,1814 });1815 // console.log('Vactionnn Tainer', trainer.length);1816 res.status(200).json({1817 message: "Vaction Trainer Record!",1818 data: trainer,1819 });1820 } catch (error) {1821 res.status(404).json({ message: error.message });1822 }1823 },1824 //vacation Trainer change status for admin side1825 async VacationNotificationTrainerChange(req, res) {1826 try {1827 // console.log('userid DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD', req.params)1828 const trainerData = await userModel.updateOne(1829 { "vacationTrainer._id": req.params.id },1830 { $set: { "vacationTrainer.$.status": 1 } }1831 );1832 res.status(200).json({1833 message: "Vaction Trainer Status Change Record!",1834 data: trainerData,1835 });1836 } catch (error) {1837 res.status(405).json({ message: error.message });1838 }1839 },1840 //booking Solt and user1841 async BookingSlotByUser(req, res) {1842 //userId trainer Id and customer Id is User ID1843 try {1844 const checkId = await userModel.findById({ _id: req.auth.id });1845 const trainerId = await userModel.findById(req.body.userId);1846 // console.log('Nitinitnitnitnitnitinnticheck customer Id ', req.body.userId);1847 const userBooking = checkId.bookingSlot;1848 const trainerBooking = trainerId.bookingSlot;1849 if (!checkId && trainerId) {1850 return res.status(404).send("Id is not valid");1851 }1852 userBooking.push({1853 _id: ObjectId(),1854 package: req.body.package,1855 slotId: req.body.slotId,1856 userId: req.body.userId,1857 customerId: req.body.customerId,1858 packageSession: req.body.packageSession,1859 fromTime: req.body.fromTime,1860 toTime: req.body.toTime,1861 status: req.body.status,1862 });1863 trainerBooking.push({1864 _id: ObjectId(),1865 package: req.body.package,1866 slotId: req.body.slotId,1867 userId: req.body.userId,1868 customerId: req.body.customerId,1869 packageSession: req.body.packageSession,1870 fromTime: req.body.fromTime,1871 toTime: req.body.toTime,1872 status: req.body.status,1873 });1874 const insertUserBooking = await userModel.findByIdAndUpdate(1875 { _id: req.auth.id },1876 { $set: { bookingSlot: userBooking } },1877 { new: true }1878 );1879 const insertTrainerBooking = await userModel.findByIdAndUpdate(1880 { _id: req.body.userId },1881 { $set: { bookingSlot: trainerBooking } },1882 { new: true }1883 );1884 res.send({1885 message: "booking Slot book Successfully!",1886 data: insertUserBooking,1887 data: insertTrainerBooking,1888 });1889 } catch (error) {1890 res.status(500).send(error.message);1891 }1892 },1893 //status slot change user side1894 async userSlotBooking(req, res) {1895 try {1896 // console.log('juisbdvuidfb',req.params.id, req.body);1897 const trainerID = await userModel.findOne({ _id: req.params.id });1898 const indexId = req.body;1899 const trainerAvailabilityDetails = trainerID.trainerAvailabilities;1900 const checkIdx = trainerAvailabilityDetails.findIndex(1901 //availId slot id1902 (availId) => availId._id == indexId.slotId1903 );1904 if (checkIdx != -1) {1905 const slotIdx = trainerAvailabilityDetails[checkIdx].slots.filter(1906 (idx) =>1907 idx.toTime === indexId.toTime && idx.fromTime === indexId.fromTime1908 );1909 // trainerAvailabilityDetails[checkIdx].status = 2;1910 slotIdx[0].status = 2;1911 for (1912 let index = 0;1913 index < trainerAvailabilityDetails.length;1914 index++1915 ) {1916 const element = trainerAvailabilityDetails[index];1917 const allStatus = element.slots.filter(1918 (idx) =>1919 idx.toTime === indexId.toTime && idx.fromTime === indexId.fromTime1920 );1921 // console.log( allStatus ,"jvbereivbervberibvueruviber")1922 if (allStatus.length > 0) {1923 allStatus[0].status = 2;1924 }1925 // console.log("all status :::::::::::::::::::::::",allStatus);1926 // console.log(slotIdx[0].status ,'SLOT IDX',trainerAvailabilityDetails[checkIdx].slots, trainerAvailabilityDetails);1927 }1928 }1929 const updateAvailability = await userModel.findOneAndUpdate(1930 { _id: req.params.id },1931 { $set: { trainerAvailabilities: trainerAvailabilityDetails } },1932 { new: true }1933 );1934 res.send({1935 message: "User slot book has been updated successfully!",1936 data: updateAvailability,1937 });1938 } catch (error) {1939 res.status(500).send(error.message);1940 }1941 },1942 //Booking Slot And User send trainer1943 async BookingUserShowStariner(req, res) {1944 try {1945 const trainerId = await userModel.findOne({ _id: req.auth.id });1946 const customerId = await userModel.find({ _id: { $in: req.body } });1947 // console.log("customer id ", customerId);1948 if (!trainerId && customerId) {1949 return res.status(404).send("Id is not valid");1950 }1951 res.status(200).json({1952 message: "User Record As Per Request Show!",1953 data: customerId,1954 });1955 } catch (error) {1956 res.status(404).json({ message: error.message });1957 }1958 },1959 //workout Statistic by user add1960 async WorkoutStatistic(req, res) {1961 try {1962 const { running, cycling, yoga } = req.body;1963 if (!req.body.running && !req.body.cycling && !req.body.yoga) {1964 return res.status(400).send({ message: "Content can not be empty!" });1965 }1966 // console.log("check all data require", req.body);1967 // Validate user input1968 if (!(running && cycling && yoga)) {1969 return res.status(400).json("All input is required!");1970 }1971 const checkId = await userModel.findById({ _id: req.auth.id });1972 const userWorkout = checkId.workoutStatistic;1973 if (!checkId) {1974 return res.status(404).send("Id is not valid");1975 }1976 userWorkout.push({1977 _id: ObjectId(),1978 running: req.body.running,1979 cycling: req.body.cycling,1980 yoga: req.body.yoga,1981 workoutDay: moment().format("dddd"),1982 });1983 const workout = await userModel.findByIdAndUpdate(1984 { _id: req.auth.id },1985 { $set: { workoutStatistic: userWorkout } },1986 { new: true }1987 );1988 res.send({1989 message: "workout Statistic Submitted Successfully!",1990 data: workout,1991 });1992 } catch (error) {1993 res.status(500).send(error.message);1994 }1995 },1996 //Dite plan trainer created per user( slot book trainer)1997 async DitePlanUser(req, res) {1998 try {1999 const checkId = await userModel.findById({ _id: req.auth.id }); //auth trainer Id2000 const trainerId = await userModel.findById(req.body.trainerId);2001 const userId = await userModel.findById(req.body.userId);2002 const userDietPlan = userId.workoutDitePlanPerUser;2003 // const userDitePlan = [];2004 if (!checkId && trainerId && userId) {2005 return res.status(404).send("Id is not valid");2006 }2007 if (userId.workoutDitePlanPerUser.dietImage != null && req.files.dietImage) {2008 fs.unlink("./" + userId.workoutDitePlanPerUser.dietImage, function (err) {2009 if (err) throw err;2010 // if no error, file has been deleted successfully2011 console.log("File deleted!");2012 });2013 }2014 const { body } = req;2015 console.log("data check req", req.body);2016 const profile = req.files.dietImage2017 ? req.files.dietImage[0].path2018 : userId.profile;2019 userDietPlan.push({2020 _id: ObjectId(),2021 trainerId: body.trainerId,2022 userId: body.userId,2023 dietHeading: body.dietHeading,2024 dietDescription: body.dietDescription,2025 dietTime: body.dietTime,2026 dietImage: profile,2027 dietType: body.dietType, //weekly, monthly2028 dietMealPlan: body.dietMealPlan, //lunch, dinner, breakfast, snack2029 });2030 const insertUserDitePlan = await userModel.findByIdAndUpdate(2031 { _id: req.body.userId },2032 { $set: { workoutDitePlanPerUser: userDietPlan } },2033 { new: true }2034 );2035 res.send({2036 message: "Dite Plan Submitted Successfully!",2037 data: insertUserDitePlan,2038 });2039 } catch (error) {2040 res.status(500).send(error.message);2041 }2042 },2043 2044};...

Full Screen

Full Screen

campaignads.js

Source:campaignads.js Github

copy

Full Screen

1import React, { Component } from "react";2import store from "store";3import axios from "axios";4import Header from "../Header";5import { Redirect, Link } from "react-router-dom";6import Auth from "../modules/Auth";7import { Tab, Tabs, TabList, TabPanel } from "react-tabs";8import "react-tabs/style/react-tabs.css";9import "react-responsive-modal/styles.css";10import { Modal } from "react-responsive-modal";11class Campaignads extends Component {12 constructor(props) {13 super(props);14 this.state = {15 fields: {16 fromtime_Sunday_1: "01:00",17 totime_Sunday_1: "01:00",18 campaign_link: "",19 open: false,20 monthly_budget: "",21 daily_budget: "",22 display_url: "",23 headline: "",24 bullet1: "",25 bullet2: "",26 bullet3: "",27 bullet4: "",28 bullet5: "",29 campaign_ad_id: "",30 load_spinner: false,31 bid_type: "Fixed",32 delivery_checkbox_Monday: 'Yes',33 delivery_checkbox_Tuesday: 'Yes',34 delivery_checkbox_Wednesday: 'Yes',35 delivery_checkbox_Thursday: 'Yes',36 delivery_checkbox_Friday: 'Yes',37 delivery_checkbox_Saturday: 'Yes',38 delivery_checkbox_Sunday: 'Yes'39 },40 errors: {},41 errorMessage: "",42 status: "",43 status_exist: 1,44 message: "",45 campaignads_results: [],46 selectedFile: null,47 selectedOption: "None",48 Campaign_code:''49 };50 //console.log(this.props.match.params.id);51 this.getbuyeraddleadcampaigndetail();52 this.handleChange = this.handleChange.bind(this);53 this.change = this.change.bind(this);54 this.submituserRegistrationForm = this.submituserRegistrationForm.bind(55 this56 );57 this.onFileChange = this.onFileChange.bind(this);58 this.onValueChange = this.onValueChange.bind(this);59 this.applyValueChange = this.applyValueChange.bind(this);60 this.onValueStateChange = this.onValueStateChange.bind(this);61 this.handleChangeChk = this.handleChangeChk.bind(this);62 }63 handleChangeChk(event) {64 let fields = this.state.fields;65 //alert(fields[event.target.name]);66 fields[event.target.name] = fields[event.target.name] == "No" ? "Yes" : "No";67 this.setState({68 fields,69 });70 }71 onOpenModal = (itemId, base_price, price, label, quality_type) => {72 this.setState({ open: true });73 };74 onCloseModal = () => {75 this.setState({ open: false });76 };77 applyValueChange() {78 let selectedOption = this.state.selectedOption;79 let fields = this.state.fields;80 if (selectedOption == "AllWeekdays") {81 for (var i = 1; i <= 5; i++) {82 var fromtime = fields["fromtime_Monday_" + i];83 var totime = fields["totime_Monday_" + i];84 fields["fromtime_Tuesday_" + i] = fromtime;85 fields["fromtime_Wednesday_" + i] = fromtime;86 fields["fromtime_Thursday_" + i] = fromtime;87 fields["fromtime_Friday_" + i] = fromtime;88 fields["fromtime_Saturday_" + i] = "00:00";89 fields["fromtime_Sunday_" + i] = "00:00";90 fields["totime_Tuesday_" + i] = totime;91 fields["totime_Wednesday_" + i] = totime;92 fields["totime_Thursday_" + i] = totime;93 fields["totime_Friday_" + i] = totime;94 fields["totime_Saturday_" + i] = "00:00";95 fields["totime_Sunday_" + i] = "00:00";96 }97 } else if (selectedOption == "AllDays") {98 for (var i = 1; i <= 5; i++) {99 var fromtime = fields["fromtime_Monday_" + i];100 var totime = fields["totime_Monday_" + i];101 fields["fromtime_Tuesday_" + i] = fromtime;102 fields["fromtime_Wednesday_" + i] = fromtime;103 fields["fromtime_Thursday_" + i] = fromtime;104 fields["fromtime_Friday_" + i] = fromtime;105 fields["fromtime_Saturday_" + i] = fromtime;106 fields["fromtime_Sunday_" + i] = fromtime;107 fields["totime_Tuesday_" + i] = totime;108 fields["totime_Wednesday_" + i] = totime;109 fields["totime_Thursday_" + i] = totime;110 fields["totime_Friday_" + i] = totime;111 fields["totime_Saturday_" + i] = totime;112 fields["totime_Sunday_" + i] = totime;113 }114 } else {115 for (var i = 1; i <= 5; i++) {116 fields["fromtime_Tuesday_" + i] = "00:00";117 fields["fromtime_Wednesday_" + i] = "00:00";118 fields["fromtime_Thursday_" + i] = "00:00";119 fields["fromtime_Friday_" + i] = "00:00";120 fields["fromtime_Saturday_" + i] = "00:00";121 fields["fromtime_Sunday_" + i] = "00:00";122 fields["totime_Tuesday_" + i] = "00:00";123 fields["totime_Wednesday_" + i] = "00:00";124 fields["totime_Thursday_" + i] = "00:00";125 fields["totime_Friday_" + i] = "00:00";126 fields["totime_Saturday_" + i] = "00:00";127 fields["totime_Sunday_" + i] = "00:00";128 }129 }130 this.setState({131 fields,132 });133 }134 onValueChange(event) {135 this.setState({136 selectedOption: event.target.value,137 });138 }139 onValueStateChange(event) {140 let fields = this.state.fields;141 fields[event.target.name] = event.target.value;142 this.setState({143 fields,144 });145 }146 change(e) {147 let fields = this.state.fields;148 fields[e.target.name] = e.target.value;149 this.setState({150 fields,151 });152 }153 renderAlert() {154 if (this.state.errorMessage && this.state.status == "0") {155 return (156 <div className="row">157 <div className="col-md-12">158 <div className="alert alert-danger">159 <strong>!Opps, </strong>160 {this.state.errorMessage}161 </div>162 </div>163 </div>164 );165 } else if (this.state.status == "1") {166 return (167 <div className="row">168 <div className="col-md-12">169 <div className="alert alert-success">170 <strong>Success, </strong>171 {this.state.errorMessage}172 </div>173 </div>174 </div>175 );176 }177 }178 handleChange(e) {179 180 let fields = this.state.fields;181 fields[e.target.name] = e.target.value;182 this.setState({183 fields,184 });185 }186 onFileChange(e) {187 this.setState({ selectedFile: e.target.files[0] });188 }189 getbuyeraddleadcampaigndetail() {190 const headers = {191 "Content-Type": "application/json",192 Authkey: Auth.Authkey(),193 session: Auth.getToken(),194 };195 axios196 .post(197 `${Auth.getapiurl()}/getbuyeraddleadcampaigndetail`,198 {199 buyer_lead_type_id: this.props.match.params.id,200 },201 {202 headers: headers,203 }204 )205 .then((res) => {206 if (res.data.status == 0) {207 208 const fields = res.data.responsedata;209 this.setState({ fields });210 const message = res.data.message;211 this.setState({ message });212 }213 const status = res.data.status;214 this.setState({ status });215 const Campaign_code = res.data.responsedata.Campaign_code;216 this.setState({Campaign_code})217 });218 }219 submituserRegistrationForm(e) {220 e.preventDefault();221 if (this.validateForm()) {222 this.setState({ load_spinner: true });223 const headers = {224 Authkey: Auth.Authkey(),225 session: Auth.getToken(),226 };227 const formData = new FormData();228 if (this.state.selectedFile) {229 formData.append(230 "campaign_logo",231 this.state.selectedFile,232 this.state.selectedFile.name233 );234 }235 formData.set("campaign_link", this.state.fields.campaign_link);236 formData.set("daily_budget", this.state.fields.daily_budget);237 formData.set("monthly_budget", this.state.fields.monthly_budget);238 formData.set("display_url", this.state.fields.display_url);239 formData.set("headline", this.state.fields.headline);240 formData.set("bullet1", this.state.fields.bullet1);241 formData.set("bullet2", this.state.fields.bullet2);242 formData.set("bullet3", this.state.fields.bullet3);243 formData.set("bullet4", this.state.fields.bullet4);244 formData.set("bullet5", this.state.fields.bullet5);245 formData.set("campaign_ad_id", this.state.fields.campaign_ad_id);246 formData.set("buyer_lead_type_id", this.props.match.params.id);247 formData.set("bid_type", this.state.fields.bid_type);248 //Sunday from - to time249 formData.set("fromtime_Sunday_1", this.state.fields.fromtime_Sunday_1);250 formData.set("totime_Sunday_1", this.state.fields.totime_Sunday_1);251 formData.set("fromtime_Sunday_2", this.state.fields.fromtime_Sunday_2);252 formData.set("totime_Sunday_2", this.state.fields.totime_Sunday_2);253 formData.set("fromtime_Sunday_3", this.state.fields.fromtime_Sunday_3);254 formData.set("totime_Sunday_3", this.state.fields.totime_Sunday_3);255 formData.set("fromtime_Sunday_4", this.state.fields.fromtime_Sunday_4);256 formData.set("totime_Sunday_4", this.state.fields.totime_Sunday_4);257 formData.set("fromtime_Sunday_5", this.state.fields.fromtime_Sunday_5);258 formData.set("totime_Sunday_5", this.state.fields.totime_Sunday_5);259 //Monday from - to time260 formData.set("fromtime_Monday_1", this.state.fields.fromtime_Monday_1);261 formData.set("totime_Monday_1", this.state.fields.totime_Monday_1);262 formData.set("fromtime_Monday_2", this.state.fields.fromtime_Monday_2);263 formData.set("totime_Monday_2", this.state.fields.totime_Monday_2);264 formData.set("fromtime_Monday_3", this.state.fields.fromtime_Monday_3);265 formData.set("totime_Monday_3", this.state.fields.totime_Monday_3);266 formData.set("fromtime_Monday_4", this.state.fields.fromtime_Monday_4);267 formData.set("totime_Monday_4", this.state.fields.totime_Monday_4);268 formData.set("fromtime_Monday_5", this.state.fields.fromtime_Monday_5);269 formData.set("totime_Monday_5", this.state.fields.totime_Monday_5);270 //Tuesday from - to time271 formData.set("fromtime_Tuesday_1", this.state.fields.fromtime_Tuesday_1);272 formData.set("totime_Tuesday_1", this.state.fields.totime_Tuesday_1);273 formData.set("fromtime_Tuesday_2", this.state.fields.fromtime_Tuesday_2);274 formData.set("totime_Tuesday_2", this.state.fields.totime_Tuesday_2);275 formData.set("fromtime_Tuesday_3", this.state.fields.fromtime_Tuesday_3);276 formData.set("totime_Tuesday_3", this.state.fields.totime_Tuesday_3);277 formData.set("fromtime_Tuesday_4", this.state.fields.fromtime_Tuesday_4);278 formData.set("totime_Tuesday_4", this.state.fields.totime_Tuesday_4);279 formData.set("fromtime_Tuesday_5", this.state.fields.fromtime_Tuesday_5);280 formData.set("totime_Tuesday_5", this.state.fields.totime_Tuesday_5);281 //Wednesday from - to time282 formData.set(283 "fromtime_Wednesday_1",284 this.state.fields.fromtime_Wednesday_1285 );286 formData.set("totime_Wednesday_1", this.state.fields.totime_Wednesday_1);287 formData.set(288 "fromtime_Wednesday_2",289 this.state.fields.fromtime_Wednesday_2290 );291 formData.set("totime_Wednesday_2", this.state.fields.totime_Wednesday_2);292 formData.set(293 "fromtime_Wednesday_3",294 this.state.fields.fromtime_Wednesday_3295 );296 formData.set("totime_Wednesday_3", this.state.fields.totime_Wednesday_3);297 formData.set(298 "fromtime_Wednesday_4",299 this.state.fields.fromtime_Wednesday_4300 );301 formData.set("totime_Wednesday_4", this.state.fields.totime_Wednesday_4);302 formData.set(303 "fromtime_Wednesday_5",304 this.state.fields.fromtime_Wednesday_5305 );306 formData.set("totime_Wednesday_5", this.state.fields.totime_Wednesday_5);307 //Thursday from - to time308 formData.set(309 "fromtime_Thursday_1",310 this.state.fields.fromtime_Thursday_1311 );312 formData.set("totime_Thursday_1", this.state.fields.totime_Thursday_1);313 formData.set(314 "fromtime_Thursday_2",315 this.state.fields.fromtime_Thursday_2316 );317 formData.set("totime_Thursday_2", this.state.fields.totime_Thursday_2);318 formData.set(319 "fromtime_Thursday_3",320 this.state.fields.fromtime_Thursday_3321 );322 formData.set("totime_Thursday_3", this.state.fields.totime_Thursday_3);323 formData.set(324 "fromtime_Thursday_4",325 this.state.fields.fromtime_Thursday_4326 );327 formData.set("totime_Thursday_4", this.state.fields.totime_Thursday_4);328 formData.set(329 "fromtime_Thursday_5",330 this.state.fields.fromtime_Thursday_5331 );332 formData.set("totime_Thursday_5", this.state.fields.totime_Thursday_5);333 //Friday from - to time334 formData.set("fromtime_Friday_1", this.state.fields.fromtime_Friday_1);335 formData.set("totime_Friday_1", this.state.fields.totime_Friday_1);336 formData.set("fromtime_Friday_2", this.state.fields.fromtime_Friday_2);337 formData.set("totime_Friday_2", this.state.fields.totime_Friday_2);338 formData.set("fromtime_Friday_3", this.state.fields.fromtime_Friday_3);339 formData.set("totime_Friday_3", this.state.fields.totime_Friday_3);340 formData.set("fromtime_Friday_4", this.state.fields.fromtime_Friday_4);341 formData.set("totime_Friday_4", this.state.fields.totime_Friday_4);342 formData.set("fromtime_Friday_5", this.state.fields.fromtime_Friday_5);343 formData.set("totime_Friday_5", this.state.fields.totime_Friday_5);344 //Saturday from - to time345 formData.set(346 "fromtime_Saturday_1",347 this.state.fields.fromtime_Saturday_1348 );349 formData.set("totime_Saturday_1", this.state.fields.totime_Saturday_1);350 formData.set(351 "fromtime_Saturday_2",352 this.state.fields.fromtime_Saturday_2353 );354 formData.set("totime_Saturday_2", this.state.fields.totime_Saturday_2);355 formData.set(356 "fromtime_Saturday_3",357 this.state.fields.fromtime_Saturday_3358 );359 formData.set("totime_Saturday_3", this.state.fields.totime_Saturday_3);360 formData.set(361 "fromtime_Saturday_4",362 this.state.fields.fromtime_Saturday_4363 );364 formData.set("totime_Saturday_4", this.state.fields.totime_Saturday_4);365 formData.set(366 "fromtime_Saturday_5",367 this.state.fields.fromtime_Saturday_5368 );369 formData.set("totime_Saturday_5", this.state.fields.totime_Saturday_5);370 formData.set("delivery_checkbox_Monday", this.state.fields.delivery_checkbox_Monday);371 formData.set("delivery_checkbox_Tuesday", this.state.fields.delivery_checkbox_Tuesday);372 formData.set("delivery_checkbox_Wednesday", this.state.fields.delivery_checkbox_Wednesday);373 formData.set("delivery_checkbox_Thursday", this.state.fields.delivery_checkbox_Thursday);374 formData.set("delivery_checkbox_Friday", this.state.fields.delivery_checkbox_Friday);375 formData.set("delivery_checkbox_Saturday", this.state.fields.delivery_checkbox_Saturday);376 formData.set("delivery_checkbox_Sunday", this.state.fields.delivery_checkbox_Sunday);377 axios378 .post(`${Auth.getapiurl()}/buyerAddupdateleadcampaign`, formData, {379 headers: headers,380 })381 .then((res) => {382 this.setState({383 errorMessage: res.data.message,384 status: res.data.status,385 });386 this.setState({ load_spinner: false });387 if (res.data.status == 1) {388 Auth.toastmsg(res.data.message, "S");389 } else {390 Auth.toastmsg(res.data.message, "E");391 }392 this.props.history.push("/campaign");393 });394 }395 }396 validateForm() {397 let fields = this.state.fields;398 let errors = {};399 let formIsValid = true;400 if (!fields["campaign_link"]) {401 formIsValid = false;402 errors["campaign_link"] = "*Please Fill campaign Link.";403 }404 if (!fields["daily_budget"]) {405 formIsValid = false;406 errors["daily_budget"] = "*Please Fill Daily Budget.";407 }408 if (!fields["monthly_budget"]) {409 formIsValid = false;410 errors["monthly_budget"] = "*Please Fill Monthly Budget.";411 }412 if (!fields["display_url"]) {413 formIsValid = false;414 errors["display_url"] = "*Please Fill Display URL.";415 }416 if (!fields["headline"]) {417 formIsValid = false;418 errors["headline"] = "*Please Fill Headline.";419 }420 if (!fields["bullet1"]) {421 formIsValid = false;422 errors["bullet1"] = "*Please Fill Bullet 1.";423 }424 if (!fields["bullet2"]) {425 formIsValid = false;426 errors["bullet2"] = "*Please Fill Bullet 2.";427 }428 if (!fields["bullet3"]) {429 formIsValid = false;430 errors["bullet3"] = "*Please Fill Bullet 3.";431 }432 this.setState({433 errors: errors,434 });435 return formIsValid;436 }437 render() {438 const { open } = this.state;439 const fields = this.state.fields;440 // console.log(this.state.fields);441 if (!Auth.getToken()) {442 return <Redirect to="/login" />;443 }444 var week = new Array(445 "Monday",446 "Tuesday",447 "Wednesday",448 "Thursday",449 "Friday",450 "Saturday",451 "Sunday"452 );453 var weekdays = new Array("1", "2", "3", "4", "5");454 var hoursarray = new Array(455 "00:00",456 "01:00",457 "01:30",458 "02:00",459 "02:30",460 "03:00",461 "03:30",462 "04:00",463 "04:30",464 "05:00",465 "05:30",466 "06:00",467 "06:30",468 "07:00",469 "07:30",470 "08:00",471 "08:30",472 "09:00",473 "09:30",474 "10:00",475 "10:30",476 "11:00",477 "11:30",478 "12:00",479 "12:30",480 "13:00",481 "13:30",482 "14:00",483 "14:30",484 "15:00",485 "15:30",486 "16:00",487 "16:30",488 "17:00",489 "17:30",490 "18:00",491 "18:30",492 "19:00",493 "19:30",494 "20:00",495 "20:30",496 "21:00",497 "21:30",498 "22:00",499 "22:30",500 "23:00",501 "23:30"502 );503 let tab_week;504 tab_week = week.map((item, i) => <Tab key={i}>{week[i]}</Tab>);505 var sundayData = weekdays.map((timevalue, i) => {506 var sunday_value = "";507 var sunday_to_value = "";508 if (i + 1 == 1) {509 sunday_value = this.state.fields.fromtime_Sunday_1;510 sunday_to_value = this.state.fields.totime_Sunday_1;511 } else if (i + 1 == 2) {512 sunday_value = this.state.fields.fromtime_Sunday_2;513 sunday_to_value = this.state.fields.totime_Sunday_2;514 } else if (i + 1 == 3) {515 sunday_value = this.state.fields.fromtime_Sunday_3;516 sunday_to_value = this.state.fields.totime_Sunday_3;517 } else if (i + 1 == 4) {518 sunday_value = this.state.fields.fromtime_Sunday_4;519 sunday_to_value = this.state.fields.totime_Sunday_4;520 } else if (i + 1 == 5) {521 sunday_value = this.state.fields.fromtime_Sunday_5;522 sunday_to_value = this.state.fields.totime_Sunday_5;523 }524 return (525 <div className="form-group">526 <label className="col-sm-2 control-label">from : </label>527 <div className="col-sm-4">528 <select529 className="form-control"530 onChange={this.change}531 name={"fromtime_Sunday_" + (i + 1)}532 >533 {hoursarray.map((value) => (534 <option535 key={value}536 value={value}537 selected={sunday_value == value}538 >539 {value}540 </option>541 ))}542 </select>543 </div>544 <label className="col-sm-2 control-label">To : </label>545 <div className="col-sm-4">546 <select547 className="form-control"548 onChange={this.change}549 name={"totime_Sunday_" + (i + 1)}550 >551 {hoursarray.map((value) => (552 <option553 key={value}554 value={value}555 selected={sunday_to_value == value}556 >557 {value}558 </option>559 ))}560 </select>561 </div>562 </div>563 );564 });565 var mondayData = weekdays.map((timevalue, i) => {566 var day_value = "";567 var day_to_value = "";568 if (i + 1 == 1) {569 day_value = this.state.fields.fromtime_Monday_1;570 day_to_value = this.state.fields.totime_Monday_1;571 } else if (i + 1 == 2) {572 day_value = this.state.fields.fromtime_Monday_2;573 day_to_value = this.state.fields.totime_Monday_2;574 } else if (i + 1 == 3) {575 day_value = this.state.fields.fromtime_Monday_3;576 day_to_value = this.state.fields.totime_Monday_3;577 } else if (i + 1 == 4) {578 day_value = this.state.fields.fromtime_Monday_4;579 day_to_value = this.state.fields.totime_Monday_4;580 } else if (i + 1 == 5) {581 day_value = this.state.fields.fromtime_Monday_5;582 day_to_value = this.state.fields.totime_Monday_5;583 }584 return (585 <div className="form-group">586 <label className="col-sm-2 control-label">from : </label>587 <div className="col-sm-4">588 <select589 className="form-control"590 onChange={this.change}591 name={"fromtime_Monday_" + (i + 1)}592 >593 {hoursarray.map((value) => (594 <option key={value} value={value} selected={day_value == value}>595 {value}596 </option>597 ))}598 </select>599 </div>600 <label className="col-sm-2 control-label">To : </label>601 <div className="col-sm-4">602 <select603 className="form-control"604 onChange={this.change}605 name={"totime_Monday_" + (i + 1)}606 >607 {hoursarray.map((value) => (608 <option609 key={value}610 value={value}611 selected={day_to_value == value}612 >613 {value}614 </option>615 ))}616 </select>617 </div>618 </div>619 );620 });621 var tuesdayData = weekdays.map((timevalue, i) => {622 var day_value = "";623 var day_to_value = "";624 if (i + 1 == 1) {625 day_value = this.state.fields.fromtime_Tuesday_1;626 day_to_value = this.state.fields.totime_Tuesday_1;627 } else if (i + 1 == 2) {628 day_value = this.state.fields.fromtime_Tuesday_2;629 day_to_value = this.state.fields.totime_Tuesday_2;630 } else if (i + 1 == 3) {631 day_value = this.state.fields.fromtime_Tuesday_3;632 day_to_value = this.state.fields.totime_Tuesday_3;633 } else if (i + 1 == 4) {634 day_value = this.state.fields.fromtime_Tuesday_4;635 day_to_value = this.state.fields.totime_Tuesday_4;636 } else if (i + 1 == 5) {637 day_value = this.state.fields.fromtime_Tuesday_5;638 day_to_value = this.state.fields.totime_Tuesday_5;639 }640 return (641 <div className="form-group">642 <label className="col-sm-2 control-label">from : </label>643 <div className="col-sm-4">644 <select645 className="form-control"646 onChange={this.change}647 name={"fromtime_Tuesday_" + (i + 1)}648 >649 {hoursarray.map((value) => (650 <option key={value} value={value} selected={day_value == value}>651 {value}652 </option>653 ))}654 </select>655 </div>656 <label className="col-sm-2 control-label">To : </label>657 <div className="col-sm-4">658 <select659 className="form-control"660 onChange={this.change}661 name={"totime_Tuesday_" + (i + 1)}662 >663 {hoursarray.map((value) => (664 <option665 key={value}666 value={value}667 selected={day_to_value == value}668 >669 {value}670 </option>671 ))}672 </select>673 </div>674 </div>675 );676 });677 var wednesdayData = weekdays.map((timevalue, i) => {678 var day_value = "";679 var day_to_value = "";680 if (i + 1 == 1) {681 day_value = this.state.fields.fromtime_Wednesday_1;682 day_to_value = this.state.fields.totime_Wednesday_1;683 } else if (i + 1 == 2) {684 day_value = this.state.fields.fromtime_Wednesday_2;685 day_to_value = this.state.fields.totime_Wednesday_2;686 } else if (i + 1 == 3) {687 day_value = this.state.fields.fromtime_Wednesday_3;688 day_to_value = this.state.fields.totime_Wednesday_3;689 } else if (i + 1 == 4) {690 day_value = this.state.fields.fromtime_Wednesday_4;691 day_to_value = this.state.fields.totime_Wednesday_4;692 } else if (i + 1 == 5) {693 day_value = this.state.fields.fromtime_Wednesday_5;694 day_to_value = this.state.fields.totime_Wednesday_5;695 }696 return (697 <div className="form-group">698 <label className="col-sm-2 control-label">from : </label>699 <div className="col-sm-4">700 <select701 className="form-control"702 onChange={this.change}703 name={"fromtime_Wednesday_" + (i + 1)}704 >705 {hoursarray.map((value) => (706 <option key={value} value={value} selected={day_value == value}>707 {value}708 </option>709 ))}710 </select>711 </div>712 <label className="col-sm-2 control-label">To : </label>713 <div className="col-sm-4">714 <select715 className="form-control"716 onChange={this.change}717 name={"totime_Wednesday_" + (i + 1)}718 >719 {hoursarray.map((value) => (720 <option721 key={value}722 value={value}723 selected={day_to_value == value}724 >725 {value}726 </option>727 ))}728 </select>729 </div>730 </div>731 );732 });733 var thursdayData = weekdays.map((timevalue, i) => {734 var day_value = "";735 var day_to_value = "";736 if (i + 1 == 1) {737 day_value = this.state.fields.fromtime_Thursday_1;738 day_to_value = this.state.fields.totime_Thursday_1;739 } else if (i + 1 == 2) {740 day_value = this.state.fields.fromtime_Thursday_2;741 day_to_value = this.state.fields.totime_Thursday_2;742 } else if (i + 1 == 3) {743 day_value = this.state.fields.fromtime_Thursday_3;744 day_to_value = this.state.fields.totime_Thursday_3;745 } else if (i + 1 == 4) {746 day_value = this.state.fields.fromtime_Thursday_4;747 day_to_value = this.state.fields.totime_Thursday_4;748 } else if (i + 1 == 5) {749 day_value = this.state.fields.fromtime_Thursday_5;750 day_to_value = this.state.fields.totime_Thursday_5;751 }752 return (753 <div className="form-group">754 <label className="col-sm-2 control-label">from : </label>755 <div className="col-sm-4">756 <select757 className="form-control"758 onChange={this.change}759 name={"fromtime_Thursday_" + (i + 1)}760 >761 {hoursarray.map((value) => (762 <option key={value} value={value} selected={day_value == value}>763 {value}764 </option>765 ))}766 </select>767 </div>768 <label className="col-sm-2 control-label">To : </label>769 <div className="col-sm-4">770 <select771 className="form-control"772 onChange={this.change}773 name={"totime_Thursday_" + (i + 1)}774 >775 {hoursarray.map((value) => (776 <option777 key={value}778 value={value}779 selected={day_to_value == value}780 >781 {value}782 </option>783 ))}784 </select>785 </div>786 </div>787 );788 });789 var fridayData = weekdays.map((timevalue, i) => {790 var day_value = "";791 var day_to_value = "";792 if (i + 1 == 1) {793 day_value = this.state.fields.fromtime_Friday_1;794 day_to_value = this.state.fields.totime_Friday_1;795 } else if (i + 1 == 2) {796 day_value = this.state.fields.fromtime_Friday_2;797 day_to_value = this.state.fields.totime_Friday_2;798 } else if (i + 1 == 3) {799 day_value = this.state.fields.fromtime_Friday_3;800 day_to_value = this.state.fields.totime_Friday_3;801 } else if (i + 1 == 4) {802 day_value = this.state.fields.fromtime_Friday_4;803 day_to_value = this.state.fields.totime_Friday_4;804 } else if (i + 1 == 5) {805 day_value = this.state.fields.fromtime_Friday_5;806 day_to_value = this.state.fields.totime_Friday_5;807 }808 return (809 <div className="form-group">810 <label className="col-sm-2 control-label">from : </label>811 <div className="col-sm-4">812 <select813 className="form-control"814 onChange={this.change}815 name={"fromtime_Friday_" + (i + 1)}816 >817 {hoursarray.map((value) => (818 <option key={value} value={value} selected={day_value == value}>819 {value}820 </option>821 ))}822 </select>823 </div>824 <label className="col-sm-2 control-label">To : </label>825 <div className="col-sm-4">826 <select827 className="form-control"828 onChange={this.change}829 name={"totime_Friday_" + (i + 1)}830 >831 {hoursarray.map((value) => (832 <option833 key={value}834 value={value}835 selected={day_to_value == value}836 >837 {value}838 </option>839 ))}840 </select>841 </div>842 </div>843 );844 });845 var saturdayData = weekdays.map((timevalue, i) => {846 var day_value = "";847 var day_to_value = "";848 if (i + 1 == 1) {849 day_value = this.state.fields.fromtime_Saturday_1;850 day_to_value = this.state.fields.totime_Saturday_1;851 } else if (i + 1 == 2) {852 day_value = this.state.fields.fromtime_Saturday_2;853 day_to_value = this.state.fields.totime_Saturday_2;854 } else if (i + 1 == 3) {855 day_value = this.state.fields.fromtime_Saturday_3;856 day_to_value = this.state.fields.totime_Saturday_3;857 } else if (i + 1 == 4) {858 day_value = this.state.fields.fromtime_Saturday_4;859 day_to_value = this.state.fields.totime_Saturday_4;860 } else if (i + 1 == 5) {861 day_value = this.state.fields.fromtime_Saturday_5;862 day_to_value = this.state.fields.totime_Saturday_5;863 }864 return (865 <div className="form-group">866 <label className="col-sm-2 control-label">from : </label>867 <div className="col-sm-4">868 <select869 className="form-control"870 onChange={this.change}871 name={"fromtime_Saturday_" + (i + 1)}872 >873 {hoursarray.map((value) => (874 <option key={value} value={value} selected={day_value == value}>875 {value}876 </option>877 ))}878 </select>879 </div>880 <label className="col-sm-2 control-label">To : </label>881 <div className="col-sm-4">882 <select883 className="form-control"884 onChange={this.change}885 name={"totime_Saturday_" + (i + 1)}886 >887 {hoursarray.map((value) => (888 <option889 key={value}890 value={value}891 selected={day_to_value == value}892 >893 {value}894 </option>895 ))}896 </select>897 </div>898 </div>899 );900 });901 return (902 <div>903 <div>904 <Header />905 </div>906 <div className="content-wrapper">907 <section className="content">908 <div className="row">909 <div className="col-md-12 text-center"></div>910 <div className="col-md-12">911 <div className="box box-info">912 <div className="box-header with-border">913 <h3 className="box-title">Campaign Details</h3>914 <div class="pull-right">915 <h2 className="box-title">[ Campaign : {this.state.Campaign_code} ]</h2>916 {this.state.status == 0 ? (917 <span918 className="btn btn-primary btn-lg"919 onClick={() => this.onOpenModal()}920 >921 Preview922 </span>923 ) : (924 ""925 )}926 </div>927 </div>928 <form929 className="has-validation-callback"930 onSubmit={this.submituserRegistrationForm}931 >932 <div className="box-body">933 <div className="row">934 <div className="col-md-6">935 <div className="form-group">936 <label className="control-label">937 Campaign Tracking Link :{" "}938 <span className="red">*</span>939 </label>940 <input941 className="form-control"942 placeholder="Campaign Tracking Link"943 defaultValue={this.state.fields.campaign_link}944 onChange={this.handleChange}945 onKeyUp={this.handleChange}946 name="campaign_link"947 type="text"948 />949 <div className="errorMsg">950 {this.state.errors.campaign_link}951 </div>952 </div>953 </div>954 <div className="col-md-4">955 <div className="form-group">956 <label className="control-label">957 Campaign Logo :{" "}958 <span className="red">* (Size : 110 * 55)</span>959 </label>960 <input961 className="form-control"962 placeholder="Campaign Logo"963 defaultValue={this.state.fields.campaign_logo}964 onChange={this.onFileChange}965 name="campaign_logo"966 type="file"967 />968 <div className="errorMsg">969 {this.state.errors.campaign_logo}970 </div>971 </div>972 </div>973 <div className="col-md-2">974 <div className="form-group">975 {this.state.fields.campaign_logo ? (976 <img977 src={Auth.imageCheck(978 this.state.fields.campaign_logo979 )}980 height="100px"981 className="img-responsive"982 />983 ) : (984 ""985 )}986 </div>987 </div>988 </div>989 <div className="row">990 <div className="col-md-6">991 <div className="form-group">992 <label className="control-label">993 Daily Budget : <span className="red">*</span>994 </label>995 <input996 className="form-control"997 placeholder="Daily Budget"998 defaultValue={this.state.fields.daily_budget}999 onChange={this.handleChange}1000 onKeyUp={this.handleChange}1001 name="daily_budget"1002 type="text"1003 />1004 <div className="errorMsg">1005 {this.state.errors.daily_budget}1006 </div>1007 </div>1008 </div>1009 <div className="col-md-6">1010 <div className="form-group">1011 <label className="control-label">1012 Monthly Budget : <span className="red">*</span>1013 </label>1014 <input1015 className="form-control"1016 placeholder="Monthly Budget"1017 defaultValue={this.state.fields.monthly_budget}1018 onChange={this.handleChange}1019 onKeyUp={this.handleChange}1020 name="monthly_budget"1021 type="text"1022 />1023 <div className="errorMsg">1024 {this.state.errors.monthly_budget}1025 </div>1026 </div>1027 </div>1028 </div>1029 <div className="row">1030 <div className="col-md-6">1031 <div className="form-group">1032 <label className="control-label">1033 Display Url : <span className="red">*</span>1034 </label>1035 <input1036 className="form-control"1037 placeholder="Display Url"1038 defaultValue={this.state.fields.display_url}1039 onChange={this.handleChange}1040 onKeyUp={this.handleChange}1041 name="display_url"1042 type="text"1043 />1044 <div className="errorMsg">1045 {this.state.errors.display_url}1046 </div>1047 </div>1048 </div>1049 <div className="col-md-6">1050 <div className="form-group">1051 <label className="control-label">1052 Headline : <span className="red">*</span>1053 </label>1054 <input1055 className="form-control"1056 placeholder="Headline"1057 defaultValue={this.state.fields.headline}1058 onChange={this.handleChange}1059 onKeyUp={this.handleChange}1060 name="headline"1061 type="text"1062 />1063 <div className="errorMsg">1064 {this.state.errors.headline}1065 </div>1066 </div>1067 </div>1068 </div>1069 <div className="row">1070 <div className="col-md-6">1071 <div className="form-group">1072 <label className="control-label">1073 Bullet 1 : <span className="red">*</span>1074 </label>1075 <input1076 className="form-control"1077 placeholder="Bullet 1"1078 defaultValue={this.state.fields.bullet1}1079 onChange={this.handleChange}1080 onKeyUp={this.handleChange}1081 name="bullet1"1082 type="text"1083 />1084 <div className="errorMsg">1085 {this.state.errors.bullet1}1086 </div>1087 </div>1088 </div>1089 <div className="col-md-6">1090 <div className="form-group">1091 <label className="control-label">1092 Bullet 2 : <span className="red">*</span>1093 </label>1094 <input1095 className="form-control"1096 placeholder="Bullet 2"1097 defaultValue={this.state.fields.bullet2}1098 onChange={this.handleChange}1099 onKeyUp={this.handleChange}1100 name="bullet2"1101 type="text"1102 />1103 <div className="errorMsg">1104 {this.state.errors.bullet2}1105 </div>1106 </div>1107 </div>1108 </div>1109 <div className="row">1110 <div className="col-md-6">1111 <div className="form-group">1112 <label className="control-label">1113 Bullet 3 : <span className="red">*</span>1114 </label>1115 <input1116 className="form-control"1117 placeholder="Bullet 3"1118 defaultValue={this.state.fields.bullet3}1119 onChange={this.handleChange}1120 onKeyUp={this.handleChange}1121 name="bullet3"1122 type="text"1123 />1124 <div className="errorMsg">1125 {this.state.errors.bullet3}1126 </div>1127 </div>1128 </div>1129 <div className="col-md-6">1130 <div className="form-group">1131 <label className="control-label">Bullet 4 : </label>1132 <input1133 className="form-control"1134 placeholder="Bullet 4"1135 defaultValue={this.state.fields.bullet4}1136 onKeyUp={this.handleChange}1137 onChange={this.handleChange}1138 1139 name="bullet4"1140 type="text"1141 />1142 <div className="errorMsg">1143 {this.state.errors.bullet4}1144 </div>1145 </div>1146 </div>1147 </div>1148 <div className="row">1149 <div className="col-md-6">1150 <div className="form-group">1151 <label className="control-label">Bullet 5 :</label>1152 <input1153 className="form-control"1154 placeholder="Bullet 5"1155 defaultValue={this.state.fields.bullet5}1156 onChange={this.handleChange}1157 onKeyUp={this.handleChange}1158 name="bullet5"1159 type="text"1160 />1161 <div className="errorMsg">1162 {this.state.errors.bullet5}1163 </div>1164 </div>1165 </div>1166 <div className="col-md-6">1167 <div className="form-group">1168 <label className="control-label">Bid Type :</label>1169 <div className="radio">1170 <label>1171 <input1172 type="radio"1173 name="bid_type"1174 value="Fixed"1175 checked={1176 this.state.fields.bid_type === "Fixed"1177 }1178 onChange={this.onValueStateChange}1179 />1180 Fixed1181 </label>1182 </div>1183 <div className="radio">1184 <label>1185 <input1186 type="radio"1187 name="bid_type"1188 value="Dynamic"1189 checked={1190 this.state.fields.bid_type === "Dynamic"1191 }1192 onChange={this.onValueStateChange}1193 />1194 Dynamic1195 </label>1196 </div>1197 </div>1198 </div>1199 </div>1200 <div className="row">1201 <div className="col-md-12">1202 <p>1203 <label className="text-danger">1204 Dynamic Variables available currently: {"{StateName} , {ZipCode}"}1205 </label>1206 </p>1207 <p>1208 <label className="text-danger">1209 Allowed in : Headline ,Bullet-1 ,Bullet-2 ,Bullet-3 ,Bullet-4 ,Bullet-5.1210 </label>1211 </p>1212 <p>1213 <label className="text-danger">1214 Example : Insurance Plans in {"{StateName}"} from [site.net].1215 </label>1216 </p>1217 <p>1218 <label className="text-danger">1219 Like : Insurance Plans in California from [site.net].1220 </label>1221 </p>1222 </div>1223 </div>1224 <div className="col-md-12 alert alert-info">1225 <strong>Time of Day Detail <span class="pull-right">( Note : All times are EST )</span></strong>1226 </div>1227 <div className="col-md-12">1228 <Tabs>1229 <TabList>{tab_week}</TabList>1230 <TabPanel>1231 <div className="col-md-9">{mondayData}</div>1232 <div className="col-md-3">1233 <div class="panel panel-default">1234 <div class="panel-body">1235 <div className="radio">1236 <label>1237 <input1238 type="radio"1239 value="AllWeekdays"1240 checked={1241 this.state.selectedOption ===1242 "AllWeekdays"1243 }1244 onChange={this.onValueChange}1245 />1246 Copy to All Weekdays1247 </label>1248 </div>1249 <div className="radio">1250 <label>1251 <input1252 type="radio"1253 value="AllDays"1254 checked={1255 this.state.selectedOption ===1256 "AllDays"1257 }1258 onChange={this.onValueChange}1259 />1260 Copy to All Days1261 </label>1262 </div>1263 <div className="radio">1264 <label>1265 <input1266 type="radio"1267 value="None"1268 checked={1269 this.state.selectedOption === "None"1270 }1271 onChange={this.onValueChange}1272 />1273 None1274 </label>1275 </div>1276 <div1277 className="btn btn-info"1278 onClick={this.applyValueChange}1279 >1280 Apply1281 </div>1282 </div>1283 </div>1284 <label>1285 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Monday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Monday" /> No Delivery?1286 </label>1287 </div>1288 </TabPanel>1289 <TabPanel>1290 <div className="col-md-9">{tuesdayData}</div>1291 <div className="col-md-3">1292 <label>1293 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Tuesday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Tuesday" /> No Delivery?1294 </label>1295 </div>1296 </TabPanel>1297 <TabPanel>1298 <div className="col-md-9">{wednesdayData}</div>1299 <div className="col-md-3">1300 <label>1301 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Wednesday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Wednesday" /> No Delivery?1302 </label>1303 </div>1304 </TabPanel>1305 <TabPanel>1306 <div className="col-md-9">{thursdayData}</div>1307 <div className="col-md-3">1308 <label>1309 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Thursday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Thursday" /> No Delivery?1310 </label>1311 </div>1312 </TabPanel>1313 <TabPanel><div className="col-md-9">{fridayData}</div>1314 <div className="col-md-3">1315 <label>1316 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Friday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Friday" /> No Delivery?1317 </label>1318 </div></TabPanel>1319 <TabPanel><div className="col-md-9">{saturdayData}</div>1320 <div className="col-md-3">1321 <label>1322 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Saturday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Saturday" /> No Delivery?1323 </label>1324 </div></TabPanel>1325 <TabPanel><div className="col-md-9">{sundayData}</div>1326 <div className="col-md-3">1327 <label>1328 <input type="checkbox" checked={this.state.fields.delivery_checkbox_Sunday === "No"} onChange={this.handleChangeChk} name="delivery_checkbox_Sunday" /> No Delivery?1329 </label>1330 </div></TabPanel>1331 </Tabs>1332 </div>1333 </div>1334 <div className="box-footer text-center">1335 <Link className="btn btn-primary" to="/campaign">1336 Back1337 </Link>1338 {this.state.status_exist == 1 ? (1339 this.state.load_spinner ? (1340 <button className="btn btn-info leftside">1341 <i className="fa fa-spinner fa-spin"></i>1342 </button>1343 ) : (1344 <button1345 type="submit"1346 className="btn btn-info leftside"1347 >1348 Save1349 </button>1350 )1351 ) : (1352 ""1353 )}1354 </div>1355 </form>1356 </div>1357 </div>1358 </div>1359 </section>1360 </div>1361 <Modal1362 open={open}1363 onClose={this.onCloseModal}1364 center1365 classNames={{1366 overlay: "customOverlay",1367 modal: "customModal-preview modal-lg",1368 }}1369 >1370 <div className="preview-ui">1371 <div class="row">1372 <div class="col-lg-12 text-center">1373 <h4>Campaign Preview</h4>1374 <hr />1375 </div>1376 <div class="col-lg-12" id="offerdiv">1377 <div class="listing">1378 <ul class="list-unstyled">1379 <li>1380 <div class="countlisting">1</div>1381 <div class="listingimg">1382 <img1383 src={Auth.imageCheck(this.state.fields.campaign_logo)}1384 />1385 </div>1386 <div class="listingtext">1387 <h4>{this.state.fields.headline}</h4>1388 <ul class="style1 ccawidgetdescul">1389 <li>1390 <i class="fa fa-check"></i>{" "}1391 {this.state.fields.bullet1}1392 </li>1393 <li>1394 <i class="fa fa-check"></i>{" "}1395 {this.state.fields.bullet2}1396 </li>1397 <li>1398 <i class="fa fa-check"></i>{" "}1399 {this.state.fields.bullet3}1400 </li>1401 {this.state.fields.bullet4 != "" ? (1402 <li>1403 <i class="fa fa-check"></i>{" "}1404 {this.state.fields.bullet4}1405 </li>1406 ) : (1407 ""1408 )}1409 {this.state.fields.bullet5 != "" ? (1410 <li>1411 <i class="fa fa-check"></i>{" "}1412 {this.state.fields.bullet5}1413 </li>1414 ) : (1415 ""1416 )}1417 </ul>1418 </div>1419 <div class="listingbutton">1420 <a href="javascript:void(0)" class="applyoffer">1421 Get Quote1422 </a>1423 </div>1424 <div class="clearfix"></div>1425 </li>1426 </ul>1427 </div>1428 </div>1429 </div>1430 </div>1431 </Modal>1432 </div>1433 );1434 }1435}...

Full Screen

Full Screen

Book.js

Source:Book.js Github

copy

Full Screen

1import React, { useState, useEffect } from 'react';2import { Container, Form, Button } from 'react-bootstrap';3import sweet from 'sweetalert2';4import Slots from './Slots'5import Navbars from './Navbars';6import '../CSS/login.css'7import '../CSS/booking.css'8import { useDispatch, useSelector } from 'react-redux';9import { getBookingData, getSlots } from '../API/apiCalls';10import Footer from './Footer';11const regForName = RegExp(/^[a-zA-Z0-9\s,.'-]{3,}$/);12function Book() {13 const [bookingData, setBookingData] = useState({14 location: '',15 date: '',16 fromTime: '',17 toTime: '',18 vehicle: ''19 })20 const [errors, setErrors] = useState({21 date: ' ',22 fromTime: ' ',23 toTime: ' ',24 })25 const [slotData, setSlotData] = useState()26 const color = useSelector((state) => state.changeColor);27 console.log(color)28 useEffect(() => {29 sessionStorage.setItem("slots", JSON.stringify(color))30 setSlotData(color)31 }, [color]);32 const [flag, setFlag] = useState(0)33 console.log(errors)34 const dispatch = useDispatch()35 const bookData = (event) => {36 const { name, value } = event.target37 switch (name) {38 case "date":39 var myDate = new Date(value);40 let today = new Date();41 if (myDate.getDate() < today.getDate()) {42 errors.date = "Date should not be in past"43 break;44 }45 else if (myDate.getFullYear() > today.getFullYear()) {46 errors.date = "year should be current";47 break;48 }49 // else if(myDate.getDate()>today.getDate()+3){50 // errors.date="you can book a slot upto 3 days"51 // }52 else {53 errors.date = ''54 break;55 }56 case "fromTime":57 console.log(bookingData.toTime)58 let currentTime = new Date();59 let timer = new Date(bookingData.date)60 let nextTime = new Date(new Date().toDateString() + ' ' + bookingData.toTime)61 let bTime = new Date(new Date().toDateString() + ' ' + value)62 console.log(bookingData.toTime)63 console.log(value)64 console.log(bTime.getHours(), nextTime.getHours())65 if (timer.getDate() > currentTime.getDate()) {66 errors.fromTime = ''67 break;68 }69 else if (bTime.getTime() == nextTime.getTime()) {70 errors.fromTime = "time cant be same";71 errors.toTime = '';72 break;73 }74 else if (bTime.getHours() <= currentTime.getHours()) {75 errors.fromTime = "Please select proper time"76 break;77 }78 else if (bookingData.toTime != '') {79 console.log(nextTime.getHours(), bTime.getHours())80 if (nextTime.getHours() < bTime.getHours()) {81 errors.fromTime = 'please select time which is before to Time ';82 errors.toTime = ''83 break;84 }85 else if (bTime.getTime() != nextTime.getTime()) {86 console.log(nextTime.getMinutes())87 errors.fromTime = "";88 errors.toTime = ''89 break;90 }91 else {92 errors.fromTime = ''93 break;94 }95 }96 else {97 errors.fromTime = ''98 break;99 }100 case "toTime":101 console.log(value)102 let myTime = new Date(new Date().toDateString() + ' ' + value)103 let beforeTime = new Date(new Date().toDateString() + ' ' + bookingData.toTime)104 let timess = new Date(new Date().toDateString() + ' ' + bookingData.fromTime)105 console.log(myTime.getMinutes())106 if (timess.getHours() == myTime.getHours()) {107 if (myTime.getMinutes() == 0) {108 errors.toTime = "time cant be same";109 errors.fromTime = ''110 break;111 }112 else if (myTime.getMinutes() == 30) {113 errors.toTime = "";114 break;115 }116 else if (myTime.getMinutes() > 0) {117 errors.fromTime = ''118 errors.toTime = "Minutes should be round figu#FF3131 e.g 1:30 or 1:00";119 break;120 }121 else if (myTime.getTime() != beforeTime.getTime()) {122 console.log(nextTime.getMinutes())123 errors.toTime = "";124 }125 else {126 errors.toTime = "Minutes should be round figu#FF3131 e.g 1:30 or 1:00"127 break;128 }129 }130 else if (timess.getHours() > myTime.getHours()) {131 errors.toTime = 'Select time after from time'132 errors.fromTime = ''133 break;134 }135 else if (myTime.getMinutes() != 30 && myTime.getMinutes() != 0) {136 errors.toTime = "Minutes should be round figu#FF3131 e.g 1:30 or 1:00"137 break;138 }139 else if (beforeTime.getHours() < timess.getHours()) {140 errors.fromTime = ''141 errors.toTime = ''142 break;143 }144 else {145 errors.toTime = ''146 break;147 }148 }149 setErrors({ ...errors, date: errors.date, fromTime: errors.fromTime, toTime: errors.toTime })150 setBookingData({ ...bookingData, [name]: value })151 console.log(bookingData)152 }153 const didi = () => {154 let arr = []155 let count=0;156 let countDate=0;157 if (errors.date == '' && errors.fromTime == '' && errors.toTime == '' && bookingData.location != '' && bookingData.vehicle != '') {158 setFlag(1)159 // sweet.fire({160 // title: 'Book a slot now',161 // icon: "success",162 // timer: 2000163 // })164 // getSlots().then((res) => {165 // if (sessionStorage.getItem("slots")) {166 // let slots = JSON.parse(sessionStorage.getItem("slots"))167 // for (let i = 0; i < res.data.length; i++) {168 // console.log(res.data[i].locationName==bookingData.location)169 // if (res.data[i].locationName == bookingData.location) {170 // console.log("hie")171 // for (let j = 0; j < res.data[i].bookedSlots.length; j++) {172 // let dbDate = new Date(res.data[i].bookedSlots[j].date).getDate();173 // let myDate = new Date(bookingData.date).getDate();174 // console.log(myDate, dbDate)175 // if (myDate == dbDate) {176 // countDate++;177 // console.log("date same")178 // let dbTime = new Date(new Date().toDateString() + ' ' + res.data[i].bookedSlots[j].fromTime).getHours()179 // let myTime = new Date(new Date().toDateString() + ' ' + bookingData.fromTime).getHours()180 // if (dbTime == myTime) {181 // console.log("yes")182 // arr.push(res.data[i].bookedSlots[j].slots)183 // console.log(arr)184 // slots.forEach(function (arrayItem, index) {185 // if (arr.includes(index+1)) {186 // slots[index].color = "#FF3131";187 // }188 // else{189 // slots[index].color="#22DD22"190 // }191 // })192 // count++;193 // console.log("count",count)194 // }195 // else if(count==0){196 // console.log("no")197 // slots.forEach(function (arrayItem, index) {198 // slots[index].color = "#22DD22"199 // })200 // }201 // }202 // else if(countDate==0){203 // slots.forEach(function (arrayItem, index) {204 // slots[index].color = "#22DD22"205 // })206 // }207 // }208 // }209 // }210 // console.log(slots)211 // setSlotData(slots)212 // sessionStorage.setItem("slots", JSON.stringify(slots))213 // }214 // })215 getSlots().then((res) => {216 if (sessionStorage.getItem("slots")) {217 let slots = JSON.parse(sessionStorage.getItem("slots"))218 for (let i = 0; i < res.data.length; i++) {219 console.log(res.data[i].locationName==bookingData.location)220 221 if (res.data[i].locationName == bookingData.location) {222 // getBookingData({id:res.data[i]._id}).then((res)=>{223 // })224 console.log("hie")225 for (let j = 0; j < res.data[i].bookedSlots.length; j++) {226 let dbDate = new Date(res.data[i].bookedSlots[j].date).getDate();227 let myDate = new Date(bookingData.date).getDate();228 console.log(myDate, dbDate)229 if (myDate == dbDate) {230 countDate++;231 console.log("date same")232 let dbTime = new Date(new Date().toDateString() + ' ' + res.data[i].bookedSlots[j].fromTime).getHours()233 let myTime = new Date(new Date().toDateString() + ' ' + bookingData.fromTime).getHours()234 if (dbTime == myTime) {235 console.log("yes")236 arr.push(res.data[i].bookedSlots[j].slots)237 console.log(arr)238 slots.forEach(function (arrayItem, index) {239 if (arr.includes(index+1)) {240 slots[index].color = "#FF3131";241 }242 else{243 slots[index].color="#22DD22"244 }245 })246 count++;247 console.log("count",count)248 }249 else if(count==0){250 console.log("no")251 slots.forEach(function (arrayItem, index) {252 slots[index].color = "#22DD22"253 })254 }255 }256 else if(countDate==0){257 slots.forEach(function (arrayItem, index) {258 slots[index].color = "#22DD22"259 })260 }261 }262 }263 }264 console.log(slots)265 setSlotData(slots)266 sessionStorage.setItem("slots", JSON.stringify(slots))267 }268 })269 // dispatch({type:"slots",payload:"#FF3131",location:bookingData.location,fromTime:bookingData.fromTime,toTime:bookingData.toTime,date:bookingData.date})270 }271 else {272 sweet.fire({273 title: 'Fill All fields Properly',274 icon: "warning",275 timer: 2000276 })277 setFlag(0)278 }279 let t = new Date(new Date().toDateString() + ' ' + bookingData.fromTime).getTime()280 let c = new Date(new Date().toDateString() + ' ' + bookingData.toTime).getTime()281 }282 return <div>283 <Navbars />284 <Container>285 <Form className='loginForm mt-2 bookingForm'>286 <fieldset id="disable">287 <h1 className='text-center'>Book a Slot</h1>288 <Form.Group className="mb-2" >289 <Form.Label className='text-dark mt-2 label1' >Location Name</Form.Label>290 <Form.Select aria-label="Default select example" name="location" onChange={bookData}>291 <option value=''>Select Location</option>292 <option value="Airoli">Airoli</option>293 <option value="Rabale">Rabale</option>294 <option value="Ghansoli">Ghansoli</option>295 </Form.Select>296 </Form.Group>297 <Form.Group>298 <Form.Label className='text-dark mt-2 label1' >Vehicle Type:</Form.Label>299 <Form.Select aria-label="Default select example" name="vehicle" onChange={bookData}>300 <option value=''>select Vehicle</option>301 <option value="4 wheeler">4 wheeler</option>302 <option value="2 wheeler">2 wheeler</option>303 </Form.Select>304 </Form.Group>305 <Form.Group className="mb-2" >306 <Form.Label className='text-dark mt-2 label1'>Booking Date:</Form.Label>307 <Form.Control type="date" name="date" onChange={bookData} />308 </Form.Group>309 {errors.date.length > 0 &&310 <span style={{ color: "#FF3131" }}>{errors.date}</span>}311 <Form.Group className="mb-2" >312 <Form.Label className='text-dark mt-2 label1'>From Time:</Form.Label>313 <Form.Select aria-label="Default select example" name="fromTime" onChange={bookData}>314 <option >From Time</option>315 <option value="1:00">1:00</option>316 <option value="2:00">2:00</option>317 <option value="3:00">3:00</option>318 <option value="4:00">4:00</option>319 <option value="6:00">6:00</option>320 <option value="7:00">7:00</option>321 <option value="8:00">8:00</option>322 <option value="9:00">9:00</option>323 <option value="10:00">10:00</option>324 <option value="11:00">11:00</option>325 <option value="12:00">12:00</option>326 <option value="13:00">13:00</option>327 <option value="14:00">14:00</option>328 <option value="15:00">15:00</option>329 <option value="16:00">16:00</option>330 <option value="17:00">17:00</option>331 <option value="18:00">18:00</option>332 <option value="19:00">19:00</option>333 <option value="20:00">20:00</option>334 <option value="21:00">21:00</option>335 <option value="22:00">22:00</option>336 <option value="22:00">23:00</option>337 </Form.Select>338 </Form.Group>339 {errors.fromTime.length > 0 &&340 <span style={{ color: "#FF3131" }}>{errors.fromTime}</span>}341 <Form.Group >342 <Form.Label className='text-dark mt-2 label1'>To Time:</Form.Label>343 <Form.Control type="time" name="toTime" onChange={bookData} />344 </Form.Group>345 {errors.toTime.length > 0 &&346 <span style={{ color: "#FF3131" }}>{errors.toTime}</span>}347 </fieldset>348 <Button onClick={didi}>Show slots</Button>349 </Form>350 {flag == 1 && <Slots location={bookingData.location} date={bookingData.date} fromTime={bookingData.fromTime} vehicle={bookingData.vehicle} toTime={bookingData.toTime} slotData={slotData} />}351 {/* <Slots/> */}352 </Container>353 <Footer/>354 </div>;355}...

Full Screen

Full Screen

Bootstrap.js

Source:Bootstrap.js Github

copy

Full Screen

1import { useEffect, useState } from "react"2import axios from "axios"3import { client as apolloClient } from "./Config/ApolloProviderWithClient"4import { SAVE_EVENT_DURATION, SAVE_EVENT_STATE, SAVE_ROOM, SAVE_THERAPY_TYPE } from "./GraphQL/Mutations/baseDataMutators"5import { CREATE_PASS, SAVE_THERAPIST } from "./GraphQL/Mutations/therapyMutators"6import { SAVE_CLIENT, SAVE_FAMILY } from "./GraphQL/Mutations/familyMutators"7import { CREATE_TIME_TABLE } from "./GraphQL/Mutations/timeTableMutators"8import { days, formatTime, getFirstDayOfWeekInMonth, getHourAndMin } from "./utils"9export const Bootstrap = () => {10 const [cleared, setCleared] = useState(null)11 useEffect(() => {12 if (!cleared) {13 (async () => {14 const response = await axios.get("http://localhost:8080/clearAllData")15 setCleared(response.data.response)16 })()17 }18 })19 const [rooms, setRooms] = useState()20 useEffect(() => {21 const createRoom = async (room) => {22 const response = await apolloClient.mutate({ mutation: SAVE_ROOM, variables: room })23 return response.data.saveRoom24 }25 if (cleared === "success") {26 (async () => {27 const theRooms = []28 theRooms.push(await createRoom({ id: 1, description: "Logo szoba" }))29 theRooms.push(await createRoom({ id: 2, description: "Vizsgáló" }))30 theRooms.push(await createRoom({ id: 3, description: "Torna szoba" }))31 setRooms(theRooms)32 })()33 }34 }, [cleared])35 const [therapyTypes, setTherapyTypes] = useState()36 useEffect(() => {37 const createTherapyType = async (therapyType) => {38 const response = await apolloClient.mutate({ mutation: SAVE_THERAPY_TYPE, variables: therapyType })39 return response.data.saveTherapyType40 }41 if (cleared === "success") {42 (async () => {43 const theTherapyTypes = []44 theTherapyTypes.push(await createTherapyType({ id: 1, description: "Logopédia" }))45 theTherapyTypes.push(await createTherapyType({ id: 2, description: "Mozgásfejlesztés" }))46 setTherapyTypes(theTherapyTypes)47 })()48 }49 }, [cleared])50 const [therapyEventStates, setTherapyEventStates] = useState([])51 useEffect(() => {52 const createEventStatus = async (eventStatus) => {53 const response = await apolloClient.mutate({ mutation: SAVE_EVENT_STATE, variables: eventStatus })54 return response.data.saveTherapyEventState55 }56 if (cleared === "success") {57 (async () => {58 const theTherapyEventStates = []59 theTherapyEventStates.push(await createEventStatus({ id: 1, description: "Tervezett" }))60 theTherapyEventStates.push(await createEventStatus({ id: 2, description: "Megtartott" }))61 theTherapyEventStates.push(await createEventStatus({ id: 3, description: "Lemondott" }))62 setTherapyEventStates(theTherapyEventStates)63 })()64 }65 }, [cleared])66 const [therapyEventDurations, setTherapyEventDurations] = useState([])67 useEffect(() => {68 const createEventDuration = async (eventDuration) => {69 const response = await apolloClient.mutate({ mutation: SAVE_EVENT_DURATION, variables: eventDuration })70 return response.data.saveTherapyEventDuration71 }72 if (cleared === "success") {73 (async () => {74 const theTherapyEventDurations = []75 theTherapyEventDurations.push(await createEventDuration({ id: 1, description: "30 perc", minutes: 30 }))76 theTherapyEventDurations.push(await createEventDuration({ id: 2, description: "45 perc", minutes: 45 }))77 setTherapyEventDurations(theTherapyEventDurations)78 })()79 }80 }, [cleared])81 const [therapists, setTherapists] = useState()82 useEffect(() => {83 const createTherapist = async (therapist) => {84 const resp = await apolloClient.mutate({ mutation: SAVE_THERAPIST, variables: therapist })85 return resp.data.saveTherapist86 }87 if (cleared === "success") {88 (async () => {89 const theTherapists = []90 theTherapists.push(await createTherapist({ id: 1, name: "Fehér Kata", phone: "+36202459782", email: "fhrkata@gmail.com" }))91 theTherapists.push(await createTherapist({ id: 2, name: "Turcsik Anita", phone: "", email: "" }))92 setTherapists(theTherapists)93 })()94 }95 }, [cleared])96 const [families, setFamilies] = useState()97 useEffect(() => {98 const createPass = async (timeTable, newClient) => {99 const variables = {100 therapyType: 1,101 eventCount: 4,102 eventDuration: 2,103 clientId: newClient.id,104 familyId: newClient.familyId,105 firstEventDate: getFirstDayOfWeekInMonth(timeTable.dayOfWeek),106 firstTimeTable: timeTable.id107 }108 const response = await apolloClient.mutate({109 mutation: CREATE_PASS,110 variables: variables111 })112 return response.data.createPass113 }114 const createFamily = async (family, clients) => {115 const familyResp = await apolloClient.mutate({ mutation: SAVE_FAMILY, variables: { name: family.name, familyId: 0 } })116 const newFamily = familyResp.data.updateFamily117 newFamily.clients = await Promise.all(118 clients.map(async (client) => {119 const clientResp = await apolloClient.mutate({ mutation: SAVE_CLIENT, variables: { name: client.name, id: 0, familyId: newFamily.id } })120 const newClient = clientResp.data.updateClient121 newClient.timeTables = client.timeTables && await Promise.all(122 client.timeTables.map(async (timeTable) => {123 const timeTableResp = await apolloClient.mutate({124 mutation: CREATE_TIME_TABLE, variables: {125 dayOfWeek: timeTable.dayOfWeek, fromTime: formatTime(timeTable.fromTime, true, true) + "+01:00", toTime: formatTime(timeTable.toTime, true, true) + "+01:00",126 therapyType: 1, room: 2, therapist: 1, clients: newClient.id127 }128 })129 const newTimeTable = timeTableResp.data.createTimeTableSlot130 newTimeTable.pass = await createPass(newTimeTable, newClient)131 return newTimeTable132 })133 )134 return newClient135 })136 )137 return newFamily138 }139 if (cleared === "success" && therapists && therapyTypes && rooms) {140 (async () => {141 const theFamilies = []142 theFamilies.push(await createFamily({ name: "Hervai" }, [143 { name: "Hervai Bence", timeTables: [{ dayOfWeek: 1, fromTime: { hour: 14, min: 45 }, toTime: { hour: 15, min: 30 } }] },144 { name: "Hervai Gergő", timeTables: [{ dayOfWeek: 4, fromTime: { hour: 13, min: 20 }, toTime: { hour: 14, min: 5 } }] }]))145 theFamilies.push(await createFamily({ name: "Muskovics" }, [146 { name: "Muskovics Szandi", timeTables: [{ dayOfWeek: 1, fromTime: { hour: 13, min: 55 }, toTime: { hour: 14, min: 40 } }] }]))147 theFamilies.push(await createFamily({ name: "Sziebig" }, [148 {149 name: "Sziebig Ricsi", timeTables: [150 { dayOfWeek: 2, fromTime: { hour: 8, min: 55 }, toTime: { hour: 9, min: 40 } },151 { dayOfWeek: 4, fromTime: { hour: 8, min: 55 }, toTime: { hour: 9, min: 40 } }]152 }]))153 theFamilies.push(await createFamily({ name: "Buzna" }, [154 { name: "Buzna Balu", timeTables: [{ dayOfWeek: 1, fromTime: { hour: 15, min: 45 }, toTime: { hour: 16, min: 30 } }] },155 { name: "Buzna Misi", timeTables: [{ dayOfWeek: 2, fromTime: { hour: 15, min: 45 }, toTime: { hour: 16, min: 30 } }] }]))156 theFamilies.push(await createFamily({ name: "Elek" }, [157 { name: "Elek Ábel", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 15, min: 45 }, toTime: { hour: 16, min: 30 } }] }]))158 theFamilies.push(await createFamily({ name: "Tolnai" }, [159 { name: "Tolnai Lőrinc", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 15, min: 0 }, toTime: { hour: 15, min: 45 } }] }]))160 theFamilies.push(await createFamily({ name: "Farkasházi" }, [161 { name: "Farkasházi Kornél", timeTables: [{ dayOfWeek: 2, fromTime: { hour: 15, min: 5 }, toTime: { hour: 15, min: 35 } }] }]))162 theFamilies.push(await createFamily({ name: "Szabó" }, [163 { name: "Szabó Atti", timeTables: [{ dayOfWeek: 1, fromTime: { hour: 8, min: 30 }, toTime: { hour: 9, min: 15 } }] }]))164 theFamilies.push(await createFamily({ name: "Deme" }, [165 { name: "Deme Dóri", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 8, min: 0 }, toTime: { hour: 8, min: 45 } }] }]))166 theFamilies.push(await createFamily({ name: "Székely" }, [167 { name: "Székely Hanna", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 16, min: 35 }, toTime: { hour: 17, min: 20 } }] }]))168 theFamilies.push(await createFamily({ name: "Nemes" }, [169 { name: "Nemes Bence", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 8, min: 0 }, toTime: { hour: 8, min: 45 } }] }]))170 theFamilies.push(await createFamily({ name: "Tálos" }, [171 { name: "Tálos Bettina", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 13, min: 30 }, toTime: { hour: 14, min: 0 } }] }]))172 theFamilies.push(await createFamily({ name: "Charaf" }, [173 { name: "Charaf Klára", timeTables: [{ dayOfWeek: 4, fromTime: { hour: 10, min: 30 }, toTime: { hour: 11, min: 0 } }] }]))174 theFamilies.push(await createFamily({ name: "Párkányi" }, [175 { name: "Párkányi Bence", timeTables: [{ dayOfWeek: 4, fromTime: { hour: 14, min: 10 }, toTime: { hour: 14, min: 55 } }] }]))176 theFamilies.push(await createFamily({ name: "Karászi" }, [177 { name: "Karászi Gyöngyi", timeTables: [{ dayOfWeek: 2, fromTime: { hour: 14, min: 10 }, toTime: { hour: 14, min: 55 } }] }]))178 theFamilies.push(await createFamily({ name: "Dormán" }, [179 { name: "Dormán Áron", timeTables: [{ dayOfWeek: 4, fromTime: { hour: 15, min: 10 }, toTime: { hour: 15, min: 55 } }] }]))180 theFamilies.push(await createFamily({ name: "Tóth-Oborni" }, [181 { name: "Tóth-Oborni Dorka", timeTables: [{ dayOfWeek: 4, fromTime: { hour: 16, min: 0 }, toTime: { hour: 16, min: 30 } }] }]))182 theFamilies.push(await createFamily({ name: "Dobó" }, [183 { name: "Dobó Domi", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 8, min: 55 }, toTime: { hour: 9, min: 40 } }] }]))184 theFamilies.push(await createFamily({ name: "Höltzl" }, [185 { name: "Höltzl Huba", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 13, min: 0 }, toTime: { hour: 13, min: 45 } }] },186 { name: "Höltzl Marci", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 13, min: 55 }, toTime: { hour: 14, min: 40 } }] }]))187 theFamilies.push(await createFamily({ name: "Szabó" }, [188 { name: "Szabó Barbara", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 15, min: 45 }, toTime: { hour: 16, min: 30 } }] }]))189 theFamilies.push(await createFamily({ name: "Turcsik" }, [190 { name: "Turcsik Levente", timeTables: [{ dayOfWeek: 2, fromTime: { hour: 13, min: 15 }, toTime: { hour: 14, min: 0 } }] },191 { name: "Turcsik Magdi", timeTables: [{ dayOfWeek: 5, fromTime: { hour: 14, min: 50 }, toTime: { hour: 15, min: 35 } }] }]))192 theFamilies.push(await createFamily({ name: "Tátrai" }, [193 { name: "Tátrai Anti", timeTables: [{ dayOfWeek: 3, fromTime: { hour: 14, min: 10 }, toTime: { hour: 14, min: 55 } }] }]))194 setFamilies(theFamilies)195 })()196 }197 }, [cleared, therapists, therapyTypes, rooms])198 return (199 <div className="contentwrapper">200 <p>{`ClearAllData: ${cleared}`}</p>201 <p>Szobák</p>202 <ul style={{ padding: "0 0 1rem 2rem" }} >203 {rooms && rooms.map((r, i) => <li key={i} >{r.description}</li>)}204 </ul>205 <p>Terápiatipusok</p>206 <ul style={{ padding: "0 0 1rem 2rem" }} >207 {therapyTypes && therapyTypes.map((tt, i) => <li key={i} >{tt.description}</li>)}208 </ul>209 <p>Alkalom státuszok</p>210 <ul style={{ padding: "0 0 1rem 2rem" }} >211 {therapyEventStates.map((tes, i) => <li key={i} >{tes.description}</li>)}212 </ul>213 <p>Alkalom időtartam</p>214 <ul style={{ padding: "0 0 1rem 2rem" }} >215 {therapyEventDurations.map((ted, i) => <li key={i} >{ted.description}</li>)}216 </ul>217 <p>Terapeuták</p>218 <ul style={{ padding: "0 0 1rem 2rem" }} >219 {therapists && therapists.map((t, i) => <li key={i} >{t.name}</li>)}220 </ul>221 <p>Családok</p>222 <ul style={{ padding: "0 0 1rem 2rem" }} >223 {families && families.map((f, i) => <li key={i} >{f.name}<ul>224 {f.clients.length && f.clients.map((c, ci) => <li key={ci} style={{ marginLeft: "2em" }} >{c.name}225 <ul>226 {c.timeTables?.length && c.timeTables.map((tt, tti) =>227 <li key={tti} style={{ marginLeft: "2em" }} >{`${days[tt.dayOfWeek - 1].description} ${formatTime(getHourAndMin(tt.fromTime))} - ${formatTime(getHourAndMin(tt.toTime))}`}228 <p style={{ marginLeft: "2em" }}>229 {tt.pass?.id}230 </p>231 </li>)}232 </ul>233 </li>)}234 </ul></li>)}235 </ul>236 </div>237 )...

Full Screen

Full Screen

routes_trendUsage.js

Source:routes_trendUsage.js Github

copy

Full Screen

1/*2 Copyright [2016] [Relevance Lab]3 Licensed under the Apache License, Version 2.0 (the "License");4 you may not use this file except in compliance with the License.5 You may obtain a copy of the License at6 http://www.apache.org/licenses/LICENSE-2.07 Unless required by applicable law or agreed to in writing, software8 distributed under the License is distributed on an "AS IS" BASIS,9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.10 See the License for the specific language governing permissions and11 limitations under the License.12*/13var logger = require('_pr/logger')(module);14var async = require('async');15var analyticsService = require('_pr/services/analyticsService');16module.exports.setRoutes = function(app, sessionVerificationFunc) {17 app.all('/analytics/*', sessionVerificationFunc);18 /**19 * @api {get} /analytics/trend/usage?resource=<resourceId>&fromTimeStamp=<startDate>&toTimeStamp=<endDate>&interval=<INTERVAL>&metric=<METRIC>20 * Get usage trend.21 * @apiName getTrendUsage22 * @apiGroup analytics23 * @apiVersion 1.0.024 * @apiDescription The api returns only 500 data points. If your query exceeds the limit, you will get an error response. Try resubmitting the query with smaller range25 * 26 * @apiParam {String} resource ResourceId27 * @apiParam {Date} fromTimeStamp Start Time Stamp, inclusive. Format YYYY-MM-DDTHH:MM:SS. For Ex: 2016-07-29T00:00:0028 * @apiParam {Date} toTimeStamp End Time Stamp, exclusive. Format YYYY-MM-DDTHH:MM:SS. For Ex: 2016-07-29T00:05:00 29 * @apiParam {String} interval Frequency in seconds. For Ex: 360030 * @apiParam {String} [metric="All Metrics"] Filter particular metrics. For Ex: CPUUtilization,DiskReadBytes31 * @apiParam {String} [statistics="All Statistics"] Filter particular statistics. For Ex: Average,Minimum32 *33 * @apiExample Sample_Request_134 * /analytics/trend/usage?resource=5790c31edff2c49223fd6efa&fromTimeStamp=2016-07-29T00:00:00&toTimeStamp=2016-07-29T00:05:00&interval=1_MINUTE 35 * 36 * @apiExample Sample_Request_237 * /analytics/trend/usage?resource=5790c31edff2c49223fd6efa&fromTimeStamp=2016-07-29T00:00:00&toTimeStamp=2016-07-29T00:05:00&interval=1_MINUTE&metric=CPUUtilization38 * 39 * @apiExample Sample_Request_340 * /analytics/trend/usage?resource=5790c31edff2c49223fd6efa&fromTimeStamp=2016-07-29T00:00:00&toTimeStamp=2016-07-29T00:05:00&interval=1_MINUTE&metric=CPUUtilization&statistics=Average,Minimum41 * 42 * @apiExample Sample_Request_443 * /analytics/trend/usage?resource=5790c31edff2c49223fd6efa&fromTimeStamp=2016-07-29T00:00:00&toTimeStamp=2016-07-29T24:00:00&interval=1_HOUR&metric=CPUUtilization44 * 45 * @apiSuccess {Object} trend Trend46 * @apiSuccess {Object} trend.METRIC Usage Metric Name47 * @apiSuccess {String} trend.METRIC.unit Usage Metric Unit48 * @apiSuccess {String} trend.METRIC.symbol Usage Metric Symbol49 * @apiSuccess {Object[]} trend.METRIC.datePoints Usage Metric DataPoints50 * @apiSuccess {Date} trend.METRIC.datePoints.fromTime Usage Metric Start Time51 * @apiSuccess {Date} trend.METRIC.datePoints.toTime Usage Metric End Time52 * @apiSuccess {Number} trend.METRIC.datePoints.minimum Usage Metric Minimum53 * @apiSuccess {Number} trend.METRIC.datePoints.maximum Usage Metric Maximum54 * @apiSuccess {Number} trend.METRIC.datePoints.average Usage Metric Average55 * 56 * @apiSuccessExample {json} Sample_Response_1:57 * HTTP/1.1 200 OK58 * 59 * {60 "CPUUtilization": {61 "unit": "Percentage",62 "symbol": "%",63 "dataPoints": [64 {65 "fromTime": "2016-07-29T00:00:01",66 "toTime": "2016-07-29T00:01:00",67 "maximum": 0.83,68 "minimum": 0,69 "average": 0.03570 },71 {72 "fromTime": "2016-07-29T00:01:01",73 "toTime": "2016-07-29T00:02:00",74 "maximum": 0.82,75 "minimum": 0.81,76 "average": 0.8177 },78 {79 "fromTime": "2016-07-29T00:02:01",80 "toTime": "2016-07-29T00:03:00",81 "maximum": 0.35,82 "minimum": 0.33,83 "average": 0.3484 },85 {86 "fromTime": "2016-07-29T00:03:01",87 "toTime": "2016-07-29T00:04:00",88 "maximum": 0,89 "minimum": 0,90 "average": 091 },92 {93 "fromTime": "2016-07-29T00:04:01",94 "toTime": "2016-07-29T00:05:00",95 "maximum": 0.12,96 "minimum": 0.12,97 "average": 0.1298 }99 ]100 },101 "DiskReadBytes": {102 "unit": "Bytes",103 "symbol": "Bytes",104 "dataPoints": [105 {106 "fromTime": "2016-07-29T00:00:01",107 "toTime": "2016-07-29T00:01:00",108 "maximum": 0,109 "minimum": 0,110 "average": 0111 },112 {113 "fromTime": "2016-07-29T00:01:01",114 "toTime": "2016-07-29T00:02:00",115 "maximum": 200,116 "minimum": 200,117 "average": 200118 },119 {120 "fromTime": "2016-07-29T00:02:01",121 "toTime": "2016-07-29T00:03:00",122 "maximum": 1000,123 "minimum": 500,124 "average": 750125 },126 {127 "fromTime": "2016-07-29T00:03:01",128 "toTime": "2016-07-29T00:04:00",129 "maximum": 400,130 "minimum": 400,131 "average": 400132 },133 {134 "fromTime": "2016-07-29T00:04:01",135 "toTime": "2016-07-29T00:05:00",136 "maximum": 625,137 "minimum": 620,138 "average": 623139 }140 ]141 }142 }143 *144 *@apiSuccessExample {json} Sample_Response_2:145 * HTTP/1.1 200 OK146 * 147 * {148 "CPUUtilization": {149 "unit": "Percentage",150 "symbol": "%",151 "dataPoints": [152 {153 "fromTime": "2016-07-29T00:00:01",154 "toTime": "2016-07-29T00:01:00",155 "maximum": 0.83,156 "minimum": 0,157 "average": 0.035158 },159 {160 "fromTime": "2016-07-29T00:01:01",161 "toTime": "2016-07-29T00:02:00",162 "maximum": 0.82,163 "minimum": 0.81,164 "average": 0.81165 },166 {167 "fromTime": "2016-07-29T00:02:01",168 "toTime": "2016-07-29T00:03:00",169 "maximum": 0.35,170 "minimum": 0.33,171 "average": 0.34172 },173 {174 "fromTime": "2016-07-29T00:03:01",175 "toTime": "2016-07-29T00:04:00",176 "maximum": 0,177 "minimum": 0,178 "average": 0179 },180 {181 "fromTime": "2016-07-29T00:04:01",182 "toTime": "2016-07-29T00:05:00",183 "maximum": 0.12,184 "minimum": 0.12,185 "average": 0.12186 }187 ]188 }189 }190 *191 *@apiSuccessExample {json} Sample_Response_3:192 * HTTP/1.1 200 OK193 * 194 * {195 "CPUUtilization": {196 "unit": "Percentage",197 "symbol": "%",198 "dataPoints": [199 {200 "fromTime": "2016-07-29T00:00:01",201 "toTime": "2016-07-29T00:01:00",202 "minimum": 0,203 "average": 0.035204 },205 {206 "fromTime": "2016-07-29T00:01:01",207 "toTime": "2016-07-29T00:02:00",208 "minimum": 0.81,209 "average": 0.81210 },211 {212 "fromTime": "2016-07-29T00:02:01",213 "toTime": "2016-07-29T00:03:00",214 "minimum": 0.33,215 "average": 0.34216 },217 {218 "fromTime": "2016-07-29T00:03:01",219 "toTime": "2016-07-29T00:04:00",220 "minimum": 0,221 "average": 0222 },223 {224 "fromTime": "2016-07-29T00:04:01",225 "toTime": "2016-07-29T00:05:00",226 "minimum": 0.12,227 "average": 0.12228 }229 ]230 }231 }232 *233 *@apiSuccessExample {json} Sample_Response_4:234 * HTTP/1.1 200 OK235 * 236 * {237 "CPUUtilization": {238 "unit": "Percentage",239 "symbol": "%",240 "dataPoints": [241 {242 "fromTime": "2016-07-29T00:00:01",243 "toTime": "2016-07-29T01:00:00",244 "maximum": 0.83,245 "minimum": 0,246 "average": 0.035247 },248 {249 "fromTime": "2016-07-29T01:00:01",250 "toTime": "2016-07-29T02:00:00",251 "maximum": 0.82,252 "minimum": 0.81,253 "average": 0.81254 },255 {256 "fromTime": "2016-07-29T02:00:01",257 "toTime": "2016-07-29T03:00:00",258 "maximum": 0.35,259 "minimum": 0.33,260 "average": 0.34261 },262 {263 "fromTime": "2016-07-29T03:00:01",264 "toTime": "2016-07-29T04:00:00",265 "maximum": 0,266 "minimum": 0,267 "average": 0268 },269 {270 "fromTime": "2016-07-29T04:00:01",271 "toTime": "2016-07-29T05:00:00",272 "maximum": 0.12,273 "minimum": 0.12,274 "average": 0.12275 },276 {277 "fromTime": "2016-07-29T05:00:01",278 "toTime": "2016-07-29T06:00:00",279 "maximum": 0.83,280 "minimum": 0,281 "average": 0.035282 },283 {284 "fromTime": "2016-07-29T06:00:01",285 "toTime": "2016-07-29T07:00:00",286 "maximum": 0.82,287 "minimum": 0.81,288 "average": 0.81289 },290 {291 "fromTime": "2016-07-29T07:00:01",292 "toTime": "2016-07-29T08:00:00",293 "maximum": 0.35,294 "minimum": 0.33,295 "average": 0.34296 },297 {298 "fromTime": "2016-07-29T08:00:01",299 "toTime": "2016-07-29T09:00:00",300 "maximum": 0,301 "minimum": 0,302 "average": 0303 },304 {305 "fromTime": "2016-07-29T09:00:01",306 "toTime": "2016-07-29T10:00:00",307 "maximum": 0.12,308 "minimum": 0.12,309 "average": 0.12310 },311 {312 "fromTime": "2016-07-29T10:00:01",313 "toTime": "2016-07-29T11:00:00",314 "maximum": 0.83,315 "minimum": 0,316 "average": 0.035317 },318 {319 "fromTime": "2016-07-29T11:00:01",320 "toTime": "2016-07-29T12:00:00",321 "maximum": 0.82,322 "minimum": 0.81,323 "average": 0.81324 },325 {326 "fromTime": "2016-07-29T12:00:01",327 "toTime": "2016-07-29T13:00:00",328 "maximum": 0.35,329 "minimum": 0.33,330 "average": 0.34331 },332 {333 "fromTime": "2016-07-29T13:00:01",334 "toTime": "2016-07-29T14:00:00",335 "maximum": 0,336 "minimum": 0,337 "average": 0338 },339 {340 "fromTime": "2016-07-29T14:00:01",341 "toTime": "2016-07-29T15:00:00",342 "maximum": 0.12,343 "minimum": 0.12,344 "average": 0.12345 },346 {347 "fromTime": "2016-07-29T15:00:01",348 "toTime": "2016-07-29T16:00:00",349 "maximum": 0.83,350 "minimum": 0,351 "average": 0.035352 },353 {354 "fromTime": "2016-07-29T16:00:01",355 "toTime": "2016-07-29T17:00:00",356 "maximum": 0.82,357 "minimum": 0.81,358 "average": 0.81359 },360 {361 "fromTime": "2016-07-29T17:00:01",362 "toTime": "2016-07-29T18:00:00",363 "maximum": 0.35,364 "minimum": 0.33,365 "average": 0.34366 },367 {368 "fromTime": "2016-07-29T18:00:01",369 "toTime": "2016-07-29T19:00:00",370 "maximum": 0,371 "minimum": 0,372 "average": 0373 },374 {375 "fromTime": "2016-07-29T19:00:01",376 "toTime": "2016-07-29T20:00:00",377 "maximum": 0.12,378 "minimum": 0.12,379 "average": 0.12380 },381 {382 "fromTime": "2016-07-29T20:00:01",383 "toTime": "2016-07-29T21:00:00",384 "maximum": 0,385 "minimum": 0,386 "average": 0387 },388 {389 "fromTime": "2016-07-29T21:00:01",390 "toTime": "2016-07-29T22:00:00",391 "maximum": 0.12,392 "minimum": 0.12,393 "average": 0.12394 },395 {396 "fromTime": "2016-07-29T22:00:01",397 "toTime": "2016-07-29T23:00:00",398 "maximum": 0,399 "minimum": 0,400 "average": 0401 },402 {403 "fromTime": "2016-07-29T23:00:01",404 "toTime": "2016-07-29T24:00:00",405 "maximum": 0.12,406 "minimum": 0.12,407 "average": 0.12408 }409 ]410 }411 }412 *413 * @apiErrorExample {json} Error-Response:414 * HTTP/1.1 404 Not Found415 * {416 * "errorCode": "ResourceNotFound"417 * "errorMessage": "The resource for which you are trying to obtain usage metrics does not exist in the records"418 * }419 * 420 */421 app.get("/analytics/trend/usage", getTrendUsage);422 function getTrendUsage(req, res, next) {423 /*res.status(200).send(req.query);*/424 async.waterfall([425 /* @TODO Check if user has access to the specified organization426 * 1. Check for validation of query parameters427 * 2. Get the organizational details for the resource428 * 3. Check if the user is authorized to access the resource details429 * 4. Make a query to get the usage metrics details430 * 431 */432 function(callback) {433 analyticsService.getTrendUsage(req.query.resource, req.query.interval, req.query.fromTimeStamp, req.query.toTimeStamp, callback);434 }435 ], function(err, usageMetrics) {436 if(err) {437 next(err);438 } else {439 // console.log("Usage Metrics: "+JSON.stringify(usageMetrics, null, 4));440 res.status(200).send(usageMetrics);441 }442 });443 }...

Full Screen

Full Screen

laDetail.js

Source:laDetail.js Github

copy

Full Screen

1$(document).ready(function() {2 $(".compensation").hide();3 console.log($("input[name='fromTime']").val())4 $('#fromtime').datetimepicker({5 format: 'L',//date only6 format: 'YYYY-MM-DD',7 daysOfWeekDisabled: [0, 6],8 defaultDate: timeStampConvertToyyyMMdd(parseInt($("input[name='fromTime']").val()))9 }).on('dp.change',function(e){10 showDays()11 })12 $('#totime').datetimepicker({13 format: 'L',//date only14 format: 'YYYY-MM-DD',15 daysOfWeekDisabled: [0, 6],16 defaultDate: timeStampConvertToyyyMMdd(parseInt($("input[name='toTime']").val()))17 }).on('dp.change',function(e){18 showDays()19 })20 $('#fromGranularity').datetimepicker({21 format: 'LT',//time only22 format: 'HH',23 enabledHours: [9, 12,18]24 }).on('dp.change',function(e){25 showDays()26 })27 $('#toGranularity').datetimepicker({28 format: 'LT',//time only29 format: 'HH',30 enabledHours: [9, 12,18]31 }).on('dp.change',function(e){32 showDays()33 })34});35function onLeaveTypeChange() {36 console.log("onLeaveTypeChange",$("#leavecategory").val());37 if($("#leavecategory").val()=="COMPENSATION_LEAVE"){38 $(".compensation").fadeIn();39 }else{40 $(".compensation").fadeOut();41 }42}43function showDays() {44 let fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();45 let totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();46 if(totime<=fromtime){47 return;48 }49 // let days=(totime-fromtime)/(1000*60*60*24);50 // $("#showDays").text(days+" days selectd")51 // console.log(fromtime);52 // console.log(totime);53}54function check(){55 let fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();56 let totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();57 let reasons=$("input[name='reasons']").val();58 let type=$("#leavecategory").val();59 if(type=="COMPENSATION_LEAVE"){60 if($("#fromGranularity").val()=="09"){61 fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();62 }else if($("#fromGranularity").val()=="12"){63 fromtime=new Date(new Date($("#fromtime").val()).setHours(12,0,0,0)).getTime();64 }else{65 fromtime=new Date(new Date($("#fromtime").val()).setHours(23,59,59,0)).getTime();66 }67 if($("#toGranularity").val()=="09"){68 totime=new Date(new Date($("#totime").val()).setHours(0,0,0,0)).getTime();69 }else if($("#toGranularity").val()=="12"){70 totime=new Date(new Date($("#totime").val()).setHours(12,0,0,0)).getTime();71 }else{72 totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();73 }74 }75 console.log("fromtime",fromtime);76 console.log("totime",totime);77 if(reasons==""){78 alert("reason can not be empty");79 return false;80 }81 if(totime-fromtime<=0){82 alert("the to date can not less than from date");83 return false;84 }85 $("input[name='fromTime']").val(fromtime);86 $("input[name='toTime']").val(totime);87 // return false;88 return true;89}90function timeStampConvertToyyyMMdd (timeStamp) {91 let date = new Date(timeStamp);92 let Y = date.getFullYear() + '-';93 let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';94 let D = date.getDate() + ' ';95 return Y + M + D ;...

Full Screen

Full Screen

submitLA.js

Source:submitLA.js Github

copy

Full Screen

1$(document).ready(function() {2 $(".compensation").hide();3 // var disabledDate = ['2020-7-1', '2020-7-2','2020-7-3'];4 $('#fromtime').datetimepicker({5 format: 'L',//date only6 format: 'YYYY-MM-DD',7 daysOfWeekDisabled: [0, 6]8 }).on('dp.change',function(e){9 showDays()10 })11 $('#totime').datetimepicker({12 format: 'L',//date only13 format: 'YYYY-MM-DD',14 daysOfWeekDisabled: [0, 6],15 }).on('dp.change',function(e){16 showDays()17 })18 $('#fromGranularity').datetimepicker({19 format: 'LT',//time only20 format: 'HH',21 enabledHours: [9, 12,18]22 }).on('dp.change',function(e){23 showDays()24 })25 $('#toGranularity').datetimepicker({26 format: 'LT',//time only27 format: 'HH',28 enabledHours: [9, 12,18]29 }).on('dp.change',function(e){30 showDays()31 })32});33function onLeaveTypeChange() {34 console.log("onLeaveTypeChange",$("#leavecategory").val());35 if($("#leavecategory").val()=="COMPENSATION_LEAVE"){36 $(".compensation").fadeIn();37 }else{38 $(".compensation").fadeOut();39 }40}41function showDays() {42 let fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();43 let totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();44 if(totime<=fromtime){45 return;46 }47 // let days=(totime-fromtime)/(1000*60*60*24);48 // $("#showDays").text(days+" days selectd")49 // console.log(fromtime);50 // console.log(totime);51}52function check(){53 let fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();54 let totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();55 let reasons=$("input[name='reasons']").val();56 let type=$("#leavecategory").val();57 if(type=="COMPENSATION_LEAVE"){58 if($("#fromGranularity").val()=="09"){59 fromtime=new Date(new Date($("#fromtime").val()).setHours(0,0,0,0)).getTime();60 }else if($("#fromGranularity").val()=="12"){61 fromtime=new Date(new Date($("#fromtime").val()).setHours(12,0,0,0)).getTime();62 }else{63 fromtime=new Date(new Date($("#fromtime").val()).setHours(23,59,59,0)).getTime();64 }65 if($("#toGranularity").val()=="09"){66 totime=new Date(new Date($("#totime").val()).setHours(0,0,0,0)).getTime();67 }else if($("#toGranularity").val()=="12"){68 totime=new Date(new Date($("#totime").val()).setHours(12,0,0,0)).getTime();69 }else{70 totime=new Date(new Date($("#totime").val()).setHours(23,59,59,0)).getTime();71 }72 }73 console.log("fromtime",fromtime);74 console.log("totime",totime);75 if(reasons==""){76 alert("reason can not be empty");77 return false;78 }79 if(totime-fromtime<=0){80 alert("the to date can not less than from date");81 return false;82 }83 $("input[name='fromTime']").val(fromtime);84 $("input[name='toTime']").val(totime);85 // return false;86 return true;...

Full Screen

Full Screen

answer.js

Source:answer.js Github

copy

Full Screen

1"use strict";2/**3 * In this challenge, you have to split up a video in several successive segments4 * that can be either segments with notes or without.5 *6 * Successive = the end time of a segment must be the start time of the next one.7 * Also FYI, duration are in the format "HH:mm:ss" (hours, minutes, seconds)8 *9 * Example:10 * Input: {11 * videoDuration: "01:33:12",12 * notes: [13 * { fromTime: "00:05:23", toTime: "00:15:10", note: "NodeJS presentation" },14 * { fromTime: "00:26:12", toTime: "00:51:02", note: "Installation" },15 * { fromTime: "00:51:02", toTime: "00:53:55", note: "Execution" },16 * { fromTime: "01:01:48", toTime: "01:07:29", note: "Livereloading" },17 * { fromTime: "00:16:12", toTime: "00:24:39", note: "NodeJS concepts" }18 * ]19 * }20 * Ouput: [21 * { fromTime: "00:00:00", toTime: "00:05:23" },22 * { fromTime: "00:05:23", toTime: "00:15:10", note: "NodeJS presentation" },23 * { fromTime: "00:15:10", toTime: "00:16:12" },24 * { fromTime: "00:16:12", toTime: "00:24:39", note: "NodeJS concepts" },25 * { fromTime: "00:24:39", toTime: "00:26:12" },26 * { fromTime: "00:26:12", toTime: "00:51:02", note: "Installation" },27 * { fromTime: "00:51:02", toTime: "00:53:55", note: "Execution" },28 * { fromTime: "00:53:55", toTime: "01:01:48" },29 * { fromTime: "01:01:48", toTime: "01:07:29", note: "Livereloading" }30 * { fromTime: "01:07:29", toTime: "01:33:12" },31 * ]32 */...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/utils/time');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 console.log(await page.evaluate(() => toTime(1000)));8 await page.close();9 await context.close();10 await browser.close();11})();12toTime(milliseconds)13{number}s14const { toTime } = require('playwright/lib/utils/time');15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 console.log(await page.evaluate(() => toTime(1000)));21 await page.close();22 await context.close();23 await browser.close();24})();25const { toTime } = require('playwright/lib/utils/time');26const { chromium } = require('playwright');27(async () => {28 const browser = await chromium.launch();29 const context = await browser.newContext();30 const page = await context.newPage();31 console.log(await page.evaluate(() => toTime(2000)));32 await page.close();33 await context.close();34 await browser.close();35})();36const { toTime } = require('playwright

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { toTime } = require('playwright/lib/utils/utils');3(async () => {4 const browser = await playwright['chromium'].launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.waitForTimeout(toTime('1s'));8 await page.screenshot({ path: 'screenshot.png' });9 await browser.close();10})();11const playwright = require('playwright');12const { toTime } = require('playwright/lib/utils/utils');13(async () => {14 const browser = await playwright['chromium'].launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.waitForTimeout(toTime('1s'));18 await page.screenshot({ path: 'screenshot.png' });19 await browser.close();20})();21const playwright = require('playwright');22const { toTime } = require('playwright/lib/utils/utils');23(async () => {24 const browser = await playwright['chromium'].launch();25 const context = await browser.newContext();26 const page = await context.newPage();27 await page.waitForTimeout(toTime('1s'));28 await page.screenshot({ path: 'screenshot.png' });29 await browser.close();30})();31const playwright = require('playwright');32const { toTime } = require('playwright/lib/utils/utils');33(async () => {34 const browser = await playwright['chromium'].launch();35 const context = await browser.newContext();36 const page = await context.newPage();37 await page.waitForTimeout(toTime('1s'));38 await page.screenshot({ path: 'screenshot.png' });39 await browser.close();40})();41const playwright = require('playwright');42const { toTime } = require('playwright/lib/utils/utils');43(async () => {44 const browser = await playwright['chromium'].launch();45 const context = await browser.newContext();46 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('@playwright/test/lib/utils/timeUtils');2console.log(toTime(1000));3const { toTime } = require('@playwright/test/lib/utils/timeUtils');4console.log(toTime(1000));5const { toTime } = require('@playwright/test/lib/utils/timeUtils');6console.log(toTime(1000));7const { toTime } = require('@playwright/test/lib/utils/timeUtils');8console.log(toTime(1000));9const { toTime } = require('@playwright/test/lib/utils/timeUtils');10console.log(toTime(1000));11const { toTime } = require('@playwright/test/lib/utils/timeUtils');12console.log(toTime(1000));13const { toTime } = require('@playwright/test/lib/utils/timeUtils');14console.log(toTime(1000));15const { toTime } = require('@playwright/test/lib/utils/timeUtils');16console.log(toTime(1000));17const { toTime } = require('@playwright/test/lib/utils/timeUtils');18console.log(toTime(1000));19const { toTime } = require('@playwright/test/lib/utils/timeUtils');20console.log(toTime(1000));21const { toTime } = require('@playwright/test/lib/utils/timeUtils');22console.log(toTime(1000));23const { toTime } = require('@playwright/test/lib/utils/timeUtils');24console.log(toTime(1000));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/internal/converters');2console.log(toTime(1000));3console.log(toTime(1000, 'ms'));4console.log(toTime(1000, 's'));5console.log(toTime(1000, 'm'));6console.log(toTime(1000, 'h'));7console.log(toTime(1000, 'd'));8console.log(toTime(1000, 'w'));9console.log(toTime(1000, 'M'));10console.log(toTime(1000, 'y'));11console.log(toTime(1000, 'ms', 'ms'));12console.log(toTime(1000, 'ms', 's'));13console.log(toTime(1000, 'ms', 'm'));14console.log(toTime(

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/utils/time');2const { toTime } = require('playwright/lib/utils/time');3const { toTime } = require('playwright/lib/utils/time');4const { toTime } = require('playwright/lib/utils/time');5const { toTime } = require('playwright/lib/utils/time');6const { toTime } = require('playwright/lib/utils/time');7const { toTime } = require('playwright/lib/utils/time');8const { toTime } = require('playwright/lib/utils/time');9const { toTime } = require('playwright/lib/utils/time');10console.log(toTime(

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');2const time = toTime(1234);3console.log(time);4const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');5const time = toTime(1234, 2);6console.log(time);7const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');8const time = toTime(1234, 5);9console.log(time);10const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');11const time = toTime(1234, 10);12console.log(time);13const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');14const time = toTime(1234, 15);15console.log(time);16const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');17const time = toTime(1234, 20);18console.log(time);19const { toTime } = require('@playwright/test/lib/server/trace/common/traceModel');20const time = toTime(1234, 25);21console.log(time);22const { toTime } = require('@play

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/internal/page');2const { toTime } = require('playwright/lib/helper');3const { toTime } = require('playwright/lib/utils/utils');4const { toTime } = require('playwright/lib/utils/timeoutSettings');5const { toTime } = require('playwright/lib/utils/stackTrace');6const { toTime } = require('playwright/lib/utils/debugLogger');7const { toTime } = require('playwright/lib/utils/registry');8const { toTime } = require('playwright/lib/utils/progress');9const { toTime } = require('playwright/lib/utils/timeoutSettings');10const { toTime } = require('playwright/lib/utils/registry');11const { toTime } = require('playwright/lib/utils/registry');12const {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/utils/utils');2const page = await context.newPage();3 const startTime = Date.now();4 const endTime = Date.now();5 const duration = endTime - startTime;6 console.log(duration);7 await page.close();8const startTime = Date.now();9 const page = await context.newPage();10 const endTime = Date.now();11 const duration = endTime - startTime;12 console.log(duration);13 await page.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toTime } = require('playwright/lib/utils/utils');2If you want to use toTime() method in your own code, you can use the code from the link above. But if you want to use it in a Playwright test, then you need to do the following:3const { toTime } = require('playwright/lib/utils/utils');4const { toTime } = require('./utils');5const date = new Date();6const date = new Date();7const options = { year: 'numeric', month: 'long', day: 'numeric' };8console.log(new Intl.DateTimeFormat('en-US', options).format(date));9const date = new Date();10const options = { year: 'numeric', month: 'long', day: 'numeric' };

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful