{"ast":null,"code":"import{Form,Input,Button}from'antd';import'./styles.css';import React,{useEffect,useState}from'react';import setuLogo from'../../assets/setuLogo.png';import{EyeInvisibleOutlined,EyeTwoTone,UserOutlined}from'@ant-design/icons';import{useHistory}from'react-router-dom';import{connect}from'react-redux';import{checkOrganisation,login}from'../../reduxStore/actions/action';import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";function Login(_ref){let{login,handleOrientationChange,checkOrganisation,organisation}=_ref;const history=useHistory();const subOrgId=organisation===null||organisation===void 0?void 0:organisation.id;const[loder,setLoader]=useState(false);console.log(\"subOrgId\",subOrgId);const handleLogin=async value=>{try{const param={username:value.username,password:value.password};login(param,firstTimeUser=>{setLoader(false);history.push('/setu_game');const audio=document.getElementById(\"audio-tag\");;handleOrientationChange();console.log('playing sound',firstTimeUser);if(firstTimeUser==false){console.log('playing sound');if(audio.paused){var _audio$play;audio===null||audio===void 0?void 0:(_audio$play=audio.play())===null||_audio$play===void 0?void 0:_audio$play.catch(error=>{console.error(\"Error playing audio:\",error);});// playAudio(false);\n}else{var _audio$pause;audio===null||audio===void 0?void 0:(_audio$pause=audio.pause())===null||_audio$pause===void 0?void 0:_audio$pause.catch(error=>{console.error(\"Error pausing audio:\",error);});// playAudio(true);\n}}});}catch(error){console.error('Error in login:',error);}};useEffect(()=>{// Clear local storage\nlet id=subOrgId;window.sessionStorage.clear();if(id){checkOrganisation({id},()=>{console.log('Success');},()=>{console.log('Failure');});}},[]);return/*#__PURE__*/_jsx(\"div\",{className:\"component-wrapper\",children:/*#__PURE__*/_jsxs(\"div\",{className:\"form-container\",children:[/*#__PURE__*/_jsx(\"img\",{src:setuLogo,className:\"logo-img\"}),/*#__PURE__*/_jsx(\"span\",{className:\"form-heading\",children:\"Login\"}),/*#__PURE__*/_jsxs(\"div\",{className:\"form-wrapper\",children:[/*#__PURE__*/_jsxs(Form,{layout:\"vertical\",className:\"setu-form\",autoComplete:\"off\",onFinish:handleLogin,children:[/*#__PURE__*/_jsx(Form.Item,{label:/*#__PURE__*/_jsx(\"label\",{className:\"form-label\",children:\"Username\"}),className:\"form-item\",name:\"username\",rules:[{required:true,message:'Please input your username!'}],children:/*#__PURE__*/_jsx(Input,{className:\"form-input\",placeholder:\"Username\",suffix:/*#__PURE__*/_jsx(UserOutlined,{})})}),/*#__PURE__*/_jsx(Form.Item,{className:\"form-item\",label:/*#__PURE__*/_jsx(\"label\",{className:\"form-label\",children:\"Password\"}),name:\"password\",rules:[{required:true,message:'Please input your password!'}],children:/*#__PURE__*/_jsx(Input.Password,{autoComplete:\"new-password\",placeholder:\"Password\",className:\"form-input\",iconRender:visible=>visible?/*#__PURE__*/_jsx(EyeTwoTone,{}):/*#__PURE__*/_jsx(EyeInvisibleOutlined,{})})}),/*#__PURE__*/_jsx(Form.Item,{className:\"form-item\",children:/*#__PURE__*/_jsx(Button,{className:\"form-submit-btn\",htmlType:\"submit\",children:\"Login\"})})]}),/*#__PURE__*/_jsx(\"div\",{className:\"form-link\",children:/*#__PURE__*/_jsxs(\"p\",{children:[\"Don't have an Account? \",/*#__PURE__*/_jsx(\"a\",{href:\"/setu_game/signup\",children:\"Sign Up\"})]})})]}),/*#__PURE__*/_jsx(\"div\",{className:\"forgot-password\",children:/*#__PURE__*/_jsx(\"a\",{href:\"/setu_game/forgot-password\",children:\"Forgot your password?\"})})]})});}const mapStateToProps=state=>{const{auth,organisation}=state===null||state===void 0?void 0:state.SeTu;return{auth,organisation};};const mapDispatchToProps=dispatch=>({login:(params,successCallback)=>dispatch(login(params,successCallback)),checkOrganisation:(params,successCallback,callback)=>dispatch(checkOrganisation(params,successCallback,callback))});export default connect(mapStateToProps,mapDispatchToProps)(Login);","map":{"version":3,"names":["Form","Input","Button","React","useEffect","useState","setuLogo","EyeInvisibleOutlined","EyeTwoTone","UserOutlined","useHistory","connect","checkOrganisation","login","jsx","_jsx","jsxs","_jsxs","Login","_ref","handleOrientationChange","organisation","history","subOrgId","id","loder","setLoader","console","log","handleLogin","value","param","username","password","firstTimeUser","push","audio","document","getElementById","paused","_audio$play","play","catch","error","_audio$pause","pause","window","sessionStorage","clear","className","children","src","layout","autoComplete","onFinish","Item","label","name","rules","required","message","placeholder","suffix","Password","iconRender","visible","htmlType","href","mapStateToProps","state","auth","SeTu","mapDispatchToProps","dispatch","params","successCallback","callback"],"sources":["/opt/bitnami/apache/htdocs/setu_beta_game/src/pages/auth/login.js"],"sourcesContent":["import { Form, Input, Button } from 'antd'\r\nimport './styles.css'\r\nimport React, { useEffect, useState } from 'react';\r\nimport setuLogo from '../../assets/setuLogo.png';\r\nimport { EyeInvisibleOutlined, EyeTwoTone, UserOutlined } from '@ant-design/icons';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { connect } from 'react-redux';\r\nimport { checkOrganisation, login } from '../../reduxStore/actions/action';\r\n\r\n\r\nfunction Login({ login, handleOrientationChange, checkOrganisation, organisation }) {\r\n  const history = useHistory();\r\n\r\n  const subOrgId = organisation?.id\r\n  const [loder, setLoader] = useState(false);\r\n\r\n\r\n  console.log(\"subOrgId\", subOrgId)\r\n\r\n  const handleLogin = async (value) => {\r\n    try {\r\n\r\n      const param = {\r\n        username: value.username,\r\n        password: value.password\r\n      }\r\n      login(param, (firstTimeUser) => {\r\n\r\n        setLoader(false);\r\n        history.push('/setu_game');\r\n        const audio = document.getElementById(\"audio-tag\");;\r\n        handleOrientationChange();\r\n        console.log('playing sound', firstTimeUser)\r\n        if (firstTimeUser == false) {\r\n          console.log('playing sound')\r\n          if (audio.paused) {\r\n            audio?.play()?.catch(error => {\r\n              console.error(\"Error playing audio:\", error);\r\n            });\r\n            // playAudio(false);\r\n\r\n          } else {\r\n            audio?.pause()?.catch(error => {\r\n              console.error(\"Error pausing audio:\", error);\r\n            });\r\n            // playAudio(true);\r\n\r\n          }\r\n        }\r\n      })\r\n    } catch (error) {\r\n      console.error('Error in login:', error);\r\n    }\r\n  }\r\n\r\n  useEffect(() => {\r\n    // Clear local storage\r\n    let id=subOrgId;\r\n    window.sessionStorage.clear();\r\n\r\n\r\n    if (id) {\r\n\r\n      checkOrganisation(\r\n        { id },\r\n        () => { console.log('Success'); },\r\n        () => { console.log('Failure'); }\r\n      );\r\n    }\r\n  }, []);\r\n\r\n\r\n  return (\r\n    <div className='component-wrapper'>\r\n      <div className='form-container'>\r\n\r\n        <img src={setuLogo} className='logo-img' />\r\n\r\n        <span className='form-heading'>Login</span>\r\n\r\n        <div className='form-wrapper'>\r\n          <Form\r\n            layout=\"vertical\"\r\n            className='setu-form'\r\n            autoComplete='off'\r\n            onFinish={handleLogin}\r\n\r\n          >\r\n            <Form.Item\r\n              label={<label className='form-label'>Username</label>}\r\n              className='form-item'\r\n              name=\"username\"\r\n              rules={[\r\n                {\r\n                  required: true,\r\n                  message: 'Please input your username!',\r\n                },\r\n              ]}\r\n            >\r\n              <Input className='form-input' placeholder='Username' suffix={<UserOutlined />} />\r\n            </Form.Item>\r\n            <Form.Item\r\n              className='form-item'\r\n              label={<label className='form-label'>Password</label>}\r\n              name=\"password\"\r\n              rules={[\r\n                {\r\n                  required: true,\r\n                  message: 'Please input your password!',\r\n                },\r\n              ]}\r\n            >\r\n              <Input.Password autoComplete=\"new-password\" placeholder=\"Password\" className='form-input' iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)} />\r\n            </Form.Item>\r\n            <Form.Item\r\n              className='form-item'\r\n            >\r\n              <Button className='form-submit-btn' htmlType=\"submit\">\r\n                Login\r\n              </Button>\r\n            </Form.Item>\r\n          </Form>\r\n          <div className='form-link'>\r\n            <p>Don't have an Account? <a href='/setu_game/signup' >Sign Up</a></p>\r\n\r\n          </div>\r\n        </div>\r\n        <div className='forgot-password'>\r\n          <a href='/setu_game/forgot-password'>Forgot your password?</a>\r\n        </div>\r\n      </div>\r\n\r\n    </div>\r\n  )\r\n}\r\n\r\n\r\n\r\n\r\n\r\nconst mapStateToProps = state => {\r\n  const {\r\n    auth, organisation\r\n  } = state?.SeTu;\r\n\r\n  return { auth, organisation }\r\n}\r\n\r\n\r\nconst mapDispatchToProps = dispatch => ({\r\n  login: (params, successCallback) => dispatch(login(params, successCallback)),\r\n  checkOrganisation: (params, successCallback, callback) => dispatch(checkOrganisation(params, successCallback, callback)),\r\n\r\n\r\n})\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(Login)\r\n\r\n"],"mappings":"AAAA,OAASA,IAAI,CAAEC,KAAK,CAAEC,MAAM,KAAQ,MAAM,CAC1C,MAAO,cAAc,CACrB,MAAO,CAAAC,KAAK,EAAIC,SAAS,CAAEC,QAAQ,KAAQ,OAAO,CAClD,MAAO,CAAAC,QAAQ,KAAM,2BAA2B,CAChD,OAASC,oBAAoB,CAAEC,UAAU,CAAEC,YAAY,KAAQ,mBAAmB,CAClF,OAASC,UAAU,KAAQ,kBAAkB,CAC7C,OAASC,OAAO,KAAQ,aAAa,CACrC,OAASC,iBAAiB,CAAEC,KAAK,KAAQ,iCAAiC,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAG3E,QAAS,CAAAC,KAAKA,CAAAC,IAAA,CAAsE,IAArE,CAAEN,KAAK,CAAEO,uBAAuB,CAAER,iBAAiB,CAAES,YAAa,CAAC,CAAAF,IAAA,CAChF,KAAM,CAAAG,OAAO,CAAGZ,UAAU,CAAC,CAAC,CAE5B,KAAM,CAAAa,QAAQ,CAAGF,YAAY,SAAZA,YAAY,iBAAZA,YAAY,CAAEG,EAAE,CACjC,KAAM,CAACC,KAAK,CAAEC,SAAS,CAAC,CAAGrB,QAAQ,CAAC,KAAK,CAAC,CAG1CsB,OAAO,CAACC,GAAG,CAAC,UAAU,CAAEL,QAAQ,CAAC,CAEjC,KAAM,CAAAM,WAAW,CAAG,KAAO,CAAAC,KAAK,EAAK,CACnC,GAAI,CAEF,KAAM,CAAAC,KAAK,CAAG,CACZC,QAAQ,CAAEF,KAAK,CAACE,QAAQ,CACxBC,QAAQ,CAAEH,KAAK,CAACG,QAClB,CAAC,CACDpB,KAAK,CAAC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