From fa38e252c33582643bb019640e228fc09b6c315b Mon Sep 17 00:00:00 2001 From: Malai Raja Date: Thu, 14 Dec 2023 18:31:11 +0530 Subject: [PATCH] 14122023 --- nearlexpressbuild | 2 +- src/pages/nearle/accountsettings.js | 55 +- src/pages/nearle/clients/client.js | 708 +++++++++++++++-------- src/pages/nearle/clients/createclient.js | 204 ++++--- 4 files changed, 597 insertions(+), 372 deletions(-) diff --git a/nearlexpressbuild b/nearlexpressbuild index 7af3112..088ac08 160000 --- a/nearlexpressbuild +++ b/nearlexpressbuild @@ -1 +1 @@ -Subproject commit 7af311220edb54480cdd5bb19465df348e0aec9b +Subproject commit 088ac08a24e74023a6c68ba3dd63c5fcabd7a5e8 diff --git a/src/pages/nearle/accountsettings.js b/src/pages/nearle/accountsettings.js index 4e963ec..e900451 100644 --- a/src/pages/nearle/accountsettings.js +++ b/src/pages/nearle/accountsettings.js @@ -167,27 +167,21 @@ const Accountsettings = () => { - + // title={ + // - - - {info.companyname} - {/* - - {info.registrationno} - */} - - } + // + // + // {info.companyname} + // + // } > @@ -199,11 +193,28 @@ const Accountsettings = () => { + + Company Name + {info.companyname || ''} + + + + + + + + Registration No {info.registrationno || ''} + + + Info + {info.info || ''} + + @@ -266,13 +277,13 @@ const Accountsettings = () => { - + {/* {info.info || ''} - + */} diff --git a/src/pages/nearle/clients/client.js b/src/pages/nearle/clients/client.js index 340d3f8..af46cdc 100644 --- a/src/pages/nearle/clients/client.js +++ b/src/pages/nearle/clients/client.js @@ -10,7 +10,17 @@ import { useState, Fragment } from 'react'; // import AccessTimeOutlinedIcon from '@mui/icons-material/AccessTimeOutlined'; // import CustomerCard from 'sections/apps/customer/CustomerCard'; // import CustomerCardPage from 'pages/apps/customer/card'; -import { DeleteFilled, NotificationOutlined } from '@ant-design/icons'; +import { usePlacesWidget } from "react-google-autocomplete"; +import Autocomplete from "react-google-autocomplete"; +import { Autocomplete as Autocomplete1 } from '@mui/material'; +import Geocode from "react-geocode"; + + +import { + DeleteFilled, + NotificationOutlined, + // EditTwoTone, +} from '@ant-design/icons'; import { Empty } from 'antd'; import { @@ -43,14 +53,18 @@ import { // TableSortLabel, TableRow, Tooltip, - // List, - // ListItem, - // ListItemIcon, + List, + ListItem, + ListItemIcon, FormControl, OutlinedInput, InputAdornment, Popper, ClickAwayListener, + InputLabel, + TextField, + Select, + MenuItem, // Tooltip, // Badge, // Avatar @@ -78,6 +92,7 @@ import { // PhoneOutlined, // // EditTwoTone, DeleteTwoTone, + EditTwoTone, CheckCircleOutlined, MoreOutlined @@ -353,11 +368,118 @@ const Client = () => { const [loading1, setLoading1] = useState(false); const [staffdetaillist, setStaffdetaillist] = useState([]); const [anchorEl, setAnchorEl] = React.useState(null); - const [currentcustomerid, setCurrentcustomerid] = useState('') + const [currentcustomerid, setCurrentcustomerid] = useState(''); + + const [businessname, setBusinessname] = useState(''); + const [businessno, setBusinessno] = useState(''); + // const [role, setRole] = useState(''); + const [mobilenumber, setMobilenumber] = useState('') + const [emailaddress, setEmailaddress] = useState('') + const [city, setCity] = useState('') + const [zipcode, setZipcode] = useState(''); + const [address, setAddress] = useState(''); + const [state, setState] = useState(''); + const [suburb, setSuburb] = useState(''); + const [latlong, setLatlong] = useState({}); + const [profiledetails, setProfiledetails] = useState({}); + const [primarycontact, setPrimarycontact] = useState('') + const [firstname, setFirstname] = useState(''); + const [doorno, setDoorno] = useState(''); + const [landmark, setLandmark] = useState(''); + const [tenantinfo, setTenantinfo] = useState({}); + Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY); const handleClickAway = () => { setOpen(''); }; + useEffect(()=>{ + const fetchtenantinfo = async (tid) => { + // setLoading(true) + await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantinfo/?tenantid=${tid}`) + .then((res) => { + console.log(res) + if (res.data.status) { + setTenantinfo(res.data.details); + } + // setLoading(false) + }).catch((err) => { + console.log(err) + // setLoading(false) + }) + } + if(localStorage.getItem('tenantid')){ + fetchtenantinfo(localStorage.getItem('tenantid')) + } + },[]) + + useEffect(() => { + try { + Geocode.fromAddress(address).then( + (response) => { + if (response.status == 'OK') { + + + const { lat, lng } = response.results[0].geometry.location; + setLatlong({ + lat, lng + }) + console.log(response); + + + } + + }, (error) => { + console.log(error) + } + ); + + } catch (err) { + console.log(err) + + } + + }, [address]) + + const { ref: materialRef } = usePlacesWidget({ + apiKey: process.env.REACT_APP_GOOGLE_MAPS_API_KEY, + onPlaceSelected: (place) => { + + console.log(place) + + setAddress(place.formatted_address) + let city1, zipcode1, state1, suburb1; + for (let i = 0; i < place.address_components.length; i++) { + for (let j = 0; j < place.address_components[i].types.length; j++) { + switch (place.address_components[i].types[j]) { + case "locality": + city1 = place.address_components[i].long_name; + break; + case "administrative_area_level_1": + state1 = place.address_components[i].long_name; + break; + case "postal_code": + zipcode1 = place.address_components[i].long_name; + break; + case "sublocality": + suburb1 = place.address_components[i].long_name; + break; + } + } + } + setCity(city1 || '') + setState(state1 || ''); + setZipcode(zipcode1 || ''); + setSuburb(suburb1 || '') + + // setAddress(place.formatted_address) + }, + // inputAutocompleteValue: "country", + options: { + // componentRestrictions: 'us', + // types: ["establishment"] + types: ['address' || 'geocode'] + }, + }); // const fetchstafflog = async (uid, sid) => { // setLoading1(true) // try { @@ -494,6 +616,98 @@ const Client = () => { } } + const updateclient = async (sid) => { + console.log({ + "customerid": 1364, + "configid": 1, + "firstname": firstname, + "applocationid":tenantinfo.applolcationid, + "profileimage": "", + "dialcode": "+91", + "contactno": mobilenumber, + "devicetype": "", + "deviceid": "", + // "customertoken": "123", + "address":address, + "suburb": suburb, + "city": city, + "state": state, + "postcode": zipcode, + "landmark": landmark, + "doorno": doorno, + "latitude": latlong.lat.toString(), + "longitude": latlong.lng.toString(), + "tenantid": parseInt(localStorage.getItem('tenantid')), + //email,regno,tenantname + }) + setLoading(true) + try { + // await axios.get(`${process.env.REACT_APP_URL2}/orders/getorderprocessbystatus`) + await axios.put(`${process.env.REACT_APP_URL}/staffs/earnings/update12`, + { + "customerid": 1364, + "configid": 1, + "firstname": firstname, + "applocationid":tenantinfo.applolcationid, + "profileimage": "", + "dialcode": "+91", + "contactno": mobilenumber, + "devicetype": "", + "deviceid": "", + // "customertoken": "123", + "address":address, + "suburb": suburb, + "city": city, + "state": state, + "postcode": zipcode, + "landmark": landmark, + "doorno": doorno, + "latitude": latlong.lat.toString(), + "longitude": latlong.lng.toString(), + "tenantid": parseInt(localStorage.getItem('tenantid')), + //email,regno,tenantname + } + ) + + + .then((res) => { + console.log(res) + if (res.data.status) { + // let arr = [] + // res.data.Details.map((val, i) => { + // arr = [...arr, { ...val, sno: i + 1 }]; + // }) + // // setArr(arr) + // setRows(arr) + // console.log(res.data.Details) + // console.log(arr) + // setLoading(false) + enqueueSnackbar("Updated Successfully", { + variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' }, + autoHideDuration: 2000 + }) + // setTimeout(() => { + + // if (localStorage.getItem('appuserid')) { + // fetchtable(localStorage.getItem('appuserid')) + + // } + + // }, 2000) + } + + }).catch((err) => { + console.log(err) + setLoading(false) + }) + + } catch (err) { + console.log(err); + setLoading(false) + + } + } + const handleRequestSort = (event, property) => { const isAsc = orderBy === property && order === 'asc'; @@ -1070,6 +1284,25 @@ const Client = () => { + {(false) && + + + { + setFirstname(row.firstname); + setAddress(row.address) + setMobilenumber(row.contactno) + // setEmailaddress(row.) + setSuburb(row.suburb) + setCity(row.city) + setState(row.state) + setZipcode(row.postcode) + setDoorno(row.doorno) + setLandmark(row.landmark) + setExpandopen((expandopen === row.sno) ? '' : row.sno) + }}> + + + } @@ -1078,275 +1311,240 @@ const Client = () => { - - - {/* - - - - Contact Name - Contact No - - - - - - {(row.ordercontacts.map((val) => { - return <> - - {val.contactname} - {val.contactno} - - - })) - - } - - -
- -
*/} - - {(loading1) ? - <> - - - - + + + {/* + + Business Name + setBusinessname(e.target.value)} + value={businessname} + autoComplete='off' + /> + + + + Registration No + setBusinessno(e.target.value)} + value={businessno} + autoComplete='off' - + /> + + */} + + + Admin Name + setFirstname(e.target.value)} + value={firstname} + autoComplete='off' - : + /> + + + + + + + Phone Number + + + { }} + onChange={(e) => { + if (e.target.value.toString().length <= 10) { + setMobilenumber(e.target.value) + } + }} + value={mobilenumber} + autoComplete='off' + // disabled + sx={{ cursor: 'not-allowed' }} + /> + + + + + + Email Address + setEmailaddress(e.target.value)} + value={emailaddress} + autoComplete='off' - {/* Category */} - Clockin - Clockout - Actual Hrs - - Hrs Worked - - OT - - Deficit - - {/* Experience */} - - {/* Level */} - {/* City */} - Status - Action - - - - - {/* {row.ordeprocessInfo.map((val, i) => { */} - {staffdetaillist.map((val, i) => { - - return + /> + + - res.userid == val.userid)) ? '#f5f5f5' : '', ':hover': { - // backgroundColor: (staffarr.find((res) => res.userid == val.userid)) ? '#f5f5f5 !important' : '' - // } - }}> - - {i + 1} - + + + Address + { + setAddress(place.formatted_address) + let city1, state, zipcode1, suburb1; + for (let i = 0; i < place.address_components.length; i++) { + for (let j = 0; j < place.address_components[i].types.length; j++) { + switch (place.address_components[i].types[j]) { + case "locality": + city1 = place.address_components[i].long_name; + break; + case "administrative_area_level_1": + state = place.address_components[i].long_name; + break; + case "postal_code": + zipcode1 = place.address_components[i].long_name; + break; + case "sublocality": + suburb1 = place.address_components[i].long_name; + break; + } + } + } + setCity(city1 || '') + setState(state || ''); + setZipcode(zipcode1 || ''); + setSuburb(suburb1 || '') + }} + options={{ - - - - {val.staffname} - - - - - - - - - {dayjs(val.starttime) - // .utc() - .format('MM/DD/YYYY')} - {dayjs(val.starttime) - // .utc() - .format('hh:mm A')} - - - - - {dayjs(val.endtime) - // .utc() - .format('MM/DD/YYYY')} - {dayjs(val.endtime) - // .utc() - .format('hh:mm A')} - - - {/* {val.rolecost} */} + types: ['address' || 'geocode'] + }} + placeholder='Address' + value={address} + onChange={(e) => setAddress(e.target.value)} + /> + + - - - - + + + Suburb + setSuburb(e.target.value)} + value={suburb} + autoComplete='off' - - - - - - + /> + + + + + City + setCity(e.target.value)} + value={city} + autoComplete='off' - - - {val.workhours} - - {val.hoursworked} - - {val.overtime} - {val.shorttime} + /> + +
+ + + State + setState(e.target.value)} + value={state} + autoComplete='off' + /> + + + + + Post Code + setZipcode(e.target.value)} + value={zipcode} + autoComplete='off' - - + /> + + - {(val.orderstatus === 'pending') && + + + Door No + setDoorno(e.target.value)} + value={doorno} + autoComplete='off' - - } - {(val.orderstatus === 'cancelled') && + /> + + + + + Landmark + setLandmark(e.target.value)} + value={landmark} + autoComplete='off' - - - } - {(val.orderstatus === 'completed') && - - - } - {(val.orderstatus === 'processing') && - - } - {(val.orderstatus === 'assigned') && - - } - {(val.orderstatus === 'confirmed') && - - } - - {(val.orderstatus === 'active') && - - } - {(val.orderstatus === 'closed') && - - } - - - - - - - - {((val.verified == 0) && (val.orderstatus === 'completed')) && - <> - - - handleClick1(e, row.sno)} - onClick={(e) => { - setOpen(i + 1) - setAnchorEl(e.currentTarget); - }} - aria-describedby={`aria-${row.sno}`} - > - - - - - - { - - // setApproveid(true) - // setDisableid(false) - - // setExpandopen('') - // setRolestab(0) - staffearningsverify(val.staffearningsid) - // fetchclientbyid(row.tenantid, row.sno); - // fetchclientpricing(row.tenantid) - // setEditexpandopen(row.sno) - - handleClickAway() - }} - > - - - Verify - - - - - - - - } - - {(val.verified == 1) && - - <> - - - - - - - - - - } - - - - - - - }) - } - - - - } + /> + + + + + + + +
diff --git a/src/pages/nearle/clients/createclient.js b/src/pages/nearle/clients/createclient.js index 6156607..774f496 100644 --- a/src/pages/nearle/clients/createclient.js +++ b/src/pages/nearle/clients/createclient.js @@ -62,13 +62,13 @@ const Createclient = () => { const [suburb, setSuburb] = useState(''); const [latlong, setLatlong] = useState({}); const [profiledetails, setProfiledetails] = useState({}); - const [primarycontact,setPrimarycontact]=useState('') - const [firstname,setFirstname]=useState(''); - const [doorno,setDoorno]=useState(''); - const [landmark,setLandmark]=useState(''); + const [primarycontact, setPrimarycontact] = useState('') + const [firstname, setFirstname] = useState(''); + const [doorno, setDoorno] = useState(''); + const [landmark, setLandmark] = useState(''); const [tenantinfo, setTenantinfo] = useState({}); - + const navigate = useNavigate(); @@ -81,7 +81,7 @@ const Createclient = () => { useEffect(() => { // fetchprofiledetails(localStorage.getItem('appuserid')); // fetchprofiledetails(181); - if(localStorage.getItem('tenantid')){ + if (localStorage.getItem('tenantid')) { fetchtenantinfo(localStorage.getItem('tenantid')) } }, []) @@ -106,7 +106,7 @@ const Createclient = () => { console.log(error) } ); - + } catch (err) { console.log(err) @@ -193,7 +193,7 @@ const Createclient = () => { console.log(place) setAddress(place.formatted_address) - let city1, zipcode1, state1,suburb1; + let city1, zipcode1, state1, suburb1; for (let i = 0; i < place.address_components.length; i++) { for (let j = 0; j < place.address_components[i].types.length; j++) { switch (place.address_components[i].types[j]) { @@ -232,17 +232,17 @@ const Createclient = () => { const createprofile = async () => { console.log('res', businessname, businessno, mobilenumber, emailaddress, address, city, zipcode) - if (!businessname) { - opentoast('Fill Business name') - } else if (!businessno) { - opentoast('Fill Registration No') - } else if (!businessno) { - opentoast('Fill Registration No') - } else if (!firstname) { + // if (!businessname) { + // opentoast('Fill Business name') + // } else if (!businessno) { + // opentoast('Fill Registration No') + // } + // else + if (!firstname) { opentoast('Fill Full name') - } else if (!mobilenumber) { + } else if (!mobilenumber) { opentoast('Fill Mobile Number') - }else if (!emailaddress) { + } else if (!emailaddress) { opentoast('Fill emailaddress') } else if (!address) { opentoast('Fill Address') @@ -250,45 +250,46 @@ const Createclient = () => { opentoast('Fill City') } else if (!zipcode) { opentoast('Fill post code') - } else if (!suburb) { + } else if (!suburb) { opentoast('Fill suburb') } else if (!emailaddress) { opentoast('Fill emailaddress') } else if (!latlong.lat || !latlong.lng) { opentoast('Choose valid address') - } else { - let obj={ - "customerid":0, - "configid":1, - "firstname":firstname, - "applocationid":tenantinfo.applolcationid, - "profileimage":"", - "dialcode":"+91", - "contactno":mobilenumber, - "devicetype":"", - "deviceid":"", - "customertoken":"", - "address":address, - "suburb":suburb, - "city":city, - "state":state, - "postcode":zipcode, - "landmark":landmark, - "doorno":doorno, - "latitude":latlong.lat.toString(), - "longitude":latlong.lng.toString(), - "tenantid":parseInt(localStorage.getItem('tenantid')) + } else { + let obj = { + "customerid": 0, + "configid": 1, + "firstname": firstname, + "applocationid": tenantinfo.applolcationid, + "profileimage": "", + "dialcode": "+91", + "contactno": mobilenumber, + "devicetype": "", + "deviceid": "", + "customertoken": "", + "address": address, + "suburb": suburb, + "city": city, + "state": state, + "postcode": zipcode, + "landmark": landmark, + "doorno": doorno, + "latitude": latlong.lat.toString(), + "longitude": latlong.lng.toString(), + "tenantid": parseInt(localStorage.getItem('tenantid')), + "email" : emailaddress } - + console.log(obj) setLoading(true) try { - await axios.post(`${process.env.REACT_APP_URL}/customers/create`,obj) + await axios.post(`${process.env.REACT_APP_URL}/customers/create`, obj) .then((res) => { console.log(res) if (res.data.status) { - + enqueueSnackbar(' Created Successfully ', { variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' }, autoHideDuration: 2000 @@ -298,7 +299,7 @@ const Createclient = () => { // fetchprofiledetails(localStorage.getItem('appuserid')); // },2000) - }else if(res.data.message == "Customer Already available"){ + } else if (res.data.message == "Customer Already available") { enqueueSnackbar("Customer Already available", { variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' }, autoHideDuration: 2000 @@ -307,7 +308,7 @@ const Createclient = () => { setLoading(false) }).catch((err) => { console.log(err) - + setLoading(false) enqueueSnackbar(err.message, { variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' }, @@ -341,7 +342,7 @@ const Createclient = () => { - + {/* @@ -398,44 +399,18 @@ const Createclient = () => { - - Business Name - setBusinessname(e.target.value)} - value={businessname} - autoComplete='off' - /> - + - - Registration No - setBusinessno(e.target.value)} - value={businessno} - autoComplete='off' - - /> - + - - Name - setFirstname(e.target.value)} - value={firstname} - autoComplete='off' - - /> - + - {/* @@ -449,24 +424,65 @@ const Createclient = () => { /> - */} + - - + */} + - + - + + Business Name + setBusinessname(e.target.value)} + value={businessname} + autoComplete='off' + /> + + + + + Registration No + setBusinessno(e.target.value)} + value={businessno} + autoComplete='off' + + /> + + */} + + + Admin Name + setFirstname(e.target.value)} + value={firstname} + autoComplete='off' + + /> + + + + + Phone Number - - +91 - + { placeholder="Phone Number" // defaultValue="8654239581" // onBlur={() => { }} - onChange={(e) => { - if(e.target.value.toString().length <= 10){ + onChange={(e) => { + if (e.target.value.toString().length <= 10) { setMobilenumber(e.target.value) } - }} + }} value={mobilenumber} autoComplete='off' // disabled - sx={{cursor: 'not-allowed'}} + sx={{ cursor: 'not-allowed' }} /> Email Address @@ -506,7 +522,7 @@ const Createclient = () => { /> - + @@ -578,7 +594,7 @@ const Createclient = () => { /> - + Door No @@ -593,7 +609,7 @@ const Createclient = () => { - + Landmark { /> - +