fixed missing client
This commit is contained in:
parent
0ee9bd9ad9
commit
1c7ee54ff3
1 changed files with 20 additions and 20 deletions
|
|
@ -29,7 +29,7 @@ const steps = ['Shipping Address', 'Review Order', 'Payment', 'Confirmation'];
|
||||||
|
|
||||||
const CheckoutPage = () => {
|
const CheckoutPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { user } = useAuth();
|
const { user, userData } = useAuth();
|
||||||
const { items, total, itemCount } = useCart();
|
const { items, total, itemCount } = useCart();
|
||||||
const checkout = useCheckout();
|
const checkout = useCheckout();
|
||||||
const { createCheckoutSession, isLoading: isStripeLoading } = useStripe();
|
const { createCheckoutSession, isLoading: isStripeLoading } = useStripe();
|
||||||
|
|
@ -43,13 +43,13 @@ const CheckoutPage = () => {
|
||||||
|
|
||||||
// State for form data
|
// State for form data
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
firstName: user?.first_name || '',
|
firstName: userData?.first_name || '',
|
||||||
lastName: user?.last_name || '',
|
lastName: userData?.last_name || '',
|
||||||
email: user?.email || '',
|
email: userData?.email || '',
|
||||||
address: '',
|
address: '',
|
||||||
city: '',
|
city: '',
|
||||||
state: '',
|
province: '',
|
||||||
zipCode: '',
|
postalCode: '',
|
||||||
country: '',
|
country: '',
|
||||||
saveAddress: false,
|
saveAddress: false,
|
||||||
});
|
});
|
||||||
|
|
@ -93,7 +93,7 @@ const CheckoutPage = () => {
|
||||||
|
|
||||||
// Validate shipping form
|
// Validate shipping form
|
||||||
const validateShippingForm = () => {
|
const validateShippingForm = () => {
|
||||||
const requiredFields = ['firstName', 'lastName', 'email', 'address', 'city', 'state', 'zipCode', 'country'];
|
const requiredFields = ['firstName', 'lastName', 'email', 'address', 'city', 'province', 'postalCode', 'country'];
|
||||||
|
|
||||||
for (const field of requiredFields) {
|
for (const field of requiredFields) {
|
||||||
if (!formData[field]) {
|
if (!formData[field]) {
|
||||||
|
|
@ -126,7 +126,7 @@ const CheckoutPage = () => {
|
||||||
// Format shipping address
|
// Format shipping address
|
||||||
const shippingAddress = `${formData.firstName} ${formData.lastName}
|
const shippingAddress = `${formData.firstName} ${formData.lastName}
|
||||||
${formData.address}
|
${formData.address}
|
||||||
${formData.city}, ${formData.state} ${formData.zipCode}
|
${formData.city}, ${formData.province} ${formData.postalCode}
|
||||||
${formData.country}
|
${formData.country}
|
||||||
${formData.email}`;
|
${formData.email}`;
|
||||||
|
|
||||||
|
|
@ -265,10 +265,10 @@ ${formData.email}`;
|
||||||
<TextField
|
<TextField
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
id="state"
|
id="province"
|
||||||
label="State/Province"
|
label="Province/State"
|
||||||
name="state"
|
name="province"
|
||||||
value={formData.state}
|
value={formData.province}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
@ -276,10 +276,10 @@ ${formData.email}`;
|
||||||
<TextField
|
<TextField
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
id="zipCode"
|
id="postalCode"
|
||||||
label="Zip / Postal code"
|
label="Postal / Zip code"
|
||||||
name="zipCode"
|
name="postalCode"
|
||||||
value={formData.zipCode}
|
value={formData.postalCode}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
@ -358,7 +358,7 @@ ${formData.email}`;
|
||||||
{formData.address}
|
{formData.address}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography gutterBottom>
|
<Typography gutterBottom>
|
||||||
{formData.city}, {formData.state} {formData.zipCode}
|
{formData.city}, {formData.province} {formData.postalCode}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography gutterBottom>
|
<Typography gutterBottom>
|
||||||
{formData.country}
|
{formData.country}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue