Pārlūkot izejas kodu

refactor: localization

bug-fix-v1
ntasicc pirms 3 gadiem
vecāks
revīzija
8f7fe5bbf1
32 mainītis faili ar 178 papildinājumiem un 106 dzēšanām
  1. 7
    9
      components/cards/cart-card/CartCard.jsx
  2. 12
    3
      components/cards/order-card/OrderCard.jsx
  3. 10
    9
      components/cards/order-summary-card/OrderSummaryCard.jsx
  4. 3
    1
      components/cart-content/CartContent.jsx
  5. 4
    5
      components/checkout-content/CheckoutContent.jsx
  6. 6
    4
      components/company-info/CompanyInfo.jsx
  7. 3
    1
      components/empty-cart/EmptyCart.jsx
  8. 3
    1
      components/features/FeatureItem.jsx
  9. 4
    1
      components/features/Features.jsx
  10. 3
    6
      components/features/items.js
  11. 9
    10
      components/forms/contact/ContactPageForm.jsx
  12. 10
    8
      components/forms/shipping-details/ShippingDetailsForm.jsx
  13. 9
    8
      components/hero/Hero.jsx
  14. 1
    1
      components/layout/steps-title/StepTitle.jsx
  15. 1
    0
      components/loader/route-loader/CircularIndeterminate.jsx
  16. 3
    1
      components/products/featured-product/ProductInfo.jsx
  17. 6
    4
      components/profile-content/ProfileContent.jsx
  18. 14
    9
      components/review-content/ReviewContent.jsx
  19. 5
    6
      components/shipping-content/ShippingContent.jsx
  20. 4
    2
      components/shipping-content/shipping-btnGroup/ButtonGroup.jsx
  21. 9
    4
      components/shipping-content/shipping-data/ShippingData.jsx
  22. 9
    0
      pages/cart/index.js
  23. 7
    1
      pages/checkout/index.js
  24. 1
    1
      pages/contact.js
  25. 4
    3
      pages/index.js
  26. 8
    1
      pages/profile/index.js
  27. 4
    1
      pages/review/index.js
  28. 7
    1
      pages/shipping/index.js
  29. 2
    1
      public/locales/en/contact.json
  30. 2
    1
      public/locales/en/home.json
  31. 3
    2
      public/locales/en/profile.json
  32. 5
    1
      styles/muiTheme.js

+ 7
- 9
components/cards/cart-card/CartCard.jsx Parādīt failu

import { Box, Button, ButtonGroup, Card, Typography } from '@mui/material'; import { Box, Button, ButtonGroup, Card, Typography } from '@mui/material';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
import PropType from 'prop-types'; import PropType from 'prop-types';
import { useState } from 'react'; import { useState } from 'react';


const CartCard = ({ product, initialQuantity, remove, updateQuantity }) => { const CartCard = ({ product, initialQuantity, remove, updateQuantity }) => {
const [quantity, setQuantity] = useState(initialQuantity); const [quantity, setQuantity] = useState(initialQuantity);

// useEffect(() => {
// updateQuantity(product?.customID, quantity);
// }, [quantity]);

const { t } = useTranslation('cart');
return ( return (
<Card <Card
sx={{ sx={{
fontSize: 14, fontSize: 14,
}} }}
> >
Quantity
{t('cart:quantity')}
</Typography> </Typography>
<ButtonGroup <ButtonGroup
size="small" size="small"
width: 25, width: 25,
}} }}
onClick={() => { onClick={() => {
if (quantity > 0) {
if (quantity > 1) {
updateQuantity(product?.customID, quantity - 1); updateQuantity(product?.customID, quantity - 1);
setQuantity((prevState) => prevState - 1); setQuantity((prevState) => prevState - 1);
} }
} }
onClick={() => remove(product.customID)} onClick={() => remove(product.customID)}
> >
Remove
{t('cart:remove')}
</Button> </Button>
</Box> </Box>
<Box <Box
fontSize: { xs: 15, md: 18 }, fontSize: { xs: 15, md: 18 },
}} }}
> >
Price: ${product?.price}
{t('cart:priceTag')}
{product?.price}
</Typography> </Typography>
</Box> </Box>
</Box> </Box>

+ 12
- 3
components/cards/order-card/OrderCard.jsx Parādīt failu

import { Card, Divider, Typography } from '@mui/material'; import { Card, Divider, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import PropType from 'prop-types'; import PropType from 'prop-types';


const OrderCard = ({ data }) => { const OrderCard = ({ data }) => {
const { t } = useTranslation('profile');
return ( return (
<Card <Card
height="100%" height="100%"
}} }}
> >
<Typography sx={{ fontWeight: 600 }}> <Typography sx={{ fontWeight: 600 }}>
Order placed on: {data.date}
{t('profile:orderDate')}
{data.date}
</Typography> </Typography>
<Divider /> <Divider />
<Typography sx={{ mt: 1 }}>By: {data.name}</Typography>
<Typography>Total: ${data.totalPrice.toFixed(2)}</Typography>
<Typography sx={{ mt: 1 }}>
{t('profile:by')}
{data.name}
</Typography>
<Typography>
{t('profile:total')}
{data.totalPrice.toFixed(2)}
</Typography>
</Box> </Box>
</Card> </Card>
); );

+ 10
- 9
components/cards/order-summary-card/OrderSummaryCard.jsx Parādīt failu

import { Button, Card, Divider, Typography } from '@mui/material'; import { Button, Card, Divider, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { setCookie } from 'nookies'; import { setCookie } from 'nookies';
import PropType from 'prop-types'; import PropType from 'prop-types';


const OrderSummaryCard = ({ data }) => { const OrderSummaryCard = ({ data }) => {
const { t } = useTranslation('cart');
const router = useRouter(); const router = useRouter();
return ( return (
<Card sx={{ p: 3, width: '100%', mb: 2, backgroundColor: '#f1f1f1' }}> <Card sx={{ p: 3, width: '100%', mb: 2, backgroundColor: '#f1f1f1' }}>
width: '100%', width: '100%',
}} }}
> >
Order Summary
{t('cart:orderTitle')}
</Typography> </Typography>
<Typography sx={{ mt: 4 }}> <Typography sx={{ mt: 4 }}>
Items total:${data.totalPrice.toFixed(2)}
{t('cart:itemsTotal')}
{data.totalPrice.toFixed(2)}
</Typography> </Typography>
<Typography sx={{ mt: 1.5 }}>Shipping Costs: FREE</Typography>
<Typography sx={{ mt: 1.5 }}>{t('cart:shipping')}</Typography>
<Typography sx={{ mt: 1.5, mb: 1.5 }}> <Typography sx={{ mt: 1.5, mb: 1.5 }}>
Total: ${data.totalPrice.toFixed(2)}
{t('cart:total')}
{data.totalPrice.toFixed(2)}
</Typography> </Typography>
<Divider /> <Divider />
<Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}> <Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}>
}); });
}} }}
> >
Proceed to Checkout
{t('cart:proceed')}
</Button> </Button>
</Box> </Box>
<Typography sx={{ mt: 3, fontSize: 13 }}>
Once the checkout process begins you will have an hour to complete your
checkout otherwise you will be returned back to the cart to start over.
</Typography>
<Typography sx={{ mt: 3, fontSize: 13 }}>{t('cart:infoMsg')}</Typography>
</Card> </Card>
); );
}; };

+ 3
- 1
components/cart-content/CartContent.jsx Parādīt failu

import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import { destroyCookie } from 'nookies'; import { destroyCookie } from 'nookies';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useStore, useStoreUpdate } from '../../store/cart-context'; import { useStore, useStoreUpdate } from '../../store/cart-context';
import StepTitle from '../layout/steps-title/StepTitle'; import StepTitle from '../layout/steps-title/StepTitle';


const CartContent = () => { const CartContent = () => {
const { t } = useTranslation('cart');
const { cartStorage, totalPrice, totalQuantity } = useStore(); const { cartStorage, totalPrice, totalQuantity } = useStore();
const { removeCartValue, updateItemQuantity } = useStoreUpdate(); const { removeCartValue, updateItemQuantity } = useStoreUpdate();
const [cartInfo, setCartInfo] = useState({ const [cartInfo, setCartInfo] = useState({


return ( return (
<PageWrapper> <PageWrapper>
<StepTitle title="Items in Your Cart" breadcrumbsArray={['Cart']} />
<StepTitle title={t('cart:cartTitle')} breadcrumbsArray={['Cart']} />
<ContentContainer> <ContentContainer>
<Box sx={{ mt: 2, mr: { md: 2, minWidth: '65%' }, mb: { xs: 6 } }}> <Box sx={{ mt: 2, mr: { md: 2, minWidth: '65%' }, mb: { xs: 6 } }}>
{mapProductsToDom()} {mapProductsToDom()}

+ 4
- 5
components/checkout-content/CheckoutContent.jsx Parādīt failu

import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useSession } from 'next-auth/react'; import { useSession } from 'next-auth/react';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { setCookie } from 'nookies'; import { setCookie } from 'nookies';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import PageDescription from '../page-description/PageDescription'; import PageDescription from '../page-description/PageDescription';


const CheckoutContent = () => { const CheckoutContent = () => {
const { t } = useTranslation('cart');
const { cartStorage } = useStore(); const { cartStorage } = useStore();
const { addCheckoutValue } = useCheckoutDataUpdate(); const { addCheckoutValue } = useCheckoutDataUpdate();


return ( return (
<PageWrapper> <PageWrapper>
<StepTitle <StepTitle
title="Items in Your Cart"
title={t('checkout:title')}
breadcrumbsArray={['Cart', 'Checkout']} breadcrumbsArray={['Cart', 'Checkout']}
/> />
<PageDescription
description="The following fields will be used as the shipping details for your
order"
/>
<PageDescription description={t('checkout:subtitle')} />
<ContentContainer> <ContentContainer>
<Box flexGrow={1} sx={{ minWidth: '65%' }}> <Box flexGrow={1} sx={{ minWidth: '65%' }}>
<ShippingDetailsForm <ShippingDetailsForm

+ 6
- 4
components/company-info/CompanyInfo.jsx Parādīt failu

import { Typography } from '@mui/material'; import { Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
const CompanyInfo = () => { const CompanyInfo = () => {
const { t } = useTranslation('home');
return ( return (
<> <>
<Box <Box
color: 'white', color: 'white',
}} }}
> >
We are waiting for you!
{t('home:infoTitle')}
</Typography> </Typography>
<Box <Box
sx={{ sx={{
pl: 2, pl: 2,
}} }}
> >
Nis, Zetska 36
{t('home:address')}
</Typography> </Typography>
</Box> </Box>
<Box <Box
mr: -4, mr: -4,
}} }}
> >
Every day: 09 to 18
{t('home:open')}
</Typography> </Typography>
</Box> </Box>
<Box <Box
mr: -3, mr: -3,
}} }}
> >
info@coffee.com
{t('home:mail')}
</Typography> </Typography>
</Box> </Box>
</Box> </Box>

+ 3
- 1
components/empty-cart/EmptyCart.jsx Parādīt failu

import { Typography } from '@mui/material'; import { Typography } from '@mui/material';
import { useTranslation } from 'next-i18next';


const EmptyCart = () => { const EmptyCart = () => {
const { t } = useTranslation('cart');
return ( return (
<Typography <Typography
sx={{ sx={{
mb: { md: 5 }, mb: { md: 5 },
}} }}
> >
Your cart is currently empty
{t('cart:empty')}
</Typography> </Typography>
); );
}; };

+ 3
- 1
components/features/FeatureItem.jsx Parādīt failu

import { Container, Typography } from '@mui/material'; import { Container, Typography } from '@mui/material';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';


const FeatureItem = ({ image, alt, description }) => { const FeatureItem = ({ image, alt, description }) => {
const { t } = useTranslation('home');
return ( return (
<Container <Container
sx={{ sx={{
px: 6, px: 6,
}} }}
> >
{description}
{t(description)}
</Typography> </Typography>
</Container> </Container>
); );

+ 4
- 1
components/features/Features.jsx Parādīt failu

import { Container, Divider, Typography } from '@mui/material'; import { Container, Divider, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
import FeatureItem from './FeatureItem'; import FeatureItem from './FeatureItem';
import items from './items'; import items from './items';


const Features = () => { const Features = () => {
const { t } = useTranslation('home');
return ( return (
<> <>
<Box <Box
color: 'primary.main', color: 'primary.main',
textAlign: 'center', textAlign: 'center',
mt: 5, mt: 5,
fontFamily: ['Indie Flower', 'cursive'].join(','),
}} }}
> >
Natural coffee
{t('home:coffeeTitle')}
</Typography> </Typography>
</Container> </Container>
<Container <Container

+ 3
- 6
components/features/items.js Parādīt failu

const features = [ const features = [
{ {
id: 1, id: 1,
description:
'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using Content here, content here, making it look like readable English.',
description: 'home:factory',
alt: 'image description', alt: 'image description',
image: '/images/factory.svg', image: '/images/factory.svg',
}, },
{ {
id: 2, id: 2,
description:
'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using Content here, content here, making it look like readable English.',
description: 'home:machine',
alt: 'image description', alt: 'image description',
image: '/images/coffee-machine.svg', image: '/images/coffee-machine.svg',
}, },
{ {
id: 3, id: 3,
description:
'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using Content here, content here, making it look like readable English.',
description: 'home:coffeeBeans',
alt: 'image description', alt: 'image description',
image: '/images/coffee-beans.svg', image: '/images/coffee-beans.svg',
}, },

+ 9
- 10
components/forms/contact/ContactPageForm.jsx Parādīt failu

import { contactPageSchema } from '../../../schemas/contactSchema'; import { contactPageSchema } from '../../../schemas/contactSchema';


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


const handleSubmit = async (values) => { const handleSubmit = async (values) => {
try { try {
severity="success" severity="success"
sx={{ width: '100%', backgroundColor: 'green', color: 'white' }} sx={{ width: '100%', backgroundColor: 'green', color: 'white' }}
> >
Question submitted!
{t('contact:notification')}
</Alert> </Alert>
</Snackbar> </Snackbar>
<Box <Box
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Typography fontSize={48}>{t('contact:Title')}</Typography>
<Typography fontSize={48}>{t('contact:title')}</Typography>
<Box <Box
component="form" component="form"
onSubmit={formik.handleSubmit} onSubmit={formik.handleSubmit}
> >
<TextField <TextField
name="firstName" name="firstName"
label={t('forms:FirstName')}
label={t('contact:firstName')}
margin="normal" margin="normal"
value={formik.values.firstName} value={formik.values.firstName}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="lastName" name="lastName"
label={t('forms:LastName')}
label={t('contact:lastName')}
margin="normal" margin="normal"
value={formik.values.lastName} value={formik.values.lastName}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="email" name="email"
label={t('forms:Email')}
label={t('contact:email')}
margin="normal" margin="normal"
value={formik.values.email} value={formik.values.email}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="message" name="message"
label={t('forms:Message')}
label={t('contact:message')}
multiline multiline
margin="normal" margin="normal"
value={formik.values.message} value={formik.values.message}
sx={{ mt: 3, mb: 2 }} sx={{ mt: 3, mb: 2 }}
fullWidth fullWidth
> >
{t('contact:SendBtn')}
{t('contact:sendBtn')}
</Button> </Button>
<Grid container justifyContent="center"> <Grid container justifyContent="center">
<Link href={BASE_PAGE}> <Link href={BASE_PAGE}>
<Typography>{t('common:Back')}</Typography>
<Typography>{t('contact:back')}</Typography>
</Link> </Link>
</Grid> </Grid>
</Box> </Box>

+ 10
- 8
components/forms/shipping-details/ShippingDetailsForm.jsx Parādīt failu

import { Box, Button, Card, TextField } from '@mui/material'; import { Box, Button, Card, TextField } from '@mui/material';
import { useFormik } from 'formik'; import { useFormik } from 'formik';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import PropType from 'prop-types'; import PropType from 'prop-types';
import { useState } from 'react'; import { useState } from 'react';
submitHandler, submitHandler,
enableBtn = true, enableBtn = true,
}) => { }) => {
const { t } = useTranslation('addressForm');
const [error] = useState({ hasError: false, errorMessage: '' }); const [error] = useState({ hasError: false, errorMessage: '' });
const { userStorage } = useUserData(); const { userStorage } = useUserData();
const router = useRouter(); const router = useRouter();
> >
<TextField <TextField
name="fullName" name="fullName"
label="Name"
label={t('addressForm:name')}
margin="normal" margin="normal"
value={formik.values.fullName} value={formik.values.fullName}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="address" name="address"
label="Address"
label={t('addressForm:address')}
margin="normal" margin="normal"
value={formik.values.address} value={formik.values.address}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="address2" name="address2"
label="Address Line 2"
label={t('addressForm:address2')}
margin="normal" margin="normal"
value={formik.values.address2} value={formik.values.address2}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="city" name="city"
label="City"
label={t('addressForm:city')}
margin="normal" margin="normal"
value={formik.values.city} value={formik.values.city}
onChange={formik.handleChange} onChange={formik.handleChange}
<Box sx={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
<TextField <TextField
name="country" name="country"
label="Country"
label={t('addressForm:country')}
margin="normal" margin="normal"
value={formik.values.country} value={formik.values.country}
onChange={formik.handleChange} onChange={formik.handleChange}
/> />
<TextField <TextField
name="postcode" name="postcode"
label="Postal Code"
label={t('addressForm:postcode')}
margin="normal" margin="normal"
value={formik.values.postcode} value={formik.values.postcode}
onChange={formik.handleChange} onChange={formik.handleChange}
router.push('/cart'); router.push('/cart');
}} }}
> >
Back to cart
{t('addressForm:back')}
</Button> </Button>
)} )}
<Button <Button
submitHandler; submitHandler;
}} }}
> >
{isCheckout ? 'Proceed to shipping' : 'Submit Details'}
{isCheckout ? t('addressForm:shipping') : t('addressForm:submit')}
</Button> </Button>
</Box> </Box>
</Box> </Box>

+ 9
- 8
components/hero/Hero.jsx Parādīt failu

import { Button, Typography } from '@mui/material'; import { Button, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { PRODUCTS_PAGE } from '../../constants/pages'; import { PRODUCTS_PAGE } from '../../constants/pages';


const Hero = () => { const Hero = () => {
const { t } = useTranslation('home');
const router = useRouter(); const router = useRouter();
return ( return (
<> <>
fontSize: { xs: '96px', md: '64px', lg: '96px' }, fontSize: { xs: '96px', md: '64px', lg: '96px' },
ml: 10, ml: 10,
color: 'white', color: 'white',
fontFamily: ['Indie Flower', 'cursive'].join(','),
}} }}
> >
Its a
{t('home:mainTitle1')}
</Typography> </Typography>
<Typography <Typography
variant="h1" variant="h1"
fontSize: { xs: '96px', md: '64px', lg: '96px' }, fontSize: { xs: '96px', md: '64px', lg: '96px' },
ml: 10, ml: 10,
color: 'white', color: 'white',
fontFamily: ['Indie Flower', 'cursive'].join(','),
}} }}
> >
{' '}
Coffee Break
{t('home:mainTitle2')}
</Typography> </Typography>
</Box> </Box>
<Typography <Typography
pr: '20%', pr: '20%',
}} }}
> >
If you drink coffee regulary you will know the difference between
fresh coffee and old coffee. Our goal is to provide the freshest
coffee beans in each day.
{t('home:description')}
</Typography> </Typography>
<Box <Box
sx={{ sx={{
}} }}
onClick={() => router.push(PRODUCTS_PAGE)} onClick={() => router.push(PRODUCTS_PAGE)}
> >
Explore the Shop
{t('home:exploreBtn')}
</Button> </Button>
<Button <Button
disableRipple disableRipple
/> />
} }
> >
How to make
{t('home:howTo')}
</Button> </Button>
</Box> </Box>
</Box> </Box>

+ 1
- 1
components/layout/steps-title/StepTitle.jsx Parādīt failu

<> <>
<Grid item xs={12}> <Grid item xs={12}>
<Typography <Typography
variant="h3"
variant="h4"
sx={{ sx={{
ml: { xs: 2, md: 12 }, ml: { xs: 2, md: 12 },
mt: 12, mt: 12,

+ 1
- 0
components/loader/route-loader/CircularIndeterminate.jsx Parādīt failu

top: '48%', top: '48%',
left: '48%', left: '48%',
marginX: 'auto', marginX: 'auto',
color: 'primary.dark',
}} }}
> >
<CircularProgress color="inherit" size={60} thickness={4} /> <CircularProgress color="inherit" size={60} thickness={4} />

+ 3
- 1
components/products/featured-product/ProductInfo.jsx Parādīt failu

import { Button, ButtonGroup, Typography } from '@mui/material'; import { Button, ButtonGroup, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import Image from 'next/image'; import Image from 'next/image';
import PropType from 'prop-types'; import PropType from 'prop-types';
import { useState } from 'react'; import { useState } from 'react';


const ProductInfo = ({ data, bColor, addProductToCart, inCart }) => { const ProductInfo = ({ data, bColor, addProductToCart, inCart }) => {
const { t } = useTranslation('home');
const [quantity, setQuantity] = useState(1); const [quantity, setQuantity] = useState(1);


const handleIncrement = () => { const handleIncrement = () => {
disabled={inCart} disabled={inCart}
onClick={() => addProductToCart(quantity)} onClick={() => addProductToCart(quantity)}
> >
{inCart ? 'In Cart' : 'Add to cart'}
{inCart ? t('home:in') : t('home:add')}
</Button> </Button>
</Box> </Box>
</Box> </Box>

+ 6
- 4
components/profile-content/ProfileContent.jsx Parādīt failu

import { Alert, Snackbar, Typography } from '@mui/material'; import { Alert, Snackbar, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useSession } from 'next-auth/react'; import { useSession } from 'next-auth/react';
import { useTranslation } from 'next-i18next';
import { useState } from 'react'; import { useState } from 'react';
import { updateUser } from '../../requests/user/userUpdateRequest'; import { updateUser } from '../../requests/user/userUpdateRequest';
import { useUserUpdate } from '../../store/user-context'; import { useUserUpdate } from '../../store/user-context';
import StepTitle from '../layout/steps-title/StepTitle'; import StepTitle from '../layout/steps-title/StepTitle';


const ProfileContent = ({ orders }) => { const ProfileContent = ({ orders }) => {
const { t } = useTranslation('profile');
const { data: session } = useSession(); const { data: session } = useSession();
const { updateUserInfo } = useUserUpdate(); const { updateUserInfo } = useUserUpdate();
const [enableBtn, setEnableBtn] = useState(true); const [enableBtn, setEnableBtn] = useState(true);


return ( return (
<PageWrapper> <PageWrapper>
<StepTitle title="Welcome to your user account" />
<StepTitle title={t('profile:title')} />
<Snackbar <Snackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }} anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={open} open={open}
severity="success" severity="success"
sx={{ width: '100%', backgroundColor: 'green', color: 'white' }} sx={{ width: '100%', backgroundColor: 'green', color: 'white' }}
> >
User profile updated!
{t('profile:notification')}
</Alert> </Alert>
</Snackbar> </Snackbar>


<ContentContainer> <ContentContainer>
<Box flexGrow={1} sx={{ minWidth: '65%' }}> <Box flexGrow={1} sx={{ minWidth: '65%' }}>
<Typography sx={{ fontSize: 20, mb: 3 }}> <Typography sx={{ fontSize: 20, mb: 3 }}>
Save details for later
{t('profile:subtitle1')}
</Typography> </Typography>
<ShippingDetailsForm <ShippingDetailsForm
submitHandler={updateUserHandler} submitHandler={updateUserHandler}
<Typography <Typography
sx={{ fontSize: 20, mb: { xs: -2, md: 3 }, ml: { md: 3 } }} sx={{ fontSize: 20, mb: { xs: -2, md: 3 }, ml: { md: 3 } }}
> >
Previous Orders
{t('profile:subtitle2')}
</Typography> </Typography>
<CardContainer>{mapOrdersToDom()}</CardContainer> <CardContainer>{mapOrdersToDom()}</CardContainer>
</Box> </Box>

+ 14
- 9
components/review-content/ReviewContent.jsx Parādīt failu

import { Button, Typography } from '@mui/material'; import { Button, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { destroyCookie } from 'nookies'; import { destroyCookie } from 'nookies';


let initialRender = true; let initialRender = true;


const ReviewContent = () => { const ReviewContent = () => {
const { t } = useTranslation('review');
const { checkoutStorage } = useCheckoutData(); const { checkoutStorage } = useCheckoutData();
const { parseCheckoutValue, clearCheckout } = useCheckoutDataUpdate(); const { parseCheckoutValue, clearCheckout } = useCheckoutDataUpdate();
const { clearCart } = useStoreUpdate(); const { clearCart } = useStoreUpdate();
fontSize: 22, fontSize: 22,
}} }}
> >
ORDER COMPLETE SUCCESSFULLY
{t('review:orderMsg')}
</Typography> </Typography>
</Box> </Box>
<Box sx={{ mt: 1 }}> <Box sx={{ mt: 1 }}>
textAlign: 'center', textAlign: 'center',
}} }}
> >
Thank you for placing your order with us. We wll get to work on
sending your order as soon as possible
{t('review:note')}
</Typography> </Typography>
</Box> </Box>
<Box sx={{ mt: 1 }}> <Box sx={{ mt: 1 }}>
fontWeight: 600, fontWeight: 600,
}} }}
> >
Order Summary
{t('review:title')}
</Typography> </Typography>
</Box> </Box>
<Box <Box
}} }}
> >
<Typography sx={{ fontSize: 18, fontWeight: 600 }}> <Typography sx={{ fontSize: 18, fontWeight: 600 }}>
Order placed on: {orderData.time}
{t('review:date')}
{orderData.time}
</Typography> </Typography>
</Box> </Box>
<Box <Box
}} }}
> >
<Typography sx={{ fontSize: 18, fontWeight: 600 }}> <Typography sx={{ fontSize: 18, fontWeight: 600 }}>
Email: {orderData?.shippingAddress?.email}
{t('review:email')}
{orderData?.shippingAddress?.email}
</Typography> </Typography>
</Box> </Box>
<Box <Box
}} }}
> >
<Typography sx={{ fontSize: 18, fontWeight: 600 }}> <Typography sx={{ fontSize: 18, fontWeight: 600 }}>
Total: ${orderData?.totalPrice}
{t('review:total')}
{orderData?.totalPrice?.toFixed(2)}
</Typography> </Typography>
</Box> </Box>
<Box <Box
}} }}
> >
<Typography sx={{ fontSize: 18, fontWeight: 600 }}> <Typography sx={{ fontSize: 18, fontWeight: 600 }}>
Shipping Address: {orderData?.shippingAddress?.address},{' '}
{t('review:shipping')}
{orderData?.shippingAddress?.address},{' '}
{orderData?.shippingAddress?.city},{' '} {orderData?.shippingAddress?.city},{' '}
{orderData?.shippingAddress?.country},{' '} {orderData?.shippingAddress?.country},{' '}
{orderData?.shippingAddress?.postcode} {orderData?.shippingAddress?.postcode}
router.push('/'); router.push('/');
}} }}
> >
Back to Home
{t('review:back')}
</Button> </Button>
</Box> </Box>
</Box> </Box>

+ 5
- 6
components/shipping-content/ShippingContent.jsx Parādīt failu

import { Checkbox, FormControlLabel } from '@mui/material'; import { Checkbox, FormControlLabel } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { setCookie } from 'nookies'; import { setCookie } from 'nookies';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import ShippingModal from './shipping-modal/ShippingModal'; import ShippingModal from './shipping-modal/ShippingModal';


const ShippingContent = () => { const ShippingContent = () => {
const { t } = useTranslation('shipping');
const { checkoutStorage } = useCheckoutData(); const { checkoutStorage } = useCheckoutData();
const { changeContact, changeShippingData } = useCheckoutDataUpdate(); const { changeContact, changeShippingData } = useCheckoutDataUpdate();
const [open, setOpen] = useState({ isOpen: false, type: '' }); const [open, setOpen] = useState({ isOpen: false, type: '' });
return ( return (
<PageWrapper> <PageWrapper>
<StepTitle <StepTitle
title="Shipping"
title={t('shipping:title')}
breadcrumbsArray={['Cart', 'Checkout', 'Shipping']} breadcrumbsArray={['Cart', 'Checkout', 'Shipping']}
/> />
<PageDescription
description="The following fields will be used as the shipping details for your
order"
/>
<PageDescription description={t('shipping:subtitle')} />
<ContentContainer> <ContentContainer>
<Box flexGrow={1} sx={{ minWidth: '65%' }}> <Box flexGrow={1} sx={{ minWidth: '65%' }}>
<ShippingData <ShippingData
> >
<FormControlLabel <FormControlLabel
control={<Checkbox checked disabled />} control={<Checkbox checked disabled />}
label="Free Shipping"
label={t('shipping:shippingCost')}
sx={{ color: 'black', ml: 2 }} sx={{ color: 'black', ml: 2 }}
/> />
</Box> </Box>

+ 4
- 2
components/shipping-content/shipping-btnGroup/ButtonGroup.jsx Parādīt failu

import { Box, Button } from '@mui/material'; import { Box, Button } from '@mui/material';
import { useTranslation } from 'next-i18next';
import PropType from 'prop-types'; import PropType from 'prop-types';


const ButtonGroup = ({ handleBackToCart, handleStripePayment }) => { const ButtonGroup = ({ handleBackToCart, handleStripePayment }) => {
const { t } = useTranslation('shipping');
return ( return (
<Box <Box
sx={{ sx={{
}} }}
onClick={handleBackToCart} onClick={handleBackToCart}
> >
Back to cart
{t('shipping:back')}
</Button> </Button>
<Button <Button
type="submit" type="submit"
}} }}
onClick={handleStripePayment} onClick={handleStripePayment}
> >
Continue to payment
{t('shipping:continue')}
</Button> </Button>
</Box> </Box>
); );

+ 9
- 4
components/shipping-content/shipping-data/ShippingData.jsx Parādīt failu

import { Button, Typography } from '@mui/material'; import { Button, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useTranslation } from 'next-i18next';
import PropType from 'prop-types'; import PropType from 'prop-types';


const ShippingData = ({ email, address, city, postcode, handleOpen }) => { const ShippingData = ({ email, address, city, postcode, handleOpen }) => {
const { t } = useTranslation('shipping');

return ( return (
<> <>
<Box <Box
p: 1, p: 1,
}} }}
> >
<Typography sx={{ fontSize: 18, fontWeight: 600 }}>Contact</Typography>
<Typography sx={{ fontSize: 18, fontWeight: 600 }}>
{t('shipping:contact')}
</Typography>
<Typography>{email}</Typography> <Typography>{email}</Typography>
<Button <Button
sx={{ sx={{
handleOpen('Contact'); handleOpen('Contact');
}} }}
> >
Change
{t('shipping:changeBtn')}
</Button> </Button>
</Box> </Box>
<Box <Box
mr: { xs: 1, sm: 0 }, mr: { xs: 1, sm: 0 },
}} }}
> >
Shipping to
{t('shipping:shipping')}
</Typography> </Typography>
<Typography> <Typography>
{address} | {city} | {postcode} {address} | {city} | {postcode}
handleOpen('Shipping'); handleOpen('Shipping');
}} }}
> >
Change
{t('shipping:changeBtn')}
</Button> </Button>
</Box> </Box>
</> </>

+ 9
- 0
pages/cart/index.js Parādīt failu

import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import CartContent from '../../components/cart-content/CartContent'; import CartContent from '../../components/cart-content/CartContent';


const CartPage = () => { const CartPage = () => {
return <CartContent></CartContent>; return <CartContent></CartContent>;
}; };


export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ['cart'])),
},
};
}

export default CartPage; export default CartPage;

+ 7
- 1
pages/checkout/index.js Parādīt failu

import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import nookies from 'nookies'; import nookies from 'nookies';
import CheckoutContent from '../../components/checkout-content/CheckoutContent'; import CheckoutContent from '../../components/checkout-content/CheckoutContent';


} }


return { return {
props: {},
props: {
...(await serverSideTranslations(ctx.locale, [
'checkout',
'addressForm',
])),
},
}; };
}; };



+ 1
- 1
pages/contact.js Parādīt failu

export async function getStaticProps({ locale }) { export async function getStaticProps({ locale }) {
return { return {
props: { props: {
...(await serverSideTranslations(locale, ['forms', 'contact', 'common'])),
...(await serverSideTranslations(locale, ['contact'])),
}, },
}; };
} }

+ 4
- 3
pages/index.js Parādīt failu

import { Box } from '@mui/system'; import { Box } from '@mui/system';
import { useSession } from 'next-auth/react'; import { useSession } from 'next-auth/react';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import Head from 'next/head'; import Head from 'next/head';
import { useEffect } from 'react'; import { useEffect } from 'react';
import CompanyInfo from '../components/company-info/CompanyInfo'; import CompanyInfo from '../components/company-info/CompanyInfo';


useEffect(() => { useEffect(() => {
const userData = getStorage('user-data'); const userData = getStorage('user-data');
console.log(userData);
if (session?.user && userData.length === 0) { if (session?.user && userData.length === 0) {
addUser(session.user); addUser(session.user);
console.log('added');
} }
}, [session, addUser]); }, [session, addUser]);


); );
}; };


export async function getStaticProps() {
export async function getStaticProps({ locale }) {
try { try {
const { message, featuredProducts } = await getFeaturedProducts(); const { message, featuredProducts } = await getFeaturedProducts();
return { return {
props: { props: {
...(await serverSideTranslations(locale, ['home'])),
message, message,
featuredProducts, featuredProducts,
}, },
} catch (error) { } catch (error) {
return { return {
props: { props: {
...(await serverSideTranslations(locale, ['home'])),
errorMessage: error, errorMessage: error,
featuredProducts: [], featuredProducts: [],
}, },

+ 8
- 1
pages/profile/index.js Parādīt failu

import { getSession } from 'next-auth/react'; import { getSession } from 'next-auth/react';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import ProfileContent from '../../components/profile-content/ProfileContent'; import ProfileContent from '../../components/profile-content/ProfileContent';
import { LOGIN_PAGE } from '../../constants/pages'; import { LOGIN_PAGE } from '../../constants/pages';
import { getOrdersForOwner } from '../../requests/orders/getOrdersForOwnerRequest'; import { getOrdersForOwner } from '../../requests/orders/getOrdersForOwnerRequest';
const orders = await getOrdersForOwner(session.user._id); const orders = await getOrdersForOwner(session.user._id);


return { return {
props: { orders },
props: {
...(await serverSideTranslations(context.locale, [
'profile',
'addressForm',
])),
orders,
},
}; };
} }



+ 4
- 1
pages/review/index.js Parādīt failu

import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import nookies from 'nookies'; import nookies from 'nookies';
import ReviewContent from '../../components/review-content/ReviewContent'; import ReviewContent from '../../components/review-content/ReviewContent';


} }


return { return {
props: {},
props: {
...(await serverSideTranslations(ctx.locale, ['review'])),
},
}; };
}; };



+ 7
- 1
pages/shipping/index.js Parādīt failu

import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import nookies from 'nookies'; import nookies from 'nookies';
import ShippingContent from '../../components/shipping-content/ShippingContent'; import ShippingContent from '../../components/shipping-content/ShippingContent';


} }


return { return {
props: {},
props: {
...(await serverSideTranslations(ctx.locale, [
'shipping',
'addressForm',
])),
},
}; };
}; };
export default ShippingPage; export default ShippingPage;

+ 2
- 1
public/locales/en/contact.json Parādīt failu

"firstName": "First name", "firstName": "First name",
"lastName": "Last name", "lastName": "Last name",
"email": "Email", "email": "Email",
"msg": "Message"
"msg": "Message",
"notification": "Question submitted!"
} }

+ 2
- 1
public/locales/en/home.json Parādīt failu

{ {
"mainTitle": "It's a Coffee Break",
"mainTitle1": "It's a",
"mainTitle2": "Coffee Break",
"description": "If you drink coffee regulary you will know the difference between fresh coffee and old coffee. Our goal is to provide the freshest coffee beans in each day.", "description": "If you drink coffee regulary you will know the difference between fresh coffee and old coffee. Our goal is to provide the freshest coffee beans in each day.",
"exploreBtn": "Explore the Shop", "exploreBtn": "Explore the Shop",
"howTo": "How to make", "howTo": "How to make",

+ 3
- 2
public/locales/en/profile.json Parādīt failu

{ {
"title": "Welcome to your user account", "title": "Welcome to your user account",
"subtitle1": "save details for later",
"subtitle1": "Save details for later",
"subtitle2": "Previous orders", "subtitle2": "Previous orders",
"orderDate": "Order placed on: ", "orderDate": "Order placed on: ",
"by": "By: ", "by": "By: ",
"total": "Total: "
"total": "Total: $",
"notification": "User profile updated"
} }

+ 5
- 1
styles/muiTheme.js Parādīt failu

const theme = createTheme({ const theme = createTheme({
typography: { typography: {
h1: { h1: {
fontFamily: ['Indie Flower', 'cursive'].join(','),
fontFamily: ['Roboto', 'sans-serif'].join(','),
textTransform: '', textTransform: '',
fontSize: '82px', fontSize: '82px',
}, },
h2: { h2: {
fontFamily: ['Indie Flower', 'cursive'].join(','), fontFamily: ['Indie Flower', 'cursive'].join(','),
}, },
h4: {
fontFamily: ['Roboto', 'sans-serif'].join(','),
fontSize: '42px',
},
}, },
body1: { body1: {
fontFamily: ['Roboto', 'sans-serif'].join(','), fontFamily: ['Roboto', 'sans-serif'].join(','),

Notiek ielāde…
Atcelt
Saglabāt