(feat): frontend static content update

This commit is contained in:
Maksym Sadovnychyy 2022-06-25 00:31:11 +02:00
parent b9e2dd6047
commit bfd3cb9f0a
6 changed files with 195 additions and 27 deletions

View File

@ -42,6 +42,12 @@ export interface MenuItemModel {
target?: string target?: string
childItems?: MenuItemModel [] childItems?: MenuItemModel []
} }
export interface LinkModel {
target: string,
anchorText: string
}
export interface ReviewerModel extends PersonModel { export interface ReviewerModel extends PersonModel {
fullName: string, fullName: string,
position: string position: string

View File

@ -1,3 +1,4 @@
import { FormItemModel, LinkModel } from "."
import { PageModel } from "./abstractions" import { PageModel } from "./abstractions"
import { BlogTitleSectionModel, CallToActionSectionModel, CommentsSectionModel, FeaturedBlogSectionModel, FeaturedBlogsSectionModel, FeaturesSectionModel, ProductSectionModel, RelatedProductsSectionModel, TestimonialsSectionModel, TitleSectionModel } from "./pageSections" import { BlogTitleSectionModel, CallToActionSectionModel, CommentsSectionModel, FeaturedBlogSectionModel, FeaturedBlogsSectionModel, FeaturesSectionModel, ProductSectionModel, RelatedProductsSectionModel, TestimonialsSectionModel, TitleSectionModel } from "./pageSections"
@ -23,6 +24,26 @@ export interface ShopCatalogPageModel extends PageModel {
titleSection: TitleSectionModel titleSection: TitleSectionModel
} }
export interface SignInPageModel extends PageModel {
title: string,
email: FormItemModel,
password: FormItemModel,
dontHaveAnAccount: string,
signUpLink: LinkModel,
submit: FormItemModel
}
export interface SignUpPageModel extends PageModel {
title: string,
username: FormItemModel,
email: FormItemModel,
reEmail: FormItemModel
password: FormItemModel,
rePassword: FormItemModel,
acceptTermsAndConditions: string,
submit: FormItemModel
}
export interface ShopItemPageModel extends PageModel { export interface ShopItemPageModel extends PageModel {
productSection: ProductSectionModel productSection: ProductSectionModel
relatedProductsSection: RelatedProductsSectionModel relatedProductsSection: RelatedProductsSectionModel

View File

@ -5,7 +5,9 @@ import {
BlogCatalogPageModel, BlogCatalogPageModel,
BlogItemPageModel, BlogItemPageModel,
ShopCatalogPageModel, ShopCatalogPageModel,
ShopItemPageModel ShopItemPageModel,
SignInPageModel,
SignUpPageModel
} from "./pages" } from "./pages"
// Shop response models // Shop response models
@ -44,7 +46,10 @@ export interface GetContentResponseModel extends ResponseModel {
shopItem: ShopItemPageModel, shopItem: ShopItemPageModel,
blogCatalog: BlogCatalogPageModel, blogCatalog: BlogCatalogPageModel,
blogItem: BlogItemPageModel blogItem: BlogItemPageModel,
signIn: SignInPageModel,
signUp: SignUpPageModel
} }
// Blog response models // Blog response models

View File

@ -1,6 +1,12 @@
import React, { useState } from "react" import React, { useEffect, useState } from "react"
// Redux
import { useDispatch, useSelector } from "react-redux"
import { actionCreators as loaderActionCreators } from '../../store/reducers/Loader'
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import { Button, Container, Form, FormGroup, Input, Label } from "reactstrap" import { Button, Container, Form, FormGroup, Input, Label } from "reactstrap"
import { ApplicationState } from "../../store"
import './scss/style.scss' import './scss/style.scss'
@ -14,6 +20,37 @@ interface IState extends IStateProp {
} }
const Signin = () => { const Signin = () => {
const dispatch = useDispatch()
const { content } = useSelector((state: ApplicationState) => state)
const {
title = "",
email = {
title: "",
placeHolder: ""
},
password = {
title: "",
placeHolder: ""
},
dontHaveAnAccount = "",
signUpLink = {
target: "#",
anchorText: ""
},
submit = {
title: ""
}
} = content?.signIn ? content.signIn : {}
useEffect(() => {
content?.isLoading
? dispatch(loaderActionCreators.show())
: setTimeout(() => {
dispatch(loaderActionCreators.hide())
}, 1000)
}, [content?.isLoading])
const [state, hookState] = useState<IState>({ const [state, hookState] = useState<IState>({
username: '', username: '',
@ -33,32 +70,32 @@ const Signin = () => {
} }
return <Container className="container"> return <Container className="container">
<h2>Sign In</h2> <h2>{title}</h2>
<Form className="form"> <Form className="form">
<FormGroup> <FormGroup>
<Label for="username">Username</Label> <Label for="username">{email.title}</Label>
<Input <Input
type="text" type="text"
name="username" name="username"
id="username" id="username"
placeholder="username or email..." placeholder={email.placeHolder}
value={state.username} value={state.username}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="password">Password</Label> <Label for="password">{password.title}</Label>
<Input <Input
type="password" type="password"
name="password" name="password"
id="password" id="password"
placeholder="password..." placeholder={password.placeHolder}
value={state.password} value={state.password}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
Dont have an account yet? Please <Link to="/signup">Signup</Link>. {dontHaveAnAccount} <Link to={signUpLink.target}>{signUpLink.anchorText}</Link>.
</FormGroup> </FormGroup>
<Button>Submit</Button> <Button>{submit.title}</Button>
</Form> </Form>

View File

@ -1,5 +1,11 @@
import React, { useState } from "react" import React, { useEffect, useState } from "react"
// Redux
import { useDispatch, useSelector } from "react-redux"
import { actionCreators as loaderActionCreators } from '../../store/reducers/Loader'
import { Button, Container, Form, FormGroup, Input, Label } from "reactstrap" import { Button, Container, Form, FormGroup, Input, Label } from "reactstrap"
import { ApplicationState } from "../../store"
import './scss/style.scss' import './scss/style.scss'
@ -20,6 +26,45 @@ interface IState extends IStateProp {
} }
const Signup = () => { const Signup = () => {
const dispatch = useDispatch()
const { content } = useSelector((state: ApplicationState) => state)
const {
title = "",
username = {
title: "",
placeHolder: ""
},
email = {
title: "",
placeHolder: ""
},
reEmail = {
title: "Repeat email address",
placeHolder: "Repeat email address..."
},
password = {
title: "",
placeHolder: ""
},
rePassword = {
title: "Repeat password",
placeHolder: "Repeat password..."
},
acceptTermsAndConditions = "",
submit = {
title: ""
}
} = content?.signUp ? content.signUp : {}
useEffect(() => {
content?.isLoading
? dispatch(loaderActionCreators.show())
: setTimeout(() => {
dispatch(loaderActionCreators.hide())
}, 1000)
}, [content?.isLoading])
const [state, hookState] = useState<IState>({ const [state, hookState] = useState<IState>({
username: '', username: '',
@ -51,63 +96,63 @@ const Signup = () => {
} }
return <Container className="container"> return <Container className="container">
<h2>Sign Up</h2> <h2>{title}</h2>
<Form className="form"> <Form className="form">
<FormGroup> <FormGroup>
<Label for="username">Username</Label> <Label for="username">{username.title}</Label>
<Input <Input
type="text" type="text"
name="username" name="username"
id="username" id="username"
placeholder="username..." placeholder={username.placeHolder}
value={state.username} value={state.username}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="email">Email</Label> <Label for="email">{email.title}</Label>
<Input <Input
type="text" type="text"
name="email" name="email"
id="email" id="email"
placeholder="email..." placeholder={email.placeHolder}
value={state.email} value={state.email}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="reEmail">Repeat email</Label> <Label for="reEmail">{reEmail.title}</Label>
<Input <Input
type="text" type="text"
name="reEmail" name="reEmail"
id="reEmail" id="reEmail"
placeholder="repeat email..." placeholder={reEmail.placeHolder}
value={state.reEmail} value={state.reEmail}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="password">Password</Label> <Label for="password">{password.title}</Label>
<Input <Input
type="password" type="password"
name="password" name="password"
id="password" id="password"
placeholder="password..." placeholder={password.placeHolder}
value={state.password} value={state.password}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="rePassword">Repeat password</Label> <Label for="rePassword">{rePassword.title}</Label>
<Input <Input
type="password" type="password"
name="rePassword" name="rePassword"
id="rePassword" id="rePassword"
placeholder="repeat password..." placeholder={rePassword.placeHolder}
value={state.rePassword} value={state.rePassword}
onChange={onChange} /> onChange={onChange} />
</FormGroup> </FormGroup>
<FormGroup check> <FormGroup check>
<Input type="checkbox" name="tnc" id="tnc" checked={state.tnc} onChange={onTogle}/> <Input type="checkbox" name="tnc" id="tnc" checked={state.tnc} onChange={onTogle}/>
<Label check>Accept Terms And Conditions</Label> <Label check>{acceptTermsAndConditions}</Label>
</FormGroup> </FormGroup>
<Button>Submit</Button> <Button>{submit.title}</Button>
</Form> </Form>
</Container> </Container>
} }

View File

@ -55,12 +55,18 @@ const unloadedState: ContentState = {
]} ]}
], ],
adminRoutes: [], adminRoutes: [],
serviceRoutes: [], serviceRoutes: [
{ target: "/signin", component: "Signin" },
{ target: "/signup", component: "Signup" }
],
topMenu: [ topMenu: [
{ target: "/", title: "Home" }, { target: "/", title: "Home" },
{ target: "/shop", title: "Shop" }, { target: "/shop", title: "Shop" },
{ target: "/blog", title: "Blog" } { target: "/blog", title: "Blog" },
{ target: "/signin", title: "Sing in" },
{ target: "/signup", title: "Sign up" }
], ],
sideMenu: [], sideMenu: [],
@ -158,6 +164,54 @@ const unloadedState: ContentState = {
}, },
signIn: {
title: "Sign in",
email: {
title: "Email address",
placeHolder: "Email address..."
},
password: {
title: "Password",
placeHolder: "Password..."
},
dontHaveAnAccount: "Don't have an account yet? Please",
signUpLink: {
target: "/signup",
anchorText: "Sign up"
},
submit: {
title: "Sign in"
}
},
signUp: {
title: "Sign up",
username: {
title: "Username",
placeHolder: "Username..."
},
email: {
title: "Email address",
placeHolder: "Email address..."
},
reEmail: {
title: "Repeat email address",
placeHolder: "Repeat email address..."
},
password: {
title: "Password",
placeHolder: "Password..."
},
rePassword: {
title: "Repeat password",
placeHolder: "Repeat password..."
},
acceptTermsAndConditions: "Accept terms and conditions",
submit: {
title: "Sing up"
}
},
isLoading: false isLoading: false
} }