How to use socksData method in Playwright Internal

Best JavaScript code snippet using playwright-internal

ViewSocks.js

Source:ViewSocks.js Github

copy

Full Screen

1import React, { Component } from 'react';2import CKEditor from 'ckeditor4-react';3import {connect} from 'react-redux';4import Notiflix from "notiflix";5import{6 setsocksitemname,7 setsocksgender,8 setsocksitemtype,9 setsocksbrand,10 setsockscompany,11 setsocksmanufacture,12 setsocksmarketer,13 setsocksreturnable,14 setsocksreturnabledays,15 setsockshsn,16 setsocksgst,17 setclearsocksitem18}19from './Actions/ActionType';20import GetApiCall from '../GetApi';21import PostApiCall from '../Api'22import moment from 'moment';23import { confirmAlert } from 'react-confirm-alert'; // Import24import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css25 26const ImgUpload =({27 onChange,28 src29 })=>30 <label htmlFor="photo-upload" className="custom-file-upload fas">31 <div className="img-wrap img-upload" >32 <img for="photo-upload" src={src} style={{width : '100%',height:'100%', borderRadius: '5%'}}/>33 </div>34 <input id="photo-upload" type="file" onChange={onChange}/> 35 </label>36class ViewSocks extends Component {37 constructor(props) {38 super(props)39 this.state = {40 PageTitle : '1',41 Page1 : 'Pending',42 Page2 : 'Pending',43 Page3 : 'Pending',44 Page4 : 'Pending',45 DecimalRegex : /^(\d*\.?\d{0,2}|\.\d{0,9})$/,46 NumRegex: /^[0-9]*$/,47 AlphaNumericRegex : /^[a-zA-Z0-9]*$/,48 EmailRegex : /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,49 UrlRegex : /^(https:\/\/www\.|https:\/\/www\.|https:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/,50 51 52 imagePreviewUrl: 'https://www.adcproductdesign.com/wp-content/uploads/2018/02/Realize-Icon-Blue.png',53 Returnable: [54 { value: "Yes", label: "Yes" },55 { value: "No", label: "No" },56 ],57 ReturnableDays:[58 59 {value:'1', label:'1'},60 {value:'2', label:'2'},61 {value:'3', label:'3'},62 {value:'4', label:'4'},63 {value:'5', label:'5'},64 {value:'6', label:'6'},65 {value:'7', label:'7'},66 {value:'8', label:'8'},67 {value:'9', label:'9'},68 {value:'10', label:'10'},69 {value:'11', label:'11'},70 {value:'12', label:'12'},71 {value:'13', label:'13'},72 {value:'14', label:'14'},73 {value:'15', label:'15'},74 {value:'16', label:'16'},75 {value:'17', label:'17'},76 {value:'18', label:'18'},77 {value:'19', label:'19'},78 {value:'20', label:'20'},{value:'21', label:'21'},{value:'22', label:'22'},{value:'23', label:'23'},{value:'24', label:'24'},{value:'25', label:'25'},79 {value:'26', label:'26'},{value:'27', label:'27'},{value:'28', label:'28'},{value:'29', label:'29'},{value:'30', label:'30'},80 81 ],82 GSTData:[],83 GenderData: [84 { value: "Male", label: "Male" },85 { value: "Female", label: "Female" },86 { value: "Unisex", label: "Unisex" }87 ],88 Branddata:[],89 Companydata:[],90 ManufactureData:[],91 MarketerData:[],92 Description:'',93 TypeData:[],94 isReturnable : true,95 IsVisible : false,96 EditAccessGranted : false,97 ApproveAccessGranted : false,98 CountryOfOrigin : 'India',99 CountryOrigindata : []100 }101 }102 componentDidMount() {103 const script = document.createElement("script");104 script.src = "/assets/js/pages/form-wizard.init.js";105 script.async = true;106 document.body.appendChild(script);107 Notiflix.Loading.Init({108 svgColor : '#507dc0'109 110 });111 this.props.setclearsocksitem()112 Notiflix.Loading.Dots('');113 var det = localStorage.getItem('SocksDetails')114 var SocksData = JSON.parse(det)115 116 // console.log(SocksData)117 new Promise( ( resolve, reject ) => {118 setTimeout( resolve, 1000 );119 } ).then( () => {120 this.setState( { 121 Description : SocksData.fld_description,122 SocksId:SocksData.fld_id,123 124 } );125 } );126 this.props.setsocksitemname(SocksData.fld_name)127 this.props.setsocksgender(SocksData.fld_gender)128 this.props.setsocksitemtype(SocksData.fld_typeid)129 this.props.setsocksbrand(SocksData.fld_brandid)130 this.props.setsockscompany(SocksData.fld_companyid)131 this.props.setsocksmanufacture(SocksData.fld_manufacturerid)132 this.props.setsocksmarketer(SocksData.fld_marketerid)133 this.props.setsocksreturnable(SocksData.fld_returnable)134 this.props.setsocksreturnabledays(SocksData.fld_returnabledays)135 this.props.setsockshsn(SocksData.fld_hsncode)136 this.props.setsocksgst(SocksData.fld_gstpercent)137 138 if(SocksData.fld_returnable == 'No'){139 this.setState({140 isReturnable : false141 })142 }else143 {144 this.setState({145 isReturnable : true146 })147 }148 149 150 GetApiCall.getRequest("GetGstData").then(resultdes =>151 resultdes.json().then(objGst =>{152 // this.props.setsocksgst(objGst.data[0].value);153 this.setState({154 GSTData:objGst.data155 })156 }))157 GetApiCall.getRequest("GetCompany").then(resultdes =>158 resultdes.json().then(objcompany =>{159 // this.props.setsockscompany(objcompany.data[0].value);160 this.setState({161 Companydata:objcompany.data,162 ManufactureData:objcompany.data,163 MarketerData:objcompany.data164 })165 }))166 GetApiCall.getRequest("GetBrandData").then(resultdes =>167 resultdes.json().then(objbrand => {168 // this.props.setsocksbrand(objbrand.data[0].value);169 170 this.setState({171 Branddata : objbrand.data,172 173 })174 }))175 GetApiCall.getRequest("GetSocksTypeMaster").then(resultdes =>176 resultdes.json().then(objtype => {177 // this.props.setsocksitemtype(objtype.data[0].value);178 179 this.setState({180 TypeData : objtype.data,181 182 })183 // Notiflix.Loading.Remove()184 }))185 GetApiCall.getRequest("GetCountry").then(resultdes =>186 resultdes.json().then(obj => {187 188 this.setState({189 CountryOrigindata : obj.data ,190 CountryOfOrigin : SocksData.fld_countryoforigin == null || SocksData.fld_countryoforigin == '' ? 'India' : SocksData.fld_countryoforigin191 192 })193 194 }))195 var login=localStorage.getItem('LoginDetail');196 var details=JSON.parse(login)197 PostApiCall.postRequest({198 199 staffid : details[0].fld_staffid,200 201 },"GetUserSubMenuAccessRights").then((resultssub) => 202 203 // const objs = JSON.parse(result._bodyText)204 resultssub.json().then(objsub => { 205 if(resultssub.status == 200 || resultssub.status==201){206 var filteredRights = objsub.data;207 // console.log(filteredRights)208 209 var con = 0210 for(var i = 0 ; i< filteredRights.length ;i++){211 212 if(filteredRights[i].fld_menuname == 'Edit Socks'){213 214 if(filteredRights[i].fld_access == 1){215 this.setState({216 EditAccessGranted : true217 })218 }219 }else if(filteredRights[i].fld_menuname == 'Approve Socks'){220 221 if(filteredRights[i].fld_access == 1){222 this.setState({223 ApproveAccessGranted : true224 })225 }226 }227 228 con = con + 1229 if(con == filteredRights.length){230 Notiflix.Loading.Remove();231 }232 }233 234 }235 }))236 }237 photoUpload = e =>{238 e.preventDefault();239 const reader = new FileReader();240 const file = e.target.files[0];241 reader.onloadend = () => {242 this.setState({243 file: file,244 imagePreviewUrl: reader.result245 });246 }247 reader.readAsDataURL(file);248 }249 250 onChangeItem(itemname){251 this.props.setsocksitemname(itemname.target.value)252 }253 onChangeGender(gender){254 this.props.setsocksgender(gender.target.value)255 }256 onChangeType(type){257 this.props.setsocksitemtype(type.target.value)258 }259 onChangeBrand(brand){260 this.props.setsocksbrand(brand.target.value)261 }262 onChangeCompany(companyname){263 this.props.setsockscompany(companyname.target.value)264 }265 onchangeManufact(manufacturename){266 this.props.setsocksmanufacture(manufacturename.target.value)267 }268 onChangeMark(marketername){269 this.props.setsocksmarketer(marketername.target.value)270 }271 onChangeReturn(returnable){272 if(returnable.target.value == 'No'){273 this.setState({274 isReturnable : false275 })276 this.props.setsocksreturnabledays(0)277 }else278 {279 this.setState({280 isReturnable : true281 })282 this.props.setsocksreturnabledays('1')283 }284 this.props.setsocksreturnable(returnable.target.value)285 }286 onChangeReturnday(returnableday){287 this.props.setsocksreturnabledays(returnableday.target.value)288 }289 onChangeHsn(hsncode){290 if(this.state.AlphaNumericRegex.test(hsncode.target.value)){291 this.props.setsockshsn((hsncode.target.value))292 }293 }294 onChangeGst(gst){295 this.props.setsocksgst(gst.target.value)296 297 }298 299 nextlabel(){300 if(this.props.sockscredential.ItemName!=''){301 if(this.props.sockscredential.ItemName.length < 160){302 if(this.props.sockscredential.Gender!=''){303 if(this.props.sockscredential.Type!=''){304 if(this.props.sockscredential.Brand!=''){305 if(this.props.sockscredential.CompanyName!=''){306 307 this.setState({308 PageTitle: '2',309 Page1: 'Done'310 })311 312 }313 else{314 Notiflix.Notify.Failure('Please select company name.')315 } 316 }317 else{318 Notiflix.Notify.Failure('Please select brand name.')319 }320 }321 else{322 Notiflix.Notify.Failure('Please select socks type')323 }324 325 }326 else{327 Notiflix.Notify.Failure('Please select gender.')328 }329 }330 else{331 Notiflix.Notify.Failure('Please enter socks item name with less then 160 characters.')332 }333 }334 else{335 Notiflix.Notify.Failure('Please enter socks item name.')336 }337 338 }339 340 onChangeDescription(description){341 this.setState({Description:description.editor.getData()})342 }343 344 nextlabel2(){345 if(this.state.Description!=''){346 347 this.setState({348 PageTitle : '3',349 Page2 : 'Done'350 })351 }352 else{353 Notiflix.Notify.Failure('Please enter socks item description.')354 }355 }356 SaveSocks(){357 if(this.props.sockscredential.HSNCode!=''){358 359 var login=localStorage.getItem('LoginDetail');360 var details=JSON.parse(login)361 Notiflix.Loading.Dots('');362 363 PostApiCall.postRequest({364 id:this.state.SocksId,365 name : this.props.sockscredential.ItemName,366 brandid :this.props.sockscredential.Brand,367 companyid : this.props.sockscredential.CompanyName,368 manufacturerid : this.props.sockscredential.ManufactureName,369 marketerid : this.props.sockscredential.MarketerName,370 typeid : this.props.sockscredential.Type,371 gender : this.props.sockscredential.Gender,372 description : this.state.Description,373 reutrnable : this.props.sockscredential.Returnable,374 returnabledays : this.props.sockscredential.ReturnableDays,375 hsncode : this.props.sockscredential.HSNCode,376 gstpercent :this.props.sockscredential.GstRate,377 approved : 'No',378 updatedon : moment().format('lll'),379 updatedby : details[0].fld_staffid,380 countryoforigin : this.state.CountryOfOrigin381 382 },"UpdateSocksItemMaster").then((results) => 383 384 385 // const objs = JSON.parse(result._bodyText)386 results.json().then(obj => {387 388 389 if(results.status == 200 || results.status==201){390 this.props.setclearsocksitem()391 Notiflix.Loading.Remove()392 Notiflix.Notify.Success('Socks ttem successfully updated.')393 window.location.href = '/socksitemmasterlist'394 395 }396 else{397 Notiflix.Loading.Remove()398 Notiflix.Notify.Failure('Something went wrong. try again later.')399 } 400 }401 )402 )403 404 }405 else{406 Notiflix.Notify.Failure('Please enter HSN code.')407 }408 }409 410 ApproveSocks(){411 if(this.state.ApproveAccessGranted){412 413 confirmAlert({414 title: 'Confirm to Approve',415 message: 'Are you sure you want to approve socks.',416 buttons: [417 {418 label: 'Yes',419 onClick: () => {420 Notiflix.Loading.Dots('');421 422 var login=localStorage.getItem('LoginDetail');423 var details=JSON.parse(login)424 425 426 PostApiCall.postRequest({427 428 id:this.state.SocksId,429 approved : 'Yes',430 updatedby : details[0].fld_staffid,431 updatedon : moment().format('lll'),432 433 434 },"UpdateSocksItemMasterApprovalStatus").then((results) => 435 436 // const objs = JSON.parse(result._bodyText)437 results.json().then(obj => {438 439 if(results.status == 200 || results.status==201){440 441 Notiflix.Loading.Remove()442 Notiflix.Notify.Success('Socks ttem successfully updated.')443 window.location.href = '/socksitemmasterlist'444 }else445 {446 Notiflix.Loading.Remove()447 Notiflix.Notify.Failure('Something went wrong, try again later.')448 }449 }))450 }451 },452 {453 label: 'No',454 // onClick: () => alert('Click No')455 }456 ]457 });458 }else{459 Notiflix.Notify.Failure('You are not authorised to continue.'); 460 }461 }462 463 render() {464 return (465 <div className="App">466 <div id="wrapper">467 <div className="content-page">468 <div class="content">469 <div className="container-fluid">470 <div className="row page-title">471 <div className="col-md-12">472 <nav aria-label="breadcrumb" class="float-right mt-1">473 <ol class="breadcrumb">474 <li class="breadcrumb-item"><a href="#">Product Management</a></li>475 <li class="breadcrumb-item"><a href="/">Socks List</a></li>476 477 <li class="breadcrumb-item active" aria-current="page">View Socks</li>478 </ol>479 </nav>480 <h4 class="mb-1 mt-0">View Socks Item</h4>481 </div>482 </div>483 <div class="row" style={{display : this.state.EditAccessGranted || this.state.ApproveAccessGranted ? '' : 'none'}}>484 <div class="col-12">485 <div class="card">486 <div class="card-body">487 <div class="row align-items-center col-lg-5" style={{float : 'right'}}>488 <div class="col text-right row " >489 <div style={{display : this.state.ApproveAccessGranted ? '' : 'none'}}>490 <button 491 style={{marginRight : '10px'}}492 onClick={this.ApproveSocks.bind(this)}493 class="btn btn-primary" id="btn-new-event" data-toggle="modal"><i494 class="uil-check mr-1"></i>Approve Socks </button>495 </div>496 <div style={{display : this.state.EditAccessGranted ? '' : 'none'}}>497 <button 498 onClick={()=>{499 this.setState({IsVisible : true})500 501 }}502 class="btn btn-primary" id="btn-new-event" data-toggle="modal"><i503 class="uil-edit mr-1"></i>Edit Socks Details</button>504 </div>505 {/* </div>506 <div class="col text-right" style={{display : this.state.ApproveAccessGranted ? '' : 'none'}}> */}507 508 </div>509 </div>510 </div>511 </div> 512 </div>513 514 </div>515 <div className="row">516 <div className="col-lg-12">517 <div className="card">518 <div className="card-body">519 <div id="smartwizard-arrows">520 <ul>521 <li className={this.state.PageTitle == '1' ? 'active nav-item' : this.state.Page1 == 'Done' ? 'done nav-item' : ''}><a onClick={() => {522 this.setState({523 PageTitle: '1',524 Page1: 'Done'525 })526 }} class="wizardlist nav-link">Socks Item Information</a></li>527 <li className={this.state.PageTitle == '2' ? 'active nav-item' : this.state.Page2 == 'Done' ? 'done nav-item' : ''}><a onClick={() => {528 if (this.state.Page2 == 'Done') {529 this.setState({530 PageTitle: '2',531 Page2: 'Done',532 })533 }534 }}535 class="wizardlist nav-link">Description</a></li>536 <li className={this.state.PageTitle == '3' ? 'active nav-item' : this.state.Page3 == 'Done' ? 'done nav-item' : ''}><a onClick={() => {537 if (this.state.Page3 == 'Done') {538 this.setState({539 PageTitle: '3',540 Page3: 'Done',541 542 })543 }544 }}545 class="wizardlist nav-link">GST & Return</a></li>546 547 548 </ul>549 <div className="p-3" style={{ minHeight: '0px' }}>550 <div id="sw-arrows-step-1"551 className="tab-pane step-content"552 style={{ display: this.state.PageTitle == '1' ? 'block' : 'none' }}553 >554 <form className="needs-validation" novalidate onSubmit={(e) => {555 e.preventDefault()556 }}>557 <div className="toast fade show" role="alert" aria-live="assertive"558 aria-atomic="true" data-toggle="toast">559 <div class="toast-header">560 <strong class="mr-auto">Socks Item Information</strong>561 </div>562 <div class="toast-body">563 <div class="row">564 <div class="col-md-12">565 <div class="row">566 567 <div class="col-md-12">568 <div class="form-group mb-2">569 <label for="validationCustom05">Item Name(160 Character)<span className="mandatory">*</span></label>570 <input type="text" class="form-control" id="validationCustom05"571 value={this.props.sockscredential.ItemName}572 disabled={!this.state.IsVisible}573 onChange={this.onChangeItem.bind(this)}574 />575 576 </div>577 </div> 578 <div class="col-md-6">579 <div class="form-group">580 <label for="sw-arrows-first-name" >Gender<span className="mandatory">*</span></label>581 582 <select class="form-control custom-select"583 disabled={!this.state.IsVisible}584 value={this.props.sockscredential.Gender}585 onChange={this.onChangeGender.bind(this)}>586 {this.state.GenderData.map(gender => (587 588 <option key={gender.value} value={gender.value}>589 {gender.label}590 </option>591 ))}592 593 </select>594 </div>595 </div>596 <div class="col-md-6">597 <div class="form-group">598 <label for="sw-arrows-first-name" >Type<span className="mandatory">*</span></label>599 600 <select class="form-control custom-select"601 disabled={!this.state.IsVisible}602 value={this.props.sockscredential.Type} 603 onChange={this.onChangeType.bind(this)}>604 {this.state.TypeData.map(type => (605 606 <option key={type.value} value={type.value}>607 {type.label}608 </option>609 ))}610 611 </select>612 </div>613 </div>614 <div class="col-md-6">615 <div class="form-group">616 <label for="sw-arrows-first-name" >Brand<span className="mandatory">*</span></label>617 618 <select class="form-control custom-select"619 disabled={!this.state.IsVisible}620 value={this.props.sockscredential.Brand}621 onChange={this.onChangeBrand.bind(this)} >622 {this.state.Branddata.map(brand => (623 624 <option key={brand.value} value={brand.value}>625 {brand.label}626 </option>627 ))}628 </select>629 </div>630 </div>631 632 <div class="col-md-6">633 <div class="form-group">634 <label for="sw-arrows-first-name" >Company Name<span className="mandatory">*</span></label>635 636 <select class="form-control custom-select" 637 disabled={!this.state.IsVisible}638 value={this.props.sockscredential.CompanyName}639 onChange={this.onChangeCompany.bind(this)}>640 {this.state.Companydata.map(company =>(641 <option key={company.value} value={company.value}>642 {company.label}643 </option>644 ))}645 646 </select>647 </div>648 </div>649 650 <div class="col-md-4">651 <div class="form-group">652 <label for="sw-arrows-first-name" >Manufacturer Name</label>653 654 <select class="form-control custom-select"655 disabled={!this.state.IsVisible}656 value={this.props.sockscredential.ManufactureName}657 onChange={this.onchangeManufact.bind(this)}>658 <option value={0}></option>659 {this.state.ManufactureData.map(manufacture =>(660 <option key={manufacture.value} value={manufacture.value}>661 {manufacture.label}662 </option>663 ))}664 </select>665 </div>666 </div>667 <div class="col-md-4">668 <div class="form-group">669 <label for="sw-arrows-first-name" >Marketer Name</label>670 671 <select class="form-control custom-select"672 disabled={!this.state.IsVisible}673 value={this.props.sockscredential.MarketerName}674 onChange={this.onChangeMark.bind(this)}>675 <option value={0}></option>676 {this.state.MarketerData.map(marketername =>(677 <option key={marketername.value} value={marketername.value}>678 {marketername.label}679 </option>680 ))}681 </select>682 </div>683 </div>684 <div class="col-md-4">685 <div class="form-group">686 <label for="sw-arrows-first-name" >Country of Origin <span className="mandatory">*</span></label>687 688 <select class="form-control custom-select"689 disabled={!this.state.IsVisible}690 value={this.state.CountryOfOrigin}691 onChange={(text)=>{692 this.setState({693 CountryOfOrigin : text.target.value694 })695 }}>696 697 {this.state.CountryOrigindata.map(flavour =>(698 <option key={flavour.label} value={flavour.label}>699 {flavour.label}700 </option>701 ))}702 </select>703 </div>704 </div>705 706 </div>707 708 </div> {/* end col-md-12 */}709 710 </div>711 712 </div>713 714 </div>715 716 <div className="toast fade show" role="alert" aria-live="assertive"717 aria-atomic="true" data-toggle="toast">718 <div className="btn-toolbar sw-toolbar sw-toolbar-top justify-content-right" style={{ float: 'right' }}>719 <button className="btn btn-secondary sw-btn-prev btn-radius-right" disabled={true} >Previous</button>720 <button className="btn btn-secondary sw-btn-next btn-radius-left" 721 // onClick={() => {722 // this.setState({723 // PageTitle: '2',724 // Page1: 'Done'725 // })726 // }}727 onClick={this.nextlabel.bind(this)}>Next</button>728 </div>729 </div>730 </form>731 </div>732 <div id="sw-arrows-step-2"733 className="tab-pane step-content"734 style={{ display: this.state.PageTitle == '2' ? 'block' : 'none' }}>735 <div className="toast fade show" role="alert" aria-live="assertive"736 aria-atomic="true" data-toggle="toast">737 <div class="toast-header">738 <strong class="mr-auto">Description</strong>739 </div>740 <div class="toast-body">741 <div class="row">742 <div class="col-md-12">743 <div class="form-group">744 <label for="sw-arrows-first-name" >Description<span className="mandatory">*</span></label>745 746 <div class="niceeditors">747 <CKEditor748 config={{749 extraPlugins: "justify,font,colorbutton",750 }}751 disabled={!this.state.IsVisible}752 data={this.state.Description}753 onChange={this.onChangeDescription.bind(this)}754 755 />756 </div>757 </div>758 </div> 759 760 761 </div>762 763 </div>764 </div>765 <div className="toast fade show" role="alert" aria-live="assertive"766 aria-atomic="true" data-toggle="toast">767 <div className='row'>768 769 <div className="col-md-12">770 <div className="btn-toolbar sw-toolbar sw-toolbar-top justify-content-right" style={{ float: 'right' }}>771 <button className="btn btn-secondary sw-btn-prev btn-radius-right" 772 onClick={()=>{773 774 this.setState({775 PageTitle : '1',776 Page2 : 'Done'777 })778 }}779 >Previous</button>780 <button className="btn btn-secondary sw-btn-next btn-radius-left" 781 // onClick={()=>{782 783 // this.setState({784 // PageTitle : '3',785 // Page2 : 'Done'786 // })787 // }}788 onClick={this.nextlabel2.bind(this)} >Next</button>789 </div>790 </div>791 </div>792 </div>793 </div> {/* Sw-arrow 2*/}794 <div id="sw-arrows-step-3"795 className="tab-pane step-content"796 style={{ display: this.state.PageTitle == '3' ? 'block' : 'none' }}>797 <div className="toast fade show" role="alert" aria-live="assertive"798 aria-atomic="true" data-toggle="toast">799 <div class="toast-header">800 <strong class="mr-auto">GST & Return</strong>801 </div>802 803 <div className="toast fade show" role="alert" aria-live="assertive"804 aria-atomic="true" data-toggle="toast">805 806 <div class="toast-body">807 <div class="row">808 809 810 <div className="col-md-3">811 <div class="form-group">812 <label for="sw-arrows-first-name" >Returnable<span className="mandatory">*</span></label>813 814 <select class="form-control custom-select"815 disabled={!this.state.IsVisible}816 value={this.props.sockscredential.Returnable}817 onChange={this.onChangeReturn.bind(this)}>818 {this.state.Returnable.map(returnable => (819 820 <option key={returnable.value} value={returnable.value}>821 {returnable.label}822 </option>823 ))}824 825 </select>826 </div>827 </div>828 <div className="col-md-3" style={{display : this.state.isReturnable ? '' : 'none'}}>829 <div class="form-group">830 <label for="sw-arrows-first-name" >Returnable Days<span className="mandatory">*</span></label>831 832 <select class="form-control custom-select"833 disabled={!this.state.IsVisible}834 value={this.props.sockscredential.ReturnableDays}835 onChange={this.onChangeReturnday.bind(this)}>836 {this.state.ReturnableDays.map(returnabledays => (837 838 <option key={returnabledays.value} value={returnabledays.value}>839 {returnabledays.label}840 </option>841 ))}842 843 </select>844 </div>845 </div>846 <div class="col-md-3">847 <div class="form-group mb-2">848 <label for="validationCustom05">HSN Code<span className="mandatory">*</span></label>849 <input type="text" class="form-control" id="validationCustom05"850 disabled={!this.state.IsVisible}851 value={this.props.sockscredential.HSNCode}852 onChange={this.onChangeHsn.bind(this)}853 />854 855 </div>856 </div>857 <div class="col-md-3">858 <div class="form-group mb-2">859 <label for="validationCustom05">GST Rate(%)<span className="mandatory">*</span></label>860 861 <select class="form-control custom-select"862 disabled={!this.state.IsVisible}863 value={this.props.sockscredential.GstRate}864 onChange={this.onChangeGst.bind(this)} >865 { this.state.GSTData.map(gst => (866 <option key={gst.value} value={gst.value}>867 {gst.label}868 </option>869 ))}870 871 </select>872 873 </div>874 </div> 875 876 </div>877 878 </div>879 </div>880 </div> 881 <div className="toast fade show" role="alert" aria-live="assertive"882 aria-atomic="true" data-toggle="toast">883 <div className='row'>884 885 <div className="col-md-12">886 <div className="btn-toolbar sw-toolbar sw-toolbar-top justify-content-right" style={{ float: 'right' }}>887 <button className="btn btn-secondary sw-btn-prev btn-radius-right"888 onClick={() => {889 this.setState({890 PageTitle: '2',891 Page2: 'Done'892 })893 }}894 >Previous</button>895 <button className="btn btn-secondary sw-btn-next btn-radius-left"896 disabled={!this.state.IsVisible} 897 // onClick={()=>{898 899 // this.setState({900 // PageTitle : '4',901 // Page3 : 'Done'902 // })903 // }}904 onClick={this.SaveSocks.bind(this)} >Update Socks Item</button>905 </div>906 </div>907 </div>908 </div>909 </div>910 911 </div>912 </div>913 </div>914 </div>915 </div>916 </div>917 </div>918 </div>919 </div>920 </div>921 </div>922 );923 }924}925function mapStateToProps(state){926 return{927 sockscredential: state.SocksItemReducers928 }929 }930 export default connect(mapStateToProps, {931 setsocksitemname,932 setsocksgender,933 setsocksitemtype,934 setsocksbrand,935 setsockscompany,936 setsocksmanufacture,937 setsocksmarketer,938 setsocksreturnable,939 setsocksreturnabledays,940 setsockshsn,941 setsocksgst,942 setclearsocksitem943 ...

Full Screen

Full Screen

Products.js

Source:Products.js Github

copy

Full Screen

1import React, { Component, Fragment, useEffect, useState } from 'react'2import Notiflix from "notiflix";3import DatePicker from "react-datepicker";4import "react-datepicker/dist/react-datepicker.css";5import ProductsGrids from './ProductsGrids'6import ProductsExtraGrids from './ProductsExtraGrids'7import GetApiCall from '../GetApi';8import ReactHTMLTableToExcel from 'react-html-table-to-excel';9import moment from 'moment'10export default function Products() {11 const [FootsData, setFootsData] = useState([])12 const [FoodData, setFoodData] = useState([])13 const [SocksData, setSockssData] = useState([])14 const [state, setState] = useState({15 status:"No Status Selected",16 statusValue:"No Status Selected",17 category:"No Category Selected",18 categoryValue:"No Category Selected",19 20 proData:[],21 startDate:null,22 endDate:null,23 extractData:false24 25 26 })27const Dropdown=() =>{28 29 return(30 <div className="btn-group mt-2">31 32 <button type="button" className="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">33 Select&nbsp;Report&nbsp;34 <i class="fa fa-chevron-down" aria-hidden="true"></i>35 <span className="sr-only">Toggle Dropdown</span>36 </button>37 <div className="dropdown-menu">38 <button onClick={()=>{setState({...state,extractData:false,statusValue:"All Items",status:"All Items"})}} className="dropdown-item bg-white text-dark" >All Items</button>39 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Fast Moving Items",status:"Fast Moving Items"})}} className="dropdown-item bg-white text-dark" >Fast Moving Items</button>40 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Non Moving Items",status:"Non Moving Items"})}} className="dropdown-item bg-white text-dark" >Non Moving Items</button>41 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Slow Moving Items",status:"Slow Moving Items"})}} className="dropdown-item bg-white text-dark" >Slow Moving Items</button>42 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Items Active On Website",status:"Items Active On Website"})}} className="dropdown-item bg-white text-dark" >Items Active On Website</button>43 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Items Not Approved",status:"Items Not Approved"})}} className="dropdown-item bg-white text-dark" >Items Not Approved</button>44 <button onClick={()=>{setState({...state,extractData:false,statusValue:"Items Approved",status:"Items Approved"})}} className="dropdown-item bg-white text-dark" >Items Approved</button>45 46 </div>47 </div>48 )49}50const Dropdown2=() =>{51 52 return(53 <div className="btn-group mt-2 mr-2">54 <button type="button" className="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">55 Select&nbsp;Product&nbsp;Category&nbsp;56 <i class="fa fa-chevron-down" aria-hidden="true"></i>57 <span className="sr-only">Toggle Dropdown</span>58 </button>59 <div className="dropdown-menu">60 <button onClick={()=>{setState({...state,extractData:false,categoryValue:"Food",category:"Food"})}} className="dropdown-item bg-white text-dark" >Food</button>61 <button onClick={()=>{setState({...state,extractData:false,categoryValue:"Footware",category:"Footware"})}} className="dropdown-item bg-white text-dark" >Footware</button>62 <button onClick={()=>{setState({...state,extractData:false,categoryValue:"Socks",category:"Socks"})}} className="dropdown-item bg-white text-dark" >Socks</button>63 64 </div>65 </div>66 )67}68const DatePickers=()=> {69 70 return (71 <>72 <li className='nav-item text-dark font-weight-bold mt-2 mr-1' style={{display:'flex'}}> 73 <span style={{marginTop:'9px'}}>From </span><DatePicker74 selected={state.startDate}75 dateFormat="MM/dd/yyyy"76 onChange={date =>setState({...state,startDate:date,extractData:false})}77 selectsStart78 startDate={state.startDate}79 endDate={state.endDate}80 maxDate={state.endDate?state.endDate:new Date()}81 popperModifiers={{82 offset: {83 enabled: true,84 offset: "5px, 10px"85 }}}86 isClearable87 className="form-date-picker"88 />89 </li>90 <li className='nav-item text-dark font-weight-bold mt-2 mr-1' style={{display:'flex'}}>91 <span style={{marginTop:'9px'}}>To </span>92 <DatePicker93 selected={state.endDate}94 dateFormat="MM/dd/yyyy"95 onChange={date =>setState({...state,endDate:date,extractData:false})}96 selectsEnd97 startDate={state.startDate}98 endDate={state.endDate}99 minDate={state.startDate}100 maxDate={new Date()}101 popperModifiers={{102 offset: {103 enabled: true,104 offset: "5px, 10px"105 }}}106 isClearable107 className="form-date-picker"108 /> 109 110 111 112 </li>113 </>114 )115}116const getReportHandler=()=>{117 if(state.statusValue==="No Status Selected"&&state.categoryValue==='No Category Selected'){118 setState({...state,extractData:false})119 120 return Notiflix.Notify.Failure('Select Report And Select Category');121 122 }123 124 if(state.statusValue==="No Status Selected"&&state.categoryValue!=='No Category Selected'){125 setState({...state,extractData:false})126 127 return Notiflix.Notify.Failure('Select Report');128 }129 if(state.statusValue!=="No Status Selected"&&state.categoryValue==='No Category Selected'){130 setState({...state,extractData:false})131 132 return Notiflix.Notify.Failure('Select Category');133 }134 if(state.startDate===null&&state.endDate===null){135 setState({...state,extractData:true})136 137 138 139 }140 if(state.startDate!==null&&state.endDate!==null){141 setState({...state,extractData:true})142 143 144 }145 if(state.startDate!==null&&state.endDate===null){146 setState({...state,extractData:false})147 return Notiflix.Notify.Failure('Enter "To" Date ');148 }149 if(state.startDate===null&&state.endDate!==null){150 setState({...state,extractData:false})151 return Notiflix.Notify.Failure('Enter "Start" Date ');152 153 154 }155 else{156 Notiflix.Loading.Init({157 svgColor : '#507dc0'158 159 });160 161 162 Notiflix.Loading.Dots('Please wait...');163 164 165 GetApiCall.getRequest("GetSocksProductDataReports").then(resultdes =>166 resultdes.json().then(obj => {167 setSockssData(obj.data)168 169 Notiflix.Loading.Remove()170 // console.log(obj.data)171 }))172 GetApiCall.getRequest("GetFootwearProductDataReports").then(resultdes =>173 resultdes.json().then(obj => {174 setFootsData(obj.data)175 176 Notiflix.Loading.Remove()177 // console.log(obj.data)178 }))179 GetApiCall.getRequest("GetFoodProductDataReports").then(resultdes =>180 resultdes.json().then(obj => {181 setFoodData(obj.data)182 183 Notiflix.Loading.Remove()184 // console.log(obj.data)185 }))186 return setState({...state,extractData:true})187 188 }189 190 191 192 }193 194 195 const DataTable=()=>{196 let ProductData=[]197 if(state.categoryValue==="Food"){198 if(state.statusValue==="All Items"){199 if(state.startDate!==null&&state.endDate!==null){200 ProductData=FoodData.filter(product=>{201 console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));202 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))){203 204 205 return product206 }207 208 209 }210 211 )212 213 }214 else{215 ProductData=FoodData216 }217 218 } 219 else if(state.statusValue==="Fast Moving Items"){220 221 if(state.startDate!==null&&state.endDate!==null){222 ProductData=FoodData.filter(product=>{223 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));224 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>=5){225 226 return product227 }228 229 230 }231 232 )233 234 } 235 else{236 ProductData=FoodData.filter(product=>{237 if(product.fld_itemordercount>=5){238 return product239 }240 })241 }242 243 244 245 }246 else if(state.statusValue==="Non Moving Items"){247 248 if(state.startDate!==null&&state.endDate!==null){249 ProductData=FoodData.filter(product=>{250 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));251 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount<=0){252 253 return product254 }255 256 257 }258 259 )260 261 } 262 else{263 ProductData=FoodData.filter(product=>{264 if(product.fld_itemordercount<=0){265 return product266 }267 })268 }269 270 271 272 }273 else if(state.statusValue==="Slow Moving Items"){274 275 if(state.startDate!==null&&state.endDate!==null){276 ProductData=FoodData.filter(product=>{277 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));278 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>0&&product.fld_itemordercount<5){279 280 return product281 }282 283 284 }285 286 )287 288 } 289 else{290 ProductData=FoodData.filter(product=>{291 if(product.fld_itemordercount>0&&product.fld_itemordercount<5){292 return product293 }294 })295 }296 297 298 299 }300 else if(state.statusValue==="Items Active On Website"){301 302 if(state.startDate!==null&&state.endDate!==null){303 ProductData=FoodData.filter(product=>{304 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));305 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_showonwebsite==='Yes'){306 307 return product308 }309 310 311 }312 313 )314 315 } 316 else{317 ProductData=FoodData.filter(product=>{318 if(product.fld_showonwebsite==='Yes'){319 return product320 }321 })322 }323 324 325 326 }327 else if(state.statusValue==="Items Not Approved"){328 329 if(state.startDate!==null&&state.endDate!==null){330 ProductData=FoodData.filter(product=>{331 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));332 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='No'){333 334 return product335 }336 337 338 }339 340 )341 342 } 343 else{344 ProductData=FoodData.filter(product=>{345 if(product.fld_approved==='No'){346 return product347 }348 })349 }350 351 352 353 }354 else if(state.statusValue==="Items Approved"){355 356 if(state.startDate!==null&&state.endDate!==null){357 ProductData=FoodData.filter(product=>{358 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));359 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='Yes'){360 361 return product362 }363 364 365 }366 367 )368 369 } 370 else{371 ProductData=FoodData.filter(product=>{372 if(product.fld_approved==='Yes'){373 return product374 }375 })376 }377 378 379 380 }381 382 }383 384 385 if(state.categoryValue==="Footware"){386 if(state.statusValue==="All Items"){387 if(state.startDate!==null&&state.endDate!==null){388 ProductData=FootsData.filter(product=>{389 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));390 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))){391 392 393 return product394 }395 396 397 }398 399 )400 401 }402 else{403 ProductData=FootsData404 }405 406 } 407 else if(state.statusValue==="Fast Moving Items"){408 409 if(state.startDate!==null&&state.endDate!==null){410 ProductData=FootsData.filter(product=>{411 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));412 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>=5){413 414 return product415 }416 417 418 }419 420 )421 422 } 423 else{424 ProductData=FootsData.filter(product=>{425 if(product.fld_itemordercount>=5){426 return product427 }428 })429 }430 431 432 433 }434 else if(state.statusValue==="Non Moving Items"){435 436 if(state.startDate!==null&&state.endDate!==null){437 ProductData=FootsData.filter(product=>{438 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));439 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount<=0){440 441 return product442 }443 444 445 }446 447 )448 449 } 450 else{451 ProductData=FootsData.filter(product=>{452 if(product.fld_itemordercount<=0){453 return product454 }455 })456 }457 458 459 460 }461 else if(state.statusValue==="Slow Moving Items"){462 463 if(state.startDate!==null&&state.endDate!==null){464 ProductData=FootsData.filter(product=>{465 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));466 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>0&&product.fld_itemordercount<5){467 468 return product469 }470 471 472 }473 474 )475 476 } 477 else{478 ProductData=FootsData.filter(product=>{479 if(product.fld_itemordercount>0&&product.fld_itemordercount<5){480 return product481 }482 })483 }484 485 486 487 }488 else if(state.statusValue==="Items Active On Website"){489 490 if(state.startDate!==null&&state.endDate!==null){491 ProductData=FootsData.filter(product=>{492 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));493 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_showonwebsite==='Yes'){494 495 return product496 }497 498 499 }500 501 )502 503 } 504 else{505 ProductData=FootsData.filter(product=>{506 if(product.fld_showonwebsite==='Yes'){507 return product508 }509 })510 }511 512 513 514 }515 else if(state.statusValue==="Items Not Approved"){516 517 if(state.startDate!==null&&state.endDate!==null){518 ProductData=FootsData.filter(product=>{519 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));520 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='No'){521 522 return product523 }524 525 526 }527 528 )529 530 } 531 else{532 ProductData=FootsData.filter(product=>{533 if(product.fld_approved==='No'){534 return product535 }536 })537 }538 539 540 541 }542 else if(state.statusValue==="Items Approved"){543 544 if(state.startDate!==null&&state.endDate!==null){545 ProductData=FootsData.filter(product=>{546 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));547 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='Yes'){548 549 return product550 }551 552 553 }554 555 )556 557 } 558 else{559 ProductData=FootsData.filter(product=>{560 if(product.fld_approved==='Yes'){561 return product562 }563 })564 }565 566 567 568 }569 570 }571 if(state.categoryValue==="Socks"){572 if(state.statusValue==="All Items"){573 if(state.startDate!==null&&state.endDate!==null){574 ProductData=SocksData.filter(product=>{575 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));576 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))){577 578 579 return product580 }581 582 583 }584 585 )586 587 }588 else if(state.startDate===null&&state.endDate===null){589 ProductData=SocksData590 }591 592 } 593 else if(state.statusValue==="Fast Moving Items"){594 595 if(state.startDate!==null&&state.endDate!==null){596 ProductData=SocksData.filter(product=>{597 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));598 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>=5){599 600 return product601 }602 603 604 }605 606 )607 608 } 609 else if(state.startDate===null&&state.endDate===null){610 ProductData=SocksData.filter(product=>{611 if(product.fld_itemordercount>=5){612 return product613 }614 })615 }616 617 618 619 }620 else if(state.statusValue==="Non Moving Items"){621 622 if(state.startDate!==null&&state.endDate!==null){623 ProductData=SocksData.filter(product=>{624 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));625 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount<=0){626 627 return product628 }629 630 631 }632 633 )634 635 } 636 else if(state.startDate===null&&state.endDate===null){637 ProductData=SocksData.filter(product=>{638 if(product.fld_itemordercount<=0){639 return product640 }641 })642 }643 644 645 646 }647 else if(state.statusValue==="Slow Moving Items"){648 649 if(state.startDate!==null&&state.endDate!==null){650 ProductData=SocksData.filter(product=>{651 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));652 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_itemordercount>0&&product.fld_itemordercount<5){653 654 return product655 }656 657 658 }659 660 )661 662 } 663 else if(state.startDate===null&&state.endDate===null){664 ProductData=SocksData.filter(product=>{665 if(product.fld_itemordercount>0&&product.fld_itemordercount<5){666 return product667 }668 })669 }670 671 672 673 }674 else if(state.statusValue==="Items Active On Website"){675 676 if(state.startDate!==null&&state.endDate!==null){677 ProductData=SocksData.filter(product=>{678 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));679 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_showonwebsite==='Yes'){680 681 return product682 }683 684 685 }686 687 )688 689 } 690 else if(state.startDate===null&&state.endDate===null){691 ProductData=SocksData.filter(product=>{692 if(product.fld_showonwebsite==='Yes'){693 return product694 }695 })696 }697 698 699 700 }701 else if(state.statusValue==="Items Not Approved"){702 703 if(state.startDate!==null&&state.endDate!==null){704 ProductData=SocksData.filter(product=>{705 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));706 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='No'){707 708 return product709 }710 711 712 }713 714 )715 716 } 717 else if(state.startDate===null&&state.endDate===null){718 ProductData=SocksData.filter(product=>{719 if(product.fld_approved==='No'){720 return product721 }722 })723 }724 725 726 727 }728 else if(state.statusValue==="Items Approved"){729 730 if(state.startDate!==null&&state.endDate!==null){731 ProductData=SocksData.filter(product=>{732 // console.log(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll')));733 if(moment(moment(product.fld_updatedon).format('ll')).isBetween(moment(state.startDate).format('ll'),moment(state.endDate).format('ll'))&&product.fld_approved==='Yes'){734 735 return product736 }737 738 739 }740 741 )742 743 } 744 else if(state.startDate===null&&state.endDate===null){745 ProductData=SocksData.filter(product=>{746 if(product.fld_approved==='Yes'){747 return product748 }749 })750 }751 752 753 754 }755 756 }757 758 if(state.extractData===false){759 return(760 <div class="row">761 <div class="col col-12">762 763 764 </div>765 </div>766 )767 }768 return(769 <table id="table-to-xls" className="table table-hover table-nowrap mb-0 table-responsive">770 {state.extractData===true&&ProductData.length===0? <div class="row">771 <div class="col col-12">772 <div class="card visually-view">773 <div class="card-body">774 <div class="jumbotron bg-light">775 <h2 class="display-4">No Product Reports Present </h2>776 777 778 </div>779 780 </div>781 </div>782 </div>783 </div>:<Fragment>784 785 <div class="row">786 <div class="col-12">787 <div class="card visually-view">788 <div class="card-body">789 790 <ProductsGrids fromDate={state.startDate!==null?moment(state.startDate).format('ll') :"Date is not Selected"} endDate={state.endDate!==null?moment(state.endDate).format('ll'):"Date is not Selected"} 791 />792 </div>793 </div>794 </div>795 </div>796 <br/>797 <div class="row">798 <div class="col-12">799 <div class="card">800 <div class="card-body">801 802 <table class="table">803 <thead>804 <tr>805 <th>Item SKU</th>806 <th>Item Name</th>807 808 <th>Vendor</th>809 <th>MRP</th>810 <th>Discounted Price</th>811 <th>Discount %</th>812 <th>No. of Items Ordered</th>813 <th>Total Sales Done</th>814 </tr>815 </thead>816 <tbody> 817 {ProductData.map(product=>{818 return <ProductsExtraGrids itemSku={product.fld_sku} itemName={product.fld_name} NoofItemsOrdered={product.fld_itemordercount} 819 MRP={product.fld_price} discountedPrice={product.fld_discountprice}820 discountedPersent={product.fld_discountpercent} totalSalesDone={product.fld_itemsales}821 vendorName={product.fld_vendorname}822 />823 })}824 825 </tbody>826 </table>827 </div>828 </div>829 </div>830 </div>831 </Fragment>}832 </table>833 )834}835 return (836 837 <div>838 <div class="content-page">839 840 <div class="content">841 <div class="container-fluid">842 843 <div class="row page-title">844 <div class="col-md-12 col-xl-12">845 <nav aria-label="breadcrumb" class="float-right mt-2">846 <ol class="breadcrumb">847 <li class="breadcrumb-item"><a href="#">Reports</a></li>848 <li class="breadcrumb-item active" aria-current="page">Products849 </li>850 </ol>851 </nav>852 853 </div>854 </div> 855 <div class="row page-title align-items-center pt-0">856 <div class="col-sm-4 col-xl-6">857 <h4 class="col-12 mb-1 mt-0">Product Reports</h4>858 </div>859 <div class="col-sm-8 col-xl-6 d-flex justify-content-end">860 <ReactHTMLTableToExcel861 id="test-table-xls-button"862 className={"btn btn-primary"}863 // className={banner===false&&startDate!==null&&endDate!==null?"bg-dark text-white py-2 rounded":"bg-dark text-white py-2 rounded d-none"}864 table="table-to-xls"865 filename={"ProductReports"}866 sheet="tablexls"867 buttonText="Download as XLS"868 style={{background: '#060a4a !important',869 color: 'white'870 871 }}/>872 873 </div>874 </div>875 876 <div className="card card-body" role="alert" aria-live="assertive" aria-atomic="true" data-toggle="toast" >877 <div className="row w-100">878 <div className="">879 <div className="btn-toolbar d-inline-flex880 sw-toolbar sw-toolbar-top" >881 {Dropdown()} 882 <input disabled={true} style={{marginTop:"9px", width:"8rem"}} className="form-control-daters mx-2" type='text' value={state.status} /> 883 </div> 884 </div>885 <div className="">886 <div className="btn-toolbar sw-toolbar sw-toolbar-top" >887 {Dropdown2()} 888 <input disabled={true} style={{marginTop:"9px"}} className="form-control-daters mr-2" type='text' value={state.category} /> 889 </div>890 </div>891 <div className="ml-2">892 893 <div className="btn-toolbar sw-toolbar sw-toolbar-top " style={{ float: 'right'}}>894 {DatePickers()}895 </div>896 </div>897 </div>898 899 </div>900 901 <div class="row">902 <div class="col-12">903 <div class="card">904 <div class="card-body getreport-card">905 <div class="row align-items-center">906 <div class="col ">907 908 </div>909 910 <div class="col text-right">911 <button style={{border:"0px"}} onClick={()=>getReportHandler()} className='btn btn-primary'>Get Reports</button> 912 </div>913 </div>914 </div>915 </div> 916 </div>917 918 </div> 919 { DataTable()}920 921 922 </div>923 </div>924</div>925 </div>926 )...

Full Screen

Full Screen

socksProxy.js

Source:socksProxy.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", {3 value: true4});5exports.SocksProxyHandler = exports.SocksProxy = void 0;6var _dns = _interopRequireDefault(require("dns"));7var _events = _interopRequireDefault(require("events"));8var _net = _interopRequireDefault(require("net"));9var _util = _interopRequireDefault(require("util"));10var _debugLogger = require("./debugLogger");11var _netUtils = require("./netUtils");12var _utils = require("./utils");13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }14/**15 * Copyright (c) Microsoft Corporation.16 *17 * Licensed under the Apache License, Version 2.0 (the "License");18 * you may not use this file except in compliance with the License.19 * You may obtain a copy of the License at20 *21 * http://www.apache.org/licenses/LICENSE-2.022 *23 * Unless required by applicable law or agreed to in writing, software24 * distributed under the License is distributed on an "AS IS" BASIS,25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.26 * See the License for the specific language governing permissions and27 * limitations under the License.28 */29const dnsLookupAsync = _util.default.promisify(_dns.default.lookup); // https://tools.ietf.org/html/rfc192830var SocksAuth;31(function (SocksAuth) {32 SocksAuth[SocksAuth["NO_AUTHENTICATION_REQUIRED"] = 0] = "NO_AUTHENTICATION_REQUIRED";33 SocksAuth[SocksAuth["GSSAPI"] = 1] = "GSSAPI";34 SocksAuth[SocksAuth["USERNAME_PASSWORD"] = 2] = "USERNAME_PASSWORD";35 SocksAuth[SocksAuth["NO_ACCEPTABLE_METHODS"] = 255] = "NO_ACCEPTABLE_METHODS";36})(SocksAuth || (SocksAuth = {}));37var SocksAddressType;38(function (SocksAddressType) {39 SocksAddressType[SocksAddressType["IPv4"] = 1] = "IPv4";40 SocksAddressType[SocksAddressType["FqName"] = 3] = "FqName";41 SocksAddressType[SocksAddressType["IPv6"] = 4] = "IPv6";42})(SocksAddressType || (SocksAddressType = {}));43var SocksCommand;44(function (SocksCommand) {45 SocksCommand[SocksCommand["CONNECT"] = 1] = "CONNECT";46 SocksCommand[SocksCommand["BIND"] = 2] = "BIND";47 SocksCommand[SocksCommand["UDP_ASSOCIATE"] = 3] = "UDP_ASSOCIATE";48})(SocksCommand || (SocksCommand = {}));49var SocksReply;50(function (SocksReply) {51 SocksReply[SocksReply["Succeeded"] = 0] = "Succeeded";52 SocksReply[SocksReply["GeneralServerFailure"] = 1] = "GeneralServerFailure";53 SocksReply[SocksReply["NotAllowedByRuleSet"] = 2] = "NotAllowedByRuleSet";54 SocksReply[SocksReply["NetworkUnreachable"] = 3] = "NetworkUnreachable";55 SocksReply[SocksReply["HostUnreachable"] = 4] = "HostUnreachable";56 SocksReply[SocksReply["ConnectionRefused"] = 5] = "ConnectionRefused";57 SocksReply[SocksReply["TtlExpired"] = 6] = "TtlExpired";58 SocksReply[SocksReply["CommandNotSupported"] = 7] = "CommandNotSupported";59 SocksReply[SocksReply["AddressTypeNotSupported"] = 8] = "AddressTypeNotSupported";60})(SocksReply || (SocksReply = {}));61class SocksConnection {62 constructor(uid, socket, client) {63 this._buffer = Buffer.from([]);64 this._offset = 0;65 this._fence = 0;66 this._fenceCallback = void 0;67 this._socket = void 0;68 this._boundOnData = void 0;69 this._uid = void 0;70 this._client = void 0;71 this._uid = uid;72 this._socket = socket;73 this._client = client;74 this._boundOnData = this._onData.bind(this);75 socket.on('data', this._boundOnData);76 socket.on('close', () => this._onClose());77 socket.on('end', () => this._onClose());78 socket.on('error', () => this._onClose());79 this._run().catch(() => this._socket.end());80 }81 async _run() {82 (0, _utils.assert)(await this._authenticate());83 const {84 command,85 host,86 port87 } = await this._parseRequest();88 if (command !== SocksCommand.CONNECT) {89 this._writeBytes(Buffer.from([0x05, SocksReply.CommandNotSupported, 0x00, // RSV90 0x01, // IPv491 0x00, 0x00, 0x00, 0x00, // Address92 0x00, 0x00 // Port93 ]));94 return;95 }96 this._socket.off('data', this._boundOnData);97 this._client.onSocketRequested({98 uid: this._uid,99 host,100 port101 });102 }103 async _authenticate() {104 // Request:105 // +----+----------+----------+106 // |VER | NMETHODS | METHODS |107 // +----+----------+----------+108 // | 1 | 1 | 1 to 255 |109 // +----+----------+----------+110 // Response:111 // +----+--------+112 // |VER | METHOD |113 // +----+--------+114 // | 1 | 1 |115 // +----+--------+116 const version = await this._readByte();117 (0, _utils.assert)(version === 0x05, 'The VER field must be set to x05 for this version of the protocol, was ' + version);118 const nMethods = await this._readByte();119 (0, _utils.assert)(nMethods, 'No authentication methods specified');120 const methods = await this._readBytes(nMethods);121 for (const method of methods) {122 if (method === 0) {123 this._writeBytes(Buffer.from([version, method]));124 return true;125 }126 }127 this._writeBytes(Buffer.from([version, SocksAuth.NO_ACCEPTABLE_METHODS]));128 return false;129 }130 async _parseRequest() {131 // Request.132 // +----+-----+-------+------+----------+----------+133 // |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |134 // +----+-----+-------+------+----------+----------+135 // | 1 | 1 | X'00' | 1 | Variable | 2 |136 // +----+-----+-------+------+----------+----------+137 // Response.138 // +----+-----+-------+------+----------+----------+139 // |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |140 // +----+-----+-------+------+----------+----------+141 // | 1 | 1 | X'00' | 1 | Variable | 2 |142 // +----+-----+-------+------+----------+----------+143 const version = await this._readByte();144 (0, _utils.assert)(version === 0x05, 'The VER field must be set to x05 for this version of the protocol, was ' + version);145 const command = await this._readByte();146 await this._readByte(); // skip reserved.147 const addressType = await this._readByte();148 let host = '';149 switch (addressType) {150 case SocksAddressType.IPv4:151 host = (await this._readBytes(4)).join('.');152 break;153 case SocksAddressType.FqName:154 const length = await this._readByte();155 host = (await this._readBytes(length)).toString();156 break;157 case SocksAddressType.IPv6:158 const bytes = await this._readBytes(16);159 const tokens = [];160 for (let i = 0; i < 8; ++i) tokens.push(bytes.readUInt16BE(i * 2));161 host = tokens.join(':');162 break;163 }164 const port = (await this._readBytes(2)).readUInt16BE(0);165 this._buffer = Buffer.from([]);166 this._offset = 0;167 this._fence = 0;168 return {169 command,170 host,171 port172 };173 }174 async _readByte() {175 const buffer = await this._readBytes(1);176 return buffer[0];177 }178 async _readBytes(length) {179 this._fence = this._offset + length;180 if (!this._buffer || this._buffer.length < this._fence) await new Promise(f => this._fenceCallback = f);181 this._offset += length;182 return this._buffer.slice(this._offset - length, this._offset);183 }184 _writeBytes(buffer) {185 if (this._socket.writable) this._socket.write(buffer);186 }187 _onClose() {188 this._client.onSocketClosed({189 uid: this._uid190 });191 }192 _onData(buffer) {193 this._buffer = Buffer.concat([this._buffer, buffer]);194 if (this._fenceCallback && this._buffer.length >= this._fence) {195 const callback = this._fenceCallback;196 this._fenceCallback = undefined;197 callback();198 }199 }200 socketConnected(host, port) {201 this._writeBytes(Buffer.from([0x05, SocksReply.Succeeded, 0x00, // RSV202 0x01, // IPv4203 ...parseIP(host), // Address204 port << 8, port & 0xFF // Port205 ]));206 this._socket.on('data', data => this._client.onSocketData({207 uid: this._uid,208 data209 }));210 }211 socketFailed(errorCode) {212 const buffer = Buffer.from([0x05, 0, 0x00, // RSV213 0x01, // IPv4214 ...parseIP('0.0.0.0'), // Address215 0, 0 // Port216 ]);217 switch (errorCode) {218 case 'ENOENT':219 case 'ENOTFOUND':220 case 'ETIMEDOUT':221 case 'EHOSTUNREACH':222 buffer[1] = SocksReply.HostUnreachable;223 break;224 case 'ENETUNREACH':225 buffer[1] = SocksReply.NetworkUnreachable;226 break;227 case 'ECONNREFUSED':228 buffer[1] = SocksReply.ConnectionRefused;229 break;230 }231 this._writeBytes(buffer);232 this._socket.end();233 }234 sendData(data) {235 this._socket.write(data);236 }237 end() {238 this._socket.end();239 }240 error(error) {241 this._socket.destroy(new Error(error));242 }243}244function parseIP(address) {245 if (!_net.default.isIPv4(address)) throw new Error('IPv6 is not supported');246 return address.split('.', 4).map(t => +t);247}248class SocksProxy extends _events.default {249 constructor() {250 super();251 this._server = void 0;252 this._connections = new Map();253 this._server = new _net.default.Server(socket => {254 const uid = (0, _utils.createGuid)();255 const connection = new SocksConnection(uid, socket, this);256 this._connections.set(uid, connection);257 });258 }259 async listen(port) {260 return new Promise(f => {261 this._server.listen(port, () => {262 const port = this._server.address().port;263 _debugLogger.debugLogger.log('proxy', `Starting socks proxy server on port ${port}`);264 f(port);265 });266 });267 }268 async close() {269 await new Promise(f => this._server.close(f));270 }271 onSocketRequested(payload) {272 this.emit(SocksProxy.Events.SocksRequested, payload);273 }274 onSocketData(payload) {275 this.emit(SocksProxy.Events.SocksData, payload);276 }277 onSocketClosed(payload) {278 this.emit(SocksProxy.Events.SocksClosed, payload);279 }280 socketConnected({281 uid,282 host,283 port284 }) {285 var _this$_connections$ge;286 (_this$_connections$ge = this._connections.get(uid)) === null || _this$_connections$ge === void 0 ? void 0 : _this$_connections$ge.socketConnected(host, port);287 }288 socketFailed({289 uid,290 errorCode291 }) {292 var _this$_connections$ge2;293 (_this$_connections$ge2 = this._connections.get(uid)) === null || _this$_connections$ge2 === void 0 ? void 0 : _this$_connections$ge2.socketFailed(errorCode);294 }295 sendSocketData({296 uid,297 data298 }) {299 var _this$_connections$ge3;300 (_this$_connections$ge3 = this._connections.get(uid)) === null || _this$_connections$ge3 === void 0 ? void 0 : _this$_connections$ge3.sendData(data);301 }302 sendSocketEnd({303 uid304 }) {305 var _this$_connections$ge4;306 (_this$_connections$ge4 = this._connections.get(uid)) === null || _this$_connections$ge4 === void 0 ? void 0 : _this$_connections$ge4.end();307 }308 sendSocketError({309 uid,310 error311 }) {312 var _this$_connections$ge5;313 (_this$_connections$ge5 = this._connections.get(uid)) === null || _this$_connections$ge5 === void 0 ? void 0 : _this$_connections$ge5.error(error);314 }315}316exports.SocksProxy = SocksProxy;317SocksProxy.Events = {318 SocksRequested: 'socksRequested',319 SocksData: 'socksData',320 SocksClosed: 'socksClosed'321};322class SocksProxyHandler extends _events.default {323 constructor(redirectPortForTest) {324 super();325 this._sockets = new Map();326 this._redirectPortForTest = void 0;327 this._redirectPortForTest = redirectPortForTest;328 }329 cleanup() {330 for (const uid of this._sockets.keys()) this.socketClosed({331 uid332 });333 }334 async socketRequested({335 uid,336 host,337 port338 }) {339 if (host === 'local.playwright') host = 'localhost';340 try {341 if (this._redirectPortForTest) port = this._redirectPortForTest;342 const {343 address344 } = await dnsLookupAsync(host);345 const socket = await (0, _netUtils.createSocket)(address, port);346 socket.on('data', data => {347 const payload = {348 uid,349 data350 };351 this.emit(SocksProxyHandler.Events.SocksData, payload);352 });353 socket.on('error', error => {354 const payload = {355 uid,356 error: error.message357 };358 this.emit(SocksProxyHandler.Events.SocksError, payload);359 this._sockets.delete(uid);360 });361 socket.on('end', () => {362 const payload = {363 uid364 };365 this.emit(SocksProxyHandler.Events.SocksEnd, payload);366 this._sockets.delete(uid);367 });368 const localAddress = socket.localAddress;369 const localPort = socket.localPort;370 this._sockets.set(uid, socket);371 const payload = {372 uid,373 host: localAddress,374 port: localPort375 };376 this.emit(SocksProxyHandler.Events.SocksConnected, payload);377 } catch (error) {378 const payload = {379 uid,380 errorCode: error.code381 };382 this.emit(SocksProxyHandler.Events.SocksFailed, payload);383 }384 }385 sendSocketData({386 uid,387 data388 }) {389 var _this$_sockets$get;390 (_this$_sockets$get = this._sockets.get(uid)) === null || _this$_sockets$get === void 0 ? void 0 : _this$_sockets$get.write(data);391 }392 socketClosed({393 uid394 }) {395 var _this$_sockets$get2;396 (_this$_sockets$get2 = this._sockets.get(uid)) === null || _this$_sockets$get2 === void 0 ? void 0 : _this$_sockets$get2.destroy();397 this._sockets.delete(uid);398 }399}400exports.SocksProxyHandler = SocksProxyHandler;401SocksProxyHandler.Events = {402 SocksConnected: 'socksConnected',403 SocksData: 'socksData',404 SocksError: 'socksError',405 SocksFailed: 'socksFailed',406 SocksEnd: 'socksEnd'...

Full Screen

Full Screen

SocksGrid.js

Source:SocksGrid.js Github

copy

Full Screen

1import React, { Component } from 'react';2import Helmet from 'react-helmet'3import {Edit3,Trash2} from 'react-feather';4import Notiflix from "notiflix";5import GetApiCall from '../GetApi';6import PostApiCall from '../Api';7class SocksGrid extends Component {8 constructor(props){9 super(props)10 this.state={11 SocksData:[],12 AddAccess : false13 }14 15 }16 17 componentDidMount(){18 Notiflix.Loading.Init({19 svgColor : '#507dc0'20 21 });22 23 Notiflix.Loading.Dots('');24 25 GetApiCall.getRequest("GetSocksItemMaster").then(resultdes =>26 resultdes.json().then(obj => {27 28 // console.log(obj.data)29 30 this.setState({31 SocksData : obj.data32 })33 34 35 // Notiflix.Loading.Remove();36 }))37 var login=localStorage.getItem('LoginDetail');38 var details=JSON.parse(login)39 40 PostApiCall.postRequest({41 42 staffid : details[0].fld_staffid,43 44 },"GetUserSubMenuAccessRights").then((resultssub) => 45 46 // const objs = JSON.parse(result._bodyText)47 resultssub.json().then(objsub => { 48 if(resultssub.status == 200 || resultssub.status==201){49 50 var filteredRights = objsub.data;51 // console.log(filteredRights)52 53 var con = 054 for(var i = 0 ; i< filteredRights.length ;i++){55 56 if(filteredRights[i].fld_menuname == 'Add Socks'){57 58 if(filteredRights[i].fld_access == 1){59 60 this.setState({61 AddAccess : true62 })63 }64 }65 66 con = con + 167 if(con == filteredRights.length){68 Notiflix.Loading.Remove();69 }70 }71 72 73 }74 75 }))76 77 }78 79 80 81 82 83 render(){84 return(85 <div>86 87 88 <div class="content-page">89 90 <div class="content">91 <div class="container-fluid">92 <div class="row page-title">93 <div class="col-md-12">94 <nav aria-label="breadcrumb" class="float-right mt-1">95 <ol class="breadcrumb">96 <li class="breadcrumb-item"><a href="#">Product Management</a></li>97 <li class="breadcrumb-item active" aria-current="page">Socks List98 </li>99 </ol>100 </nav>101 <h4 class="mb-1 mt-0">Socks List102 </h4>103 </div>104 </div> 105 <div class="row">106 <div class="col-12">107 <div class="card">108 <div class="card-body">109 <div class="row align-items-center">110 <div class="col-md-6">111 112 <div class="row align-items-center">113 <div class="col-md-2">114 <label for="validationCustom01">Filter By:</label>115 </div>116 <div class="col-md-4" style={{marginLeft:'-23px'}}>117 118 <select type="text" class="form-control" required >119 <option>Brand</option>120 <option>Pharma Company</option>121 122 </select>123 124 </div>125 <div class="col-md-4">126 127 <select type="text" class="form-control" required >128 <option>D-Alive</option>129 130 </select>131 132 </div>133 </div>134 </div>135 136 <div class="col-md-6 text-right" style={{display : this.state.AddAccess ? '' : 'none'}}>137 <a href='/addsocksitemmaster'>138 <button 139 140 class="btn btn-primary" id="btn-new-event" data-toggle="modal"><i141 class="uil-plus mr-1"></i>Add New Socks Item</button>142 143 </a>144 </div>145 </div>146 </div>147 </div> 148 </div>149 150 </div>151 152 153 <div class="row">154 <div class="col-12">155 <div class="card">156 <div class="card-body">157 <div class="table-responsive">158 159 <table id="basic-datatable" class="table dt-responsive nowrap">160 <thead>161 <tr>162 <th>Item Code</th>163 <th>Item Name</th>164 <th>Brand</th>165 <th>Comapny</th>166 <th>HSN Code</th>167 <th>Status</th>168 <th>Action</th>169 170 171 172 </tr>173 </thead>174 <tbody>175 {this.state.SocksData.length == 0 ? 176 <tr><td colSpan={7} style={{textAlign:'center'}}>No Socks Item Master Available</td></tr> : 177 ''} 178 {this.state.SocksData.map((data,index)=>(179 180 181 182 <tr key={index}>183 { index == 0 ?184 <Helmet>185 186 <script src="assets/libs/datatables/jquery.dataTables.min.js"></script>187 <script src="assets/js/pages/datatables.init.js"></script>188 <script src="assets/libs/datatables/dataTables.bootstrap4.min.js"></script>189 190 </Helmet> : ''}191 <td>{data.fld_code}</td>192 <td>{data.fld_name} 193 <br/><a class="variant-list"194 onClick={()=>{195 196 localStorage.setItem('SocksParentIdDetails',JSON.stringify(data))197 window.location.href = "/socksvariantlist"198 }}199 >{data.VariantCount} Variant{data.VariantCount == 1 ? '' : 's'} Available ( <span style={{color:'red'}}>{data.NotApproved} Pending</span>, <span style={{color:'green'}}>{data.Approved} Approved</span> )</a>200 </td>201 <td>{data.fld_brand}</td>202 <td>{data.fld_company}</td>203 <td>{data.fld_hsncode}</td>204 <td style={{color:data.fld_approved == 'Yes' ? 'green' : 'red'}}><b>{data.fld_approved== 'Yes' ? 'Approved' : 'Pending'}</b></td>205 <td> <div class="align-self-center tableact" style={{ textAlign: 'center'}}206 onClick={()=>{207 208 localStorage.setItem('SocksDetails',JSON.stringify(data))209 window.location.href = '/viewsocks'210 }}211 >212 <span >213 <Edit3/>214 </span>215 {/* &nbsp;&nbsp;<Trash2/> */}216 </div> &nbsp;&nbsp;217 </td>218 219 </tr>220 221 222 ))} 223 224 225 </tbody>226 227 228 </table>229 </div>230 231 </div>232 </div>233 </div>234 </div>235 </div>236 </div>237 </div> 238 </div>239 )240 }241}...

Full Screen

Full Screen

saveUsers.js

Source:saveUsers.js Github

copy

Full Screen

1const ruteadores = require("../database/schemas/ruteadores");2const socks = require("../database/schemas/socks");3const users = require("../database/schemas/users");4const dockerDbsUrls = require("./../config/dockerDbs");5const connect_to_database = require("./../database/index");6const config = require("./../config/index");7const { RUT0 } = require("./constatns");8function saveUsers() {9 return new Promise(async (resolve) => {10 const keys = Object.entries(dockerDbsUrls);11 let total = [];12 const curpRepeated = [];13 console.log("Obteniendo Usuarios");14 for (let key of keys) {15 await connect_to_database(key[1].toString());16 const usersData = await users.find();17 for (let user of usersData) {18 if (!total.find((x) => x._id.toString() === user._id.toString()))19 total.push(user);20 }21 }22 console.log("Filtrando Usuarios");23 await connect_to_database(config.objective_db);24 for (let user of total) {25 let filtered = [];26 if (user.curp) {27 filtered = total.filter((x) => x.curp === user.curp);28 if (filtered.length > 1) {29 const user1 = filtered[0];30 const user2 = filtered[1];31 const user3 = filtered.length === 3 ? filtered[2] : null;32 //Buscar socks y asignar los socks al usuario 133 const socksData = await socks.find({ _id: user2._id });34 if (socksData) await assignNewUserTosocks(socksData, user1._id);35 //Buscar ruta y asignar a usuario 136 const rutData = await ruteadores.find({ ciudadanos: user2._id });37 if (rutData) await filterCiudadanosBasedOnId(user2._id, user1._id);38 let socksData2 = null;39 let rutData2 = null;40 if (user3) {41 socksData2 = await socks.find({ _id: user3._id });42 rutData2 = await ruteadores.find({ ciudadanos: user3._id });43 if (socksData2) await assignNewUserTosocks(socksData2, user1._id);44 if (rutData2) await filterCiudadanosBasedOnId(user3._id), user1._id;45 }46 if (!rutData && !rutData2) await assignToTempRut(user1._id);47 //SE FILTRAN DEL ARREGLO PRINCIPAL Y SE AGREGAN A OTRO48 total = total.filter((x) => x.curp !== user.curp);49 curpRepeated.push(user1);50 }51 }52 }53 console.log(`Users length: ${total.length}`);54 console.log(`Curp Repeated Length ${curpRepeated.length}`);55 console.log("Guardando Usuarios");56 await saveUsersAsync(total);57 await saveUsersAsync(curpRepeated);58 console.log("Usuarios Guardados");59 resolve();60 });61}62async function filterCiudadanosBasedOnId(idToOmit, idToAdd) {63 //borra el ciudadano de cualquier ruta que exista64 console.log("Filtrando ciudadano en ruta");65 console.log(idToOmit);66 await ruteadores.updateMany(67 { ciudadanos: idToOmit },68 {69 $pull: { ciudadanos: idToOmit },70 }71 );72 await ruteadores.updateMany(73 { ciudadanos: idToOmit },74 {75 $push: { ciudadanos: [idToAdd] },76 }77 );78}79function assignNewUserTosocks(entregas, userId) {80 return new Promise(async (resolve) => {81 console.log("Se estan Asignando nuevos socks");82 for (let sock of entregas) {83 await socks.findOneAndUpdate(84 { _id: sock._id },85 {86 ciudadano: userId,87 }88 );89 }90 resolve();91 });92}93function saveUsersAsync(data) {94 return new Promise(async (resolve) => {95 for (let user of data) {96 const exists = await users.exists({ _id: user._id });97 if (!exists) await users.insertMany(user);98 }99 resolve();100 });101}102async function assignToTempRut(userId) {103 await socks.findOneAndUpdate(104 { _id: RUT0 },105 {106 $push: { ciudadanos: userId },107 }108 );109}...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1var exec = require('child_process').exec,2 child;3var http = require('http');4var fs = require('fs');5var socks = require('socks5');678var forwardProxy = require('forward-proxy');9var prxySrv = new forwardProxy({10 endpoints: [{ip: 'iwebvpn.com', port: 51686}, {ip: 'iwebvpn.com', port: 51868}],11 turn: [{ip: 'iwebvpn.com', agent: 51866, proxy: 51688}],12 13 usrkey: 'TBD', 14 secmode: 'acl', 15 access_local: false16}, function(err, proxy){17 if (err || !proxy) {18 console.log(err+',create proxy failed');19 return 20 }2122 // turn on export service query timer23 prxySrv.turnQuerytimer(true);2425 var importApp = proxy.importApp;2627 // 1.28 // get free tcp port29 deskShell30 .getFreePort(null, null)31 .then(function(prxydata){32 // 2.33 // start http proxy service34 var pxySrv = http.createServer();3536 pxySrv.on('request', importApp.httpApp.proxy);37 pxySrv.on('connect', importApp.httpApp.tunnel);3839 pxySrv.listen(prxydata.port);40 console.log('Http forwar proxy server listen on port '+prxydata.port);4142 deskShell43 .getFreePort(null, null)44 .then(function(socksdata){45 // 2.146 // start socks proxy service47 var sockspxySrv = socks.createServer(importApp.socksApp);4849 sockspxySrv.listen(socksdata.port);5051 sockspxySrv.on('error', function (e) {52 console.error('SERVER ERROR: %j', e);53 });54 console.log('Socks forward proxy server listen on port '+socksdata.port);5556 // 3.57 // start pac server58 deskShell59 .getFreePort(null, null)60 .then(function(pacdata){61 // pac server62 var rawstr = fs.readFileSync(__dirname+'/auto.pac').toString('utf-8');63 // fill http proxy server64 var pacstr = rawstr.replace(/proxy_port/gi, ''+prxydata.port);65 pacstr = pacstr.replace(/socks_port/gi, ''+socksdata.port);66 ///console.log('pacstr: '+pacstr);67 var pacsrv = http.createServer(function(req, res){68 res.writeHead(200, {'Content-Type': 'application/x-ns-proxy-autoconfig'});69 res.end(pacstr);70 });7172 pacsrv.listen(pacdata.port);73 console.log('pac server listening on '+pacdata.port);7475 // 3.76 // start front app77 var running = deskShell.startApp({78 "user-data-dir": __dirname+"/data",79 "deskShellSocketClient": true80 });8182 running.then(function(app){83 console.log('app started ... done');8485 // 4.86 // launching chrome browser with pac settings87 var cli = app.params['chromiumPath'];88 cli = '"' + cli + '"';89 cli += ' --proxy-pac-url="http://localhost:'+pacdata.port+'/auto.pac"';90 cli += ' --user-data-dir="' + __dirname + '/user-data/' + '"';91 cli += ' --disable-translate';9293 console.log("cli: "+cli);94 child = exec(cli);95 child.on('exit', function(code){96 console.log('child browser exited '+code);97 // exit main program98 process.exit(code);99 });100 });101 }).fail(function(err){102 console.log('get free pac port failed '+err);103 });104 }).fail(function(err){105 console.log('get free socks proxy port failed '+err);106 });107 }).fail(function(err){108 console.log('get free http proxy port failed '+err);109 });110}); ...

Full Screen

Full Screen

socks.js

Source:socks.js Github

copy

Full Screen

1import React from 'react';2import Nav from '../components/Nav';3import Footer from '../components/Footer';4import PageCarosal from '../components/PageCarosal';5import socksData from './data/socksData.json';6import { Slide } from "react-awesome-reveal";7const socks = () => {8 return (9 <>10 <Nav />11 <section translate='no' className='py-10 bg-gradient-to-r from-sky-200 to-sky-100 ...'>12 <Slide triggerOnce delay={500}>13 <PageCarosal />14 </Slide>15 <section class="overflow-hidden text-gray-700 ">16 <div class="container px-3 py-2 mx-auto lg:pt-12 lg:px-10">17 <div class="flex flex-wrap -m-1 md:-m-2">18 {19 socksData.map(item => {20 return <>21 <div class="flex flex-wrap lg:w-1/3 w-1/2">22 <div class="relative w-full p-1 md:p-2">23 <img alt="gallery" class="block object-cover object-center w-full h-full rounded-lg"24 src={item.img}25 onClick={() => { window.open(`${item.img}`, '_self') }}26 />27 <div className='absolute w-11/12 text-white rounded-full lg:top-5 top-2'>28 <p className='pl-1'>29 <span class="sm:px-2 sm:py-1 py-0 px-2 text-sm font-bold leading-none text-white bg-amber-600 rounded-full">{item.price} JD</span>30 <a href="https://wa.me/+962795152466" data-tippy-content="WhatsApp" target='_blank'>31 <span class="py-1 sm:px-2 sm:py-1 px-1 text-base font-bold leading-none float-left rounded-full bg-amber-600">32 <img src='https://cdn-icons-png.flaticon.com/512/3523/3523887.png' className='w-6 h-6'></img>33 </span>34 </a>35 </p>36 </div>37 </div>38 </div>39 </>40 })41 }42 </div>43 </div>44 </section>45 </section>46 <Footer />47 </>48 )49}...

Full Screen

Full Screen

mergeDatabaseDocker.js

Source:mergeDatabaseDocker.js Github

copy

Full Screen

1const dockerDbsUrls = require("../config/dockerDbs");2const originalDatabasesUrls = require("../config/originalDatabases");3const bienes = require("../database/schemas/bienes");4const entregas = require("../database/schemas/entregas");5const ruteadores = require("../database/schemas/ruteadores");6const socks = require("../database/schemas/socks");7const users = require("../database/schemas/users");8const connect_to_db = require("./../database/index");9function mergeDatabaseDocker() {10 return new Promise(async (resolve) => {11 const originalDatabases = Object.values(originalDatabasesUrls);12 const dockerDatabases = Object.values(dockerDbsUrls);13 for (let i = 0; i < 4; i++) {14 console.log("Conectando con: ", originalDatabases[i]);15 await connect_to_db(originalDatabases[i]);16 console.log("Obetniendo data de: ", originalDatabases[i]);17 //Get Data18 const socksData = await socks.find();19 const usersData = await users.find();20 const ruteadoresData = await ruteadores.find();21 const entregasData = await entregas.find();22 const bienesData = await bienes.find();23 //Save Data24 console.log("Conectando con: ", dockerDatabases[i]);25 await connect_to_db(dockerDatabases[i]);26 console.log("Guardando data en: ", dockerDatabases[i]);27 //ENTREGAS28 for (let entrega of entregasData) {29 const exists = await entregas.exists({ _id: entrega._id });30 if (!exists) await entregas.insertMany(entrega);31 }32 //BIENES33 for (let biene of bienesData) {34 const exists = await bienes.exists({ _id: biene._id });35 if (!exists) await bienes.insertMany(biene);36 }37 //RUTEADORES38 for (let ruteador of ruteadoresData) {39 const exists = await ruteadores.exists({ _id: ruteador._id });40 if (!exists) await ruteadores.insertMany(ruteador);41 }42 //USERS43 for (let user of usersData) {44 const exists = await users.exists({ _id: user._id });45 if (!exists) await users.insertMany(user);46 }47 //SOCKS48 for (let sock of socksData) {49 const exists = await socks.exists({ _id: sock._id });50 if (!exists) await socks.insertMany(sock);51 }52 }53 resolve();54 });55}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');2const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');3const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');4const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');5const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');6const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');7const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');8const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');9const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');10const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');11const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');12const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');13const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');14const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');15const {socksData} = require('playwright/lib/server/chromium/crNetworkManager');16const {

Full Screen

Using AI Code Generation

copy

Full Screen

1const socksData = require('playwright/lib/server/network').socksData;2const socks = require('socks');3const { chromium } = require('playwright');4(async () => {5 const browser = await chromium.launch({6 });7 const context = await browser.newContext({8 });9 const page = await context.newPage();10 await page.route('**/*', async (route, request) => {11 const { host, port, username, password } = await socksData();12 const { url, method, headers, postData } = request;13 const options = {14 proxy: {15 },16 };17 const info = await socks.createConnection({ ...options, target: url });18 const socket = info.socket;19 socket.write(`${method} ${url} HTTP/1.1\r\n`);20 for (const [name, value] of Object.entries(headers)) {21 socket.write(`${name}: ${value}\r\n`);22 }23 socket.write('\r\n');24 if (postData) socket.write(postData);25 socket.on('data', (data) => {26 const response = data.toString();27 const [statusLine, ...headers] = response.split('\r\n');28 const [version, statusCode, statusText] = statusLine.split(' ');29 const headersObject = Object.fromEntries(30 headers.map((header) => header.split(': '))31 );32 route.fulfill({33 status: Number(statusCode),34 body: data.slice(response.length),35 });36 });37 });38 await page.screenshot({ path: 'example.png' });39 await browser.close();40})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');2const socks = socksData();3console.log(socks);4const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');5const socks = socksData();6console.log(socks);7const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');8const socks = socksData();9console.log(socks);10const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');11const socks = socksData();12console.log(socks);13const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');14const socks = socksData();15console.log(socks);16const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');17const socks = socksData();18console.log(socks);19const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');20const socks = socksData();21console.log(socks);22const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');23const socks = socksData();24console.log(socks);25const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');26const socks = socksData();27console.log(socks);28const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');29const socks = socksData();30console.log(socks);31const {socksData} = require('playwright/lib/server/supplements/recorder/recorderApp');32const socks = socksData();33console.log(socks);

Full Screen

Using AI Code Generation

copy

Full Screen

1const socksData = require('playwright/lib/server/socksServer').socksData;2const socks = new socksData();3const socksServer = require('playwright/lib/server/socksServer').socksServer;4const server = new socksServer(socks);5const socksServer = require('playwright/lib/server/socksServer').socksServer;6const server = new socksServer(socks);7const launchServer = require('playwright/lib/server/browserServer').launchServer;8const launch = require('playwright/lib/server/browserType').launch;9const launchPersistentContext = require('playwright/lib/server/browserType').launchPersistentContext;10const socksData = require('playwright/lib/server/socksServer').socksData;11const socks = new socksData();12const socksServer = require('playwright/lib/server/socksServer').socksServer;13const server = new socksServer(socks);14const launchServer = require('playwright/lib/server/browserServer').launchServer;15const launch = require('playwright/lib/server/browserType').launch;16const launchPersistentContext = require('playwright/lib/server/browserType').launchPersistentContext;17const { chromium } = require('playwright');18(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const {socksData} = require('playwright/lib/utils/socksProxy');2const socksData = socksData('localhost', 1080);3const browser = await chromium.launch({4 proxy: {5 }6});7const {socksData} = require('puppeteer/lib/cjs/puppeteer/common/Connection');8const socksData = socksData('localhost', 1080);9const browser = await puppeteer.launch({10 `--proxy-username=${socksData.username}`,11 `--proxy-password=${socksData.password}`,12});13const {socksData} = require('puppeteer/lib/cjs/puppeteer/common/Connection');14const socksData = socksData('localhost', 1080);15const browser = await puppeteer.launch({16 `--proxy-username=${socksData.username}`,17 `--proxy-password=${socksData.password}`,18});19const {socksData} = require('puppeteer/lib/cjs/puppeteer/common/Connection');20const socksData = socksData('localhost', 1080);21const browser = await puppeteer.launch({22 `--proxy-username=${socksData.username}`,23 `--proxy-password=${socksData.password}`,24});25const {socksData} = require('puppeteer/lib/cjs/puppeteer/common/Connection');26const socksData = socksData('localhost', 1080);27const browser = await puppeteer.launch({28 `--proxy-username=${socksData.username}`,29 `--proxy-password=${socksData.password

Full Screen

Using AI Code Generation

copy

Full Screen

1const {socksData} = require('playwright/lib/server/browserType');2const socksData = socksData();3console.log(socksData);4#### socksData()5#### socksData({port})6#### socksData({host})7#### socksData({host, port})8#### socksData({host, port, protocol})9#### socksData({host, port, protocol, type})10#### socksData({host, port, protocol, type, username})11#### socksData({host, port, protocol, type, username, password})12#### socksData({host, port, protocol, type, username, password, state})13#### socksData({host, port, protocol, type, username, password, state, url})14const {socksData} = require('playwright/lib/server/browserType');15const socksData = socksData();16console.log(socksData);17[MIT](LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1const {socksData} = require('playwright-core/lib/server/network');2const socks = socksData();3console.log(socks);4const {socksData} = require('playwright-core/lib/server/network');5const socks = socksData();6console.log(socks);7const {socksData} = require('playwright-core/lib/server/network');8const socks = socksData();9console.log(socks);10const {socksData} = require('playwright-core/lib/server/network');11const socks = socksData();12console.log(socks);13const {socksData} = require('playwright-core/lib/server/network');14const socks = socksData();15console.log(socks);16const {socksData} = require('playwright-core/lib/server/network');17const socks = socksData();18console.log(socks);19const {socksData} = require('playwright-core/lib/server/network');20const socks = socksData();21console.log(socks);22const {socksData} = require('

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