Lazar Kostic пре 3 година
родитељ
комит
7352f31f98

+ 4
- 2
components/cards/order-summary-card/OrderSummaryCard.jsx Прегледај датотеку

@@ -22,10 +22,12 @@ const OrderSummaryCard = ({ data }) => {
>
Order Summary
</Typography>
<Typography sx={{ mt: 4 }}>Items total:${data.totalPrice}</Typography>
<Typography sx={{ mt: 4 }}>
Items total:${data.totalPrice.toFixed(2)}
</Typography>
<Typography sx={{ mt: 1.5 }}>Shipping Costs: FREE</Typography>
<Typography sx={{ mt: 1.5, mb: 1.5 }}>
Total: ${data.totalPrice}
Total: ${data.totalPrice.toFixed(2)}
</Typography>
<Divider />
<Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}>

+ 23
- 1
components/forms/contact/ContactPageForm.jsx Прегледај датотеку

@@ -1,8 +1,10 @@
import {
Alert,
Box,
Button,
Container,
Grid,
Snackbar,
TextField,
Typography,
} from '@mui/material';
@@ -10,23 +12,29 @@ import { useFormik } from 'formik';
import { useTranslation } from 'next-i18next';
import Link from 'next/link';
import PropType from 'prop-types';
import React from 'react';
import React, { useState } from 'react';
import { BASE_PAGE } from '../../../constants/pages';
import { postQuestion } from '../../../requests/question/postQuestionRequest';
import { contactPageSchema } from '../../../schemas/contactSchema';

const ContactPageForm = () => {
const { t } = useTranslation('forms', 'contact', 'common');
const [open, setOpen] = useState(false);
//const [error] = useState({ hasError: false, errorMessage: '' });

const handleSubmit = async (values) => {
try {
postQuestion(values);
setOpen(true);
} catch (error) {
console.log(error);
}
};

const handleCloseNotification = () => {
setOpen(false);
};

const formik = useFormik({
initialValues: {
firstName: '',
@@ -42,6 +50,20 @@ const ContactPageForm = () => {

return (
<Container component="main" maxWidth="md" sx={{ mb: '60px' }}>
<Snackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={open}
autoHideDuration={3000}
onClose={handleCloseNotification}
>
<Alert
onClose={handleCloseNotification}
severity="success"
sx={{ width: '100%', backgroundColor: 'green', color: 'white' }}
>
Question submitted!
</Alert>
</Snackbar>
<Box
sx={{
marginTop: 32,

+ 4
- 5
components/products/featured-product/FeaturedProduct.jsx Прегледај датотеку

@@ -6,7 +6,7 @@ import { useStore, useStoreUpdate } from '../../../store/cart-context';
import ProductImage from './ProductImage';
import ProductInfo from './ProductInfo';

const FeaturedProduct = ({ product, bColor, image, side }) => {
const FeaturedProduct = ({ product, bColor, side }) => {
const matches = useMediaQuery('(min-width: 900px)');
const data = { name: product.name, description: product.description };
const { addCartValue } = useStoreUpdate();
@@ -34,9 +34,9 @@ const FeaturedProduct = ({ product, bColor, image, side }) => {
sx={{ display: { md: 'flex' }, alignItems: { md: 'center' } }}
>
{side === 'left' ? (
<ProductImage image={image}></ProductImage>
<ProductImage image={product.image}></ProductImage>
) : !matches ? (
<ProductImage image={image}></ProductImage>
<ProductImage image={product.image}></ProductImage>
) : (
<ProductInfo
bColor={bColor}
@@ -63,7 +63,7 @@ const FeaturedProduct = ({ product, bColor, image, side }) => {
inCart={inCart}
></ProductInfo>
) : (
<ProductImage image={image}></ProductImage>
<ProductImage image={product.image}></ProductImage>
)}
</Container>
</Box>
@@ -86,7 +86,6 @@ FeaturedProduct.propTypes = {
customID: PropType.string,
}),
bColor: PropType.string,
image: PropType.string,
side: PropType.string,
};
export default FeaturedProduct;

+ 0
- 1
components/products/featured-products-list/FeaturedPorductsList.jsx Прегледај датотеку

@@ -17,7 +17,6 @@ const FeaturedProductsList = ({ featuredProducts }) => {
key={i}
product={product}
bColor={i % 2 === 0 ? 'dark' : 'light'}
image="/images/Item 2.png"
side={i % 2 === 0 ? 'left' : 'right'}
></FeaturedProduct>
);

+ 24
- 1
components/profile-content/ProfileContent.jsx Прегледај датотеку

@@ -1,4 +1,4 @@
import { Grid, Typography } from '@mui/material';
import { Alert, Grid, Snackbar, Typography } from '@mui/material';
import { Box } from '@mui/system';
import { useSession } from 'next-auth/react';
import { useState } from 'react';
@@ -11,12 +11,17 @@ const ProfileContent = ({ orders }) => {
const { data: session } = useSession();
const { updateUserInfo } = useUserUpdate();
const [enableBtn, setEnableBtn] = useState(true);
const [open, setOpen] = useState(false);

const updateUserHandler = async (values) => {
try {
setEnableBtn(false);
updateUserInfo(values);
await updateUser(values, session.user._id);
setOpen(true);
setTimeout(() => {
setEnableBtn(true);
}, 5000);
} catch (error) {
console.log(error);
setTimeout(() => {
@@ -25,6 +30,10 @@ const ProfileContent = ({ orders }) => {
}
};

const handleCloseNotification = () => {
setOpen(false);
};

const mapOrdersToDom = () =>
orders.slice(-4).map((order, i) => (
<OrderCard
@@ -39,6 +48,20 @@ const ProfileContent = ({ orders }) => {

return (
<Grid container spacing={2} sx={{ py: 10, height: '100%', width: '100%' }}>
<Snackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={open}
autoHideDuration={3000}
onClose={handleCloseNotification}
>
<Alert
onClose={handleCloseNotification}
severity="success"
sx={{ width: '100%', backgroundColor: 'green', color: 'white' }}
>
User profile updated!
</Alert>
</Snackbar>
<Grid item xs={12}>
<Typography
variant="h3"

+ 1
- 1
components/review-content/ReviewContent.jsx Прегледај датотеку

@@ -124,7 +124,7 @@ const ReviewContent = () => {
}}
>
<Typography sx={{ fontSize: 18, fontWeight: 600 }}>
Total: ${orderData?.totalPrice}
Total: ${orderData?.totalPrice.toFixed(2)}
</Typography>
</Box>
</Grid>

+ 6
- 6
components/shipping-content/ShippingContent.jsx Прегледај датотеку

@@ -35,14 +35,14 @@ const ShippingContent = () => {
handleClose();
};

console.log(checkoutStorage);
const handleStripePayment = () => {
stripe({
lineItems: [
{
price: 'price_1Lg4MsDY7dvAcw2f1CGQaFFR',
quantity: 1,
},
],
lineItems: checkoutStorage.products.map((el) => ({
price: el.product.stripeID,
quantity: el.quantity,
})),
userInfo: checkoutStorage.userInfo,
});
setCookie(null, 'review-session', 'active', {
maxAge: 3600,

+ 10
- 1
hooks/use-stripe.js Прегледај датотеку

@@ -1,6 +1,6 @@
import { loadStripe } from '@stripe/stripe-js';

export const useStripe = async ({ lineItems }) => {
export const useStripe = async ({ lineItems, userInfo }) => {
let stripePromise = null;

const getStripe = () => {
@@ -14,6 +14,15 @@ export const useStripe = async ({ lineItems }) => {

await stripe.redirectToCheckout({
mode: 'payment',
customer_email: userInfo.email,
metadata: {
name: userInfo.fullName,
address: userInfo.address,
addressLine2: userInfo.address2,
city: userInfo.city,
country: userInfo.country,
postcode: userInfo.postcode,
},
lineItems,
successUrl: `${window.location.origin}/review`,
cancelUrl: `${window.location.origin}/cart`,

+ 5
- 0
models/product.js Прегледај датотеку

@@ -60,6 +60,11 @@ const ProductSchema = new mongoose.Schema({
required: [true, 'Please provide a custom id.'],
unique: [true, 'Custom id must be unique'],
},
stripeID: {
type: String,
required: [true, 'Please provide a stripe id.'],
unique: [true, 'Stripe id must be unique'],
},
});

const Product =

+ 1
- 1
models/question.js Прегледај датотеку

@@ -16,10 +16,10 @@ const QuestionSchema = new mongoose.Schema({
},
email: {
type: String,
unique: [true, 'Email must be unique.'],
required: [true, 'Please provide an email.'],
trim: true,
lowercase: true,
unique: false,
validate(value) {
if (!validator.isEmail(value)) {
throw new Error('Email is invalid');

Loading…
Откажи
Сачувај