rd address
Some checks failed
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled
Some checks failed
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
59eedaf102
commit
06f513f4f6
@ -1,11 +1,11 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const Axios = axios.create({
|
||||
baseURL: 'http://localhost:5000/',
|
||||
// baseURL: 'http://localhost:5000/',
|
||||
// baseURL: 'https://leadesh-whatsapp.onrender.com',
|
||||
// baseURL: "https://api.leadesh.com/",
|
||||
// baseURL: 'https://cheminova-api-2.onrender.com', // latest is this one
|
||||
// baseURL: 'https://api.cnapp.co.in', // latest is this one
|
||||
baseURL: 'https://api.cnapp.co.in', // latest is this one
|
||||
})
|
||||
|
||||
export default Axios
|
||||
|
@ -13,6 +13,8 @@ import {
|
||||
FormHelperText,
|
||||
} from '@mui/material'
|
||||
import React, { useState } from 'react'
|
||||
import Axios from '../../../axios'
|
||||
import { isAutheticated } from '../../../auth'
|
||||
|
||||
const AddressAndPayment = ({
|
||||
billTo,
|
||||
@ -22,9 +24,11 @@ const AddressAndPayment = ({
|
||||
paymentMode,
|
||||
setPaymentMode,
|
||||
handleTabChange,
|
||||
address,
|
||||
}) => {
|
||||
const [billToError, setBillToError] = useState(false)
|
||||
const [shipToError, setShipToError] = useState(false)
|
||||
|
||||
const [paymentModeError, setPaymentModeError] = useState(false)
|
||||
|
||||
const handleReviewOrderClick = (e) => {
|
||||
@ -59,6 +63,10 @@ const AddressAndPayment = ({
|
||||
handleTabChange(e, 2)
|
||||
}
|
||||
}
|
||||
const formatAddress = (address) => {
|
||||
const { street, city, state, postalCode } = address
|
||||
return `${street}, ${city}, ${state} - ${postalCode}`
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -79,15 +87,12 @@ const AddressAndPayment = ({
|
||||
label="Bill Address"
|
||||
onChange={(e) => setBillTo(e.target.value)}
|
||||
>
|
||||
<MenuItem value={'123, MG Road, Bengaluru, Karnataka - 560001'}>
|
||||
123, MG Road, Bengaluru, Karnataka - 560001
|
||||
</MenuItem>
|
||||
<MenuItem value={'456, Park Street, Kolkata, West Bengal - 700016'}>
|
||||
456, Park Street, Kolkata, West Bengal - 700016
|
||||
</MenuItem>
|
||||
<MenuItem value={'789, Connaught Place, New Delhi - 110001'}>
|
||||
789, Connaught Place, New Delhi - 110001
|
||||
</MenuItem>
|
||||
{address &&
|
||||
address.map((address) => (
|
||||
<MenuItem key={address._id} value={formatAddress(address)}>
|
||||
{formatAddress(address)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
{billToError && <FormHelperText>Bill Address is required</FormHelperText>}
|
||||
</FormControl>
|
||||
@ -103,16 +108,14 @@ const AddressAndPayment = ({
|
||||
label="Ship Address"
|
||||
onChange={(e) => setShipTo(e.target.value)}
|
||||
>
|
||||
<MenuItem value={'123, MG Road, Bengaluru, Karnataka - 560001'}>
|
||||
123, MG Road, Bengaluru, Karnataka - 560001
|
||||
</MenuItem>
|
||||
<MenuItem value={'456, Park Street, Kolkata, West Bengal - 700016'}>
|
||||
456, Park Street, Kolkata, West Bengal - 700016
|
||||
</MenuItem>
|
||||
<MenuItem value={'789, Connaught Place, New Delhi - 110001'}>
|
||||
789, Connaught Place, New Delhi - 110001
|
||||
</MenuItem>
|
||||
{address &&
|
||||
address.map((address) => (
|
||||
<MenuItem key={address._id} value={formatAddress(address)}>
|
||||
{formatAddress(address)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
{shipToError && <FormHelperText>Ship Address is required</FormHelperText>}
|
||||
</FormControl>
|
||||
</Grid>
|
||||
|
@ -20,6 +20,8 @@ import {
|
||||
selectCartItems,
|
||||
selectCartSubtotal,
|
||||
} from '../../../redux-store/CartStore/ducs'
|
||||
import { isAutheticated } from '../../../auth'
|
||||
import Axios from '../../../axios'
|
||||
|
||||
const TabItem = ({ label, active, complete, onClick, reference, stepNumber }) => (
|
||||
<Box
|
||||
@ -107,11 +109,30 @@ const Cart = () => {
|
||||
const dispatch = useDispatch()
|
||||
const [paymentMode, setPaymentMode] = useState('')
|
||||
const cartItems = useSelector(selectCartItems)
|
||||
const totalItemCount = useSelector(selectCartItemCount)
|
||||
const cartSubtotal = useSelector(selectCartSubtotal)
|
||||
|
||||
const [address, setAddress] = useState([])
|
||||
const token = isAutheticated()
|
||||
const [value, setValue] = useState(0)
|
||||
|
||||
const getAddress = async () => {
|
||||
try {
|
||||
const res = await Axios.get('/api/rd/shipping/address/', {
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
setAddress(res?.data?.UserShippingAddress)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
getAddress()
|
||||
}, [])
|
||||
const handleTabChange = (event, newValue) => {
|
||||
console.log(newValue)
|
||||
if (value === 3 && newValue !== 3) {
|
||||
setPaymentMode('')
|
||||
setBillTo('')
|
||||
@ -217,6 +238,7 @@ const Cart = () => {
|
||||
paymentMode={paymentMode}
|
||||
setPaymentMode={setPaymentMode}
|
||||
handleTabChange={handleTabChange}
|
||||
address={address}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user