Pārlūkot izejas kodu

Creating create Offer page

pull/2/head
Djordje Mitrovic pirms 3 gadiem
vecāks
revīzija
3aa33b89d3

+ 6
- 0
src/components/Cards/CreateOfferCard/CreateOffer.styled.js Parādīt failu

import styled from "styled-components"; import styled from "styled-components";
import selectedTheme from "../../../themes"; import selectedTheme from "../../../themes";
import { Label } from "../../CheckBox/Label"; import { Label } from "../../CheckBox/Label";
import Select from "../../Select/Select";


export const CreateOfferContainer = styled(Container)` export const CreateOfferContainer = styled(Container)`
margin-top: 0px; margin-top: 0px;
cursor: auto; cursor: auto;
letter-spacing: 0.2px; letter-spacing: 0.2px;
} }
`
export const SelectField = styled(Select)`
position: relative;
top: 15px;
margin-bottom: 30px;
` `

+ 101
- 91
src/components/Cards/CreateOfferCard/FirstPart/FirstPartCreateOffer.js Parādīt failu

import React from 'react'
import PropTypes from 'prop-types'
import {useFormik} from "formik";
import { CreateOfferFormContainer, FieldLabel } from './FirstPartCreateOffer.styled'
import { TextField } from '../../../TextFields/TextField/TextField'
import { PrimaryButton } from '../../../Buttons/PrimaryButton/PrimaryButton'
import * as Yup from "yup"
import selectedTheme from '../../../../themes';
import { useTranslation } from 'react-i18next';
import Select from '../../../Select/Select';
import Option from '../../../Select/Option/Option';
import React from "react";
import PropTypes from "prop-types";
import { useFormik } from "formik";
import {
CreateOfferFormContainer,
FieldLabel,
} from "./FirstPartCreateOffer.styled";
import { TextField } from "../../../TextFields/TextField/TextField";
import { PrimaryButton } from "../../../Buttons/PrimaryButton/PrimaryButton";
import * as Yup from "yup";
import selectedTheme from "../../../../themes";
import { useTranslation } from "react-i18next";
import Option from "../../../Select/Option/Option";
import { SelectField } from "../CreateOffer.styled";


const FirstPartCreateOffer = () => { const FirstPartCreateOffer = () => {
const {t} = useTranslation();
const handleSubmit = (values) => {
console.log(values)
}
const formik = useFormik({
initialValues: {
nameOfProduct: "",
description: "",
},
validationSchema: Yup.object().shape({
nameOfProduct: Yup.string().required(t("login.nameOfProductRequired")),
description: Yup.string().required(t("login.descriptionRequired")).min(8),
}),
onSubmit: handleSubmit,
validateOnBlur: true,
enableReinitialize: true,
});
const { t } = useTranslation();
const handleSubmit = (values) => {
console.log(values);
};
const formik = useFormik({
initialValues: {
nameOfProduct: "",
description: "",
},
validationSchema: Yup.object().shape({
nameOfProduct: Yup.string().required(t("login.nameOfProductRequired")),
description: Yup.string().required(t("login.descriptionRequired")).min(8),
}),
onSubmit: handleSubmit,
validateOnBlur: true,
enableReinitialize: true,
});
return ( return (
<CreateOfferFormContainer component="form" onSubmit={formik.handleSubmit}> <CreateOfferFormContainer component="form" onSubmit={formik.handleSubmit}>
{/* <Backdrop position="absolute" isLoading={isLoading} /> */}
{/* <Backdrop position="absolute" isLoading={isLoading} /> */}


<FieldLabel
leftText={"NASLOV"}
/>
<TextField
name="nameOfProduct"
placeholder={"Naziv proizvoda..."}
italicPlaceholder
margin="normal"
value={formik.values.nameOfProduct}
onChange={formik.handleChange}
error={formik.touched.nameOfProduct && formik.errors.nameOfProduct}
helperText={
formik.touched.nameOfProduct && formik.errors.nameOfProduct
}
autoFocus
fullWidth
/>
<FieldLabel leftText={"NASLOV"} />
<TextField
name="nameOfProduct"
placeholder={"Naziv proizvoda..."}
italicPlaceholder
margin="normal"
value={formik.values.nameOfProduct}
onChange={formik.handleChange}
error={formik.touched.nameOfProduct && formik.errors.nameOfProduct}
helperText={formik.touched.nameOfProduct && formik.errors.nameOfProduct}
autoFocus
fullWidth
/>


<FieldLabel
leftText={"OPIS PROIZVODA"}
/>
<TextField
name="description"
placeholder={"Opis..."}
margin="normal"
italicPlaceholder
value={formik.values.description}
onChange={formik.handleChange}
error={formik.touched.description && formik.errors.description}
helperText={formik.touched.description && formik.errors.description}
fullWidth
multiline
minRows={4}
height={"100px"}
/>
<FieldLabel leftText={"OPIS PROIZVODA"} />
<TextField
name="description"
placeholder={"Opis..."}
margin="normal"
italicPlaceholder
value={formik.values.description}
onChange={formik.handleChange}
error={formik.touched.description && formik.errors.description}
helperText={formik.touched.description && formik.errors.description}
fullWidth
multiline
minRows={4}
height={"100px"}
/>


<Select defaultValue={1}>
<Option value={1}>Opcija 1</Option>
<Option value={2}>Opcija 2</Option>
<Option value={3}>Opcija 3</Option>
<Option value={4}>Opcija 4</Option>
<FieldLabel leftText={"KATEGORIJA"} />
<SelectField defaultValue={1}>
<Option value={1}>Opcija 1</Option>
<Option value={2}>Opcija 2</Option>
<Option value={3}>Opcija 3</Option>
<Option value={4}>Opcija 4</Option>
</SelectField>


</Select>
<FieldLabel leftText={"PODKATEGORIJA"} />
<SelectField defaultValue={1}>
<Option value={1}>Opcija 1</Option>
<Option value={2}>Opcija 2</Option>
<Option value={3}>Opcija 3</Option>
<Option value={4}>Opcija 4</Option>
</SelectField>


<FieldLabel leftText={"LOKACIJA"} />
<SelectField defaultValue={1}>
<Option value={1}>Opcija 1</Option>
<Option value={2}>Opcija 2</Option>
<Option value={3}>Opcija 3</Option>
<Option value={4}>Opcija 4</Option>
</SelectField>



<PrimaryButton
type="submit"
variant="contained"
height="48px"
fullWidth={true}
buttoncolor={selectedTheme.primaryPurple}
textcolor="white"
// disabled={
// formik.values.username.length === 0 ||
// formik.values.password.length === 0
// }
>
NASTAVI
</PrimaryButton>

</CreateOfferFormContainer>
)
}
<PrimaryButton
type="submit"
variant="contained"
height="48px"
fullWidth={true}
buttoncolor={selectedTheme.primaryPurple}
textcolor="white"
// disabled={
// formik.values.username.length === 0 ||
// formik.values.password.length === 0
// }
>
NASTAVI
</PrimaryButton>
</CreateOfferFormContainer>
);
};


FirstPartCreateOffer.propTypes = { FirstPartCreateOffer.propTypes = {
children: PropTypes.any,
}
children: PropTypes.any,
};


export default FirstPartCreateOffer
export default FirstPartCreateOffer;

+ 1
- 0
src/components/Cards/CreateOfferCard/FirstPart/FirstPartCreateOffer.styled.js Parādīt failu

color: ${selectedTheme.primaryPurple}; color: ${selectedTheme.primaryPurple};
margin-top: 36px; margin-top: 36px;
margin-bottom: 40px; margin-bottom: 40px;
position: relative;
`; `;
export const CreateOfferDescription = styled(Typography)` export const CreateOfferDescription = styled(Typography)`
font-family: "Open Sans"; font-family: "Open Sans";

+ 6
- 6
src/components/Cards/OfferCard/OfferCard.js Parādīt failu

<OfferCardContainer sponsored={props.offer.pinned.toString()} halfwidth={props.halfwidth ? 1 : 0}> <OfferCardContainer sponsored={props.offer.pinned.toString()} halfwidth={props.halfwidth ? 1 : 0}>
<OfferImage src={props.offer.images[0]}></OfferImage> <OfferImage src={props.offer.images[0]}></OfferImage>
<OfferInfo> <OfferInfo>
<OfferTitle>{props.title}</OfferTitle>
<OfferTitle>{props.offer.name}</OfferTitle>
<OfferAuthor> <OfferAuthor>
<OfferAuthorName>{props.author}</OfferAuthorName>
<OfferLocation>{props.location}</OfferLocation>
<OfferAuthorName>{props.offer.description}</OfferAuthorName>
<OfferLocation>{props.offer.location.city}</OfferLocation>
</OfferAuthor> </OfferAuthor>
<OfferDetails> <OfferDetails>
<OfferCategory> <OfferCategory>
<DetailIcon color="black" component="span" size="16px"> <DetailIcon color="black" component="span" size="16px">
<Category width={"14px"} /> <Category width={"14px"} />
</DetailIcon> </DetailIcon>
<DetailText>{props.category}</DetailText>
<DetailText>{props.offer.category.name}</DetailText>
</OfferCategory> </OfferCategory>
<OfferPackage> <OfferPackage>
<DetailIcon color="black" component="span" size="16px"> <DetailIcon color="black" component="span" size="16px">
<Quantity width={"12px"} height={"12px"} /> <Quantity width={"12px"} height={"12px"} />
</DetailIcon> </DetailIcon>
<DetailText>{props.quantity} pakovanja</DetailText>
<DetailText>{props.offer.quantity} pakovanja</DetailText>
</OfferPackage> </OfferPackage>
<OfferViews> <OfferViews>
<DetailIcon color="black" component="span" size="16px"> <DetailIcon color="black" component="span" size="16px">
<Line/> <Line/>
<OfferDescription> <OfferDescription>
<OfferDescriptionTitle>Opis:</OfferDescriptionTitle> <OfferDescriptionTitle>Opis:</OfferDescriptionTitle>
<OfferDescriptionText>{props.description}</OfferDescriptionText>
<OfferDescriptionText>{props.offer.description}</OfferDescriptionText>
</OfferDescription> </OfferDescription>


<CheckButton <CheckButton

+ 3
- 0
src/components/Select/Option/Option.styled.js Parādīt failu

export const OptionStyled = styled(MenuItem)` export const OptionStyled = styled(MenuItem)`
background-color: ${props => props.selected ? selectedTheme.primaryPurple : "white"} !important; background-color: ${props => props.selected ? selectedTheme.primaryPurple : "white"} !important;
color: ${props => props.selected ? "white" : selectedTheme.selectOptionTextColor}; color: ${props => props.selected ? "white" : selectedTheme.selectOptionTextColor};
margin:2px 9px;
border-radius: 4px;
&:hover { &:hover {
background-color: ${selectedTheme.primaryPurple} !important; background-color: ${selectedTheme.primaryPurple} !important;
color: white;
} }
` `
export const OptionIcon = styled(Box)` export const OptionIcon = styled(Box)`

+ 6
- 0
src/components/Select/Select.js Parādīt failu

<SelectStyled <SelectStyled
defaultValue={props.defaultValue} defaultValue={props.defaultValue}
fullWidth={props.fullwidth} fullWidth={props.fullwidth}
width={props.width}
height={props.height}
className={props.className}
IconComponent={(iconProps) => ( IconComponent={(iconProps) => (
<SelectIcon {...iconProps}> <SelectIcon {...iconProps}>
<Down /> <Down />
Select.propTypes = { Select.propTypes = {
children: PropTypes.node, children: PropTypes.node,
width: PropTypes.string, width: PropTypes.string,
height: PropTypes.string,
fullwidth: PropTypes.bool, fullwidth: PropTypes.bool,
defaultValue: PropTypes.number, defaultValue: PropTypes.number,
className: PropTypes.string,
}; };
Select.defaultProps = { Select.defaultProps = {
fullwidth: true, fullwidth: true,
height: "48px"
}; };


export default Select; export default Select;

+ 4
- 0
src/components/Select/Select.styled.js Parādīt failu

export const SelectStyled = styled(Select)` export const SelectStyled = styled(Select)`
width: ${props => props.width}; width: ${props => props.width};
height: ${props => props.height}; height: ${props => props.height};
padding: 2px;
font-size: 16px;
font-weight: 600;
font-family: "Open Sans";
` `
export const SelectIcon = styled(Box)` export const SelectIcon = styled(Box)`
position: relative; position: relative;

+ 14
- 2
src/components/StepProgress/StepProgress.js Parādīt failu

current: i === props.current, current: i === props.current,
}); });
} }
const functions = [];
steps.forEach((item,index) => {
if (props.functions[index]) {
functions.push(props.functions[index])
} else {
functions.push(() => {})
}
})
return ( return (
<StepProgressContainer done> <StepProgressContainer done>
{steps.map((item, index) => {steps.map((item, index) =>
index === 0 ? ( index === 0 ? (
<StepBar current={item.current} done={item.done} key={index}>
<StepBar current={item.current} done={item.done} key={index} onClick={item.done ? props.functions[index] : () => {console.log("neuspeh")}}>
{item.done ? <Checkmark /> : index+1} {item.done ? <Checkmark /> : index+1}
</StepBar> </StepBar>
) : ( ) : (
<StepLine done={item.done || item.current} > <StepLine done={item.done || item.current} >
<Progress done={item.done || item.current} /> <Progress done={item.done || item.current} />
</StepLine> </StepLine>
<StepBar current={item.current} done={item.done}>
<StepBar current={item.current} done={item.done} onClick={item.done ? props.functions[index] : () => {}} >
{item.done ? <Checkmark /> : index+1} {item.done ? <Checkmark /> : index+1}
</StepBar> </StepBar>
</React.Fragment> </React.Fragment>
handleNext: PropTypes.node, handleNext: PropTypes.node,
current: PropTypes.number, current: PropTypes.number,
numberOfSteps: PropTypes.number, numberOfSteps: PropTypes.number,
functions: PropTypes.array
}; };
StepProgress.defaultProps = {
functions: []
}


export default StepProgress; export default StepProgress;

+ 1
- 0
src/components/StepProgress/StepProgress.styled.js Parādīt failu

color: #1d1d1d; color: #1d1d1d;
z-index: 1; z-index: 1;
transition: background-color 1s ease; transition: background-color 1s ease;
${props => props.done && `cursor: pointer;`}
`; `;
export const Progress = styled(Box)` export const Progress = styled(Box)`
height: 9px; height: 9px;

+ 0
- 38
src/layouts/GridLayout/GridLayout.js Parādīt failu

import React from "react";
import PropTypes from "prop-types";
import { Content, LeftCard, RightCard, GridLayoutContainer, HeaderCard, MiddleCard } from "./GridLayout.styled";
import { Grid } from "@mui/material";

const GridLayout = (props) => {
return (
<GridLayoutContainer>
{props.children}
<Grid container maxHeight="lg">
<LeftCard item xs={2} lg={2.5} xl={2.4} md={3}>
{props.leftCard}
</LeftCard>
<MiddleCard item xs={7.5} lg={6.5} xl={6.6} md={6}>
<HeaderCard>
{props.headerCard}
</HeaderCard>
<Content>
{props.content}
</Content>
</MiddleCard>
<RightCard item xs={2.5} lg={3} xl={3} md={3}>
{props.rightCard}
</RightCard>
</Grid>
</GridLayoutContainer>
);
};

GridLayout.propTypes = {
children: PropTypes.node,
leftCard: PropTypes.node,
content: PropTypes.node,
rightCard: PropTypes.node,
headerCard: PropTypes.node,
};

export default GridLayout;

+ 0
- 28
src/layouts/GridLayout/GridLayout.styled.js Parādīt failu

import { Box, Container, Grid } from "@mui/material";
import styled from "styled-components";

export const GridLayoutContainer = styled(Container)`
padding-left: 0;
padding-right: 0;
margin: 0;
width: 100%;
display: flex;
flex: 1;
height: 100%;
`

export const LeftCard = styled(Grid)`
margin-top: 30px;
border-top-right-radius: 4px;
`
export const Content = styled(Grid)`
`
export const RightCard = styled(Grid)`
margin-top: 30px;
border-top-left-radius: 4px;
`
export const MiddleCard = styled(Grid)`
`
export const HeaderCard = styled(Box)`
height: 450px;
`

+ 1
- 1
src/layouts/ProfileLayout/ProfileLayout.js Parādīt failu

return ( return (
<ProfileLayoutContainer> <ProfileLayoutContainer>
{props.children} {props.children}
<Grid container maxHeight="xl">
<Grid container maxHeight maxWidth={1900}>
<LeftCard item xs={2} lg={2.5} xl={2.4} md={3}> <LeftCard item xs={2} lg={2.5} xl={2.4} md={3}>
{props.leftCard} {props.leftCard}
</LeftCard> </LeftCard>

+ 6
- 0
src/layouts/ProfileLayout/ProfileLayout.styled.js Parādīt failu

margin: 0; margin: 0;
width: 100%; width: 100%;
display: flex; display: flex;
max-width: none;
flex: 1; flex: 1;
height: 100%; height: 100%;
` `
export const LeftCard = styled(Grid)` export const LeftCard = styled(Grid)`
margin-top: 30px; margin-top: 30px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
background-color: green;
` `
export const Content = styled(Grid)` export const Content = styled(Grid)`
background-color: yellow;
height: 100%;
` `
export const RightCard = styled(Grid)` export const RightCard = styled(Grid)`
margin-top: 30px; margin-top: 30px;
border-top-left-radius: 4px; border-top-left-radius: 4px;
background-color: blue;
` `
export const MiddleCard = styled(Grid)` export const MiddleCard = styled(Grid)`
` `
export const HeaderCard = styled(Box)` export const HeaderCard = styled(Box)`
height: 450px; height: 450px;
background-color: orange;
` `

+ 12
- 8
src/pages/HomePage/HomePageMUI.js Parādīt failu

import React, { useEffect } from "react"; import React, { useEffect } from "react";
import Navbar from "../../components/MUI/NavbarComponent"; import Navbar from "../../components/MUI/NavbarComponent";
import FilterCard from "../../components/Cards/FilterCard/FilterCard";
// import FilterCard from "../../components/Cards/FilterCard/FilterCard";
import { HomePageContainer } from "./HomePage.styled"; import { HomePageContainer } from "./HomePage.styled";
import MarketPlace from "../../components/MarketPlace/MarketPlace";
import MainLayout from "../../layouts/MainLayout/MainLayout";
// import MarketPlace from "../../components/MarketPlace/MarketPlace";
// import MainLayout from "../../layouts/MainLayout/MainLayout";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { logoutUser } from "../../store/actions/login/loginActions";
// import { logoutUser } from "../../store/actions/login/loginActions";
import Mockupdata from "../../components/Cards/FilterCard/Mockupdata"; import Mockupdata from "../../components/Cards/FilterCard/Mockupdata";
import qs from "query-string"; import qs from "query-string";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { setFilters } from "../../store/actions/filters/filtersActions"; import { setFilters } from "../../store/actions/filters/filtersActions";
// import ProfileLayout from "../../layouts/ProfileLayout/ProfileLayout";
import FilterCard from "../../components/Cards/FilterCard/FilterCard";
import MainLayout from "../../layouts/MainLayout/MainLayout";
import MarketPlace from "../../components/MarketPlace/MarketPlace";


const HomePage = () => { const HomePage = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
} }
dispatch(setFilters({ category, subcategory, cities })); dispatch(setFilters({ category, subcategory, cities }));
}, [history.location.search]); }, [history.location.search]);
const handleCl = () => {
dispatch(logoutUser());
};
// const handleCl = () => {
// dispatch(logoutUser());
// };
return ( return (
<HomePageContainer> <HomePageContainer>
<button onClick={handleCl}>Dugme</button>
{/* <button onClick={handleCl}>Dugme</button> */}
<Navbar /> <Navbar />
<MainLayout leftCard={<FilterCard />} content={<MarketPlace />} /> <MainLayout leftCard={<FilterCard />} content={<MarketPlace />} />



+ 11
- 1
src/pages/RegisterPages/Register/Register.js Parādīt failu

} }
setInformations({ ...informations, ...values }); setInformations({ ...informations, ...values });
}; };

const goToFirst = () => {
setInformations({});
setCurrentStep(1);
}
const goToSecond = () => {
const {mail, password} = informations;
setInformations({mail, password});
setCurrentStep(2);
}
return ( return (
<RegisterPageContainer currentStep={currentStep}> <RegisterPageContainer currentStep={currentStep}>
<Logo /> <Logo />
</RegisterDescription> </RegisterDescription>


<ProgressContainer> <ProgressContainer>
<StepProgress current={currentStep} numberOfSteps={3} />
<StepProgress functions={[goToFirst, goToSecond]} current={currentStep} numberOfSteps={3} />
</ProgressContainer> </ProgressContainer>


{currentStep === 1 && ( {currentStep === 1 && (

Notiek ielāde…
Atcelt
Saglabāt