Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
exam_8
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zarina
exam_8
Commits
ce569a5d
Commit
ce569a5d
authored
Apr 25, 2020
by
zarina
🌊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7
, Добавлена возможность редактирования цитат
parent
389f2ee3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
8 deletions
+40
-8
FormToFill.js
src/components/FormToFill/FormToFill.js
+6
-2
Header.js
src/components/Header/Header.js
+1
-1
Quote.js
src/components/Quote/Quote.js
+3
-1
Sidebar.js
src/components/Sidebar/Sidebar.js
+2
-2
App.js
src/containers/App.js
+1
-0
QuoteForm.js
src/containers/QuoteForm/QuoteForm.js
+26
-2
Quotes.js
src/containers/Quotes/Quotes.js
+1
-0
No files found.
src/components/FormToFill/FormToFill.js
View file @
ce569a5d
...
...
@@ -14,6 +14,7 @@ const FormToFill = (props) => {
<
FormGroup
>
<
Label
for
=
"author"
>
Author
<
/Label
>
<
Input
value
=
{
props
.
author
}
type
=
"text"
name
=
"author"
id
=
"author"
...
...
@@ -22,17 +23,20 @@ const FormToFill = (props) => {
<
FormGroup
>
<
Label
for
=
"category"
>
Select
<
/Label
>
<
Input
value
=
{
props
.
category
}
type
=
"select"
name
=
"category"
id
=
"category"
onChange
=
{
props
.
inputHandler
}
>
<
option
value
=
""
disabled
>
Select
category
<
/option
>
<
option
value
=
""
disabled
>
Select
category
<
/option
>
{
printOptions
()}
<
/Input
>
<
/FormGroup
>
<
FormGroup
>
<
Label
for
=
"text"
>
Quote
Text
<
/Label
>
<
Input
type
=
"textarea"
<
Input
value
=
{
props
.
text
}
type
=
"textarea"
name
=
"text"
id
=
"text"
onChange
=
{
props
.
inputHandler
}
...
...
src/components/Header/Header.js
View file @
ce569a5d
...
...
@@ -12,7 +12,7 @@ const Header = () => {
<
NavLink
className
=
"nav-link"
to
=
"/quotes"
>
Quotes
<
/NavLink
>
<
/NavItem
>
<
NavItem
>
<
NavLink
className
=
"nav-link"
to
=
"/add-quote"
>
Add
Q
uote
<
/NavLink
>
<
NavLink
className
=
"nav-link"
to
=
"/add-quote"
>
Add
new
q
uote
<
/NavLink
>
<
/NavItem
>
<
/Nav
>
<
/Container
>
...
...
src/components/Quote/Quote.js
View file @
ce569a5d
import
React
from
'react'
;
import
{
Card
,
Button
,
CardFooter
,
CardBody
,
CardTitle
,
CardText
}
from
'reactstrap'
;
import
{
NavLink
}
from
"react-router-dom"
;
const
Quote
=
props
=>
{
return
(
...
...
@@ -10,7 +12,7 @@ const Quote = props => {
<
CardTitle
className
=
'text-uppercase font-weight-bold'
>
{
props
.
author
}
<
/CardTitle
>
<
CardText
>
{
props
.
text
}
<
/CardText
>
<
Button
onClick
=
{
props
.
delete
}
className
=
'mr-3'
color
=
'danger'
>
Delete
<
/Button
>
<
Button
color
=
'info'
>
Edit
<
/Button
>
<
Button
tag
=
{
NavLink
}
to
=
{
`/quotes/
${
props
.
id
}
/edit`
}
color
=
'info'
>
Edit
<
/Button
>
<
/CardBody
>
<
CardFooter
className
=
'text-muted'
>
{
props
.
category
}
<
/CardFooter
>
<
/Card
>
...
...
src/components/Sidebar/Sidebar.js
View file @
ce569a5d
...
...
@@ -7,8 +7,8 @@ const Sidebar = () => {
const
printCategories
=
()
=>
{
return
CATEGORIES
.
map
(
category
=>
{
return
<
NavItem
>
<
NavLink
className
=
"nav-link"
to
=
{
'/quotes/'
+
category
.
id
}
>
{
category
.
title
}
<
/NavLink
>
return
<
NavItem
key
=
{
`sidebar_
${
category
.
id
}
`
}
>
<
NavLink
className
=
"nav-link"
to
=
{
'/quotes/'
+
category
.
id
}
>
{
category
.
title
}
<
/NavLink
>
<
/NavItem
>
})
...
...
src/containers/App.js
View file @
ce569a5d
...
...
@@ -22,6 +22,7 @@ function App() {
<
Route
path
=
"/"
exact
component
=
{
Quotes
}
/
>
<
Route
path
=
"/quotes/"
exact
component
=
{
Quotes
}
/
>
<
Route
path
=
"/quotes/:category"
exact
component
=
{
Quotes
}
/
>
<
Route
path
=
"/quotes/:id/edit"
exact
component
=
{
QuoteForm
}
/
>
<
/Switch
>
<
/div
>
<
/Container
>
...
...
src/containers/QuoteForm/QuoteForm.js
View file @
ce569a5d
...
...
@@ -11,6 +11,25 @@ const QuoteForm = props => {
text
:
''
});
useEffect
(()
=>
{
if
(
props
.
match
.
params
.
id
)
{
axios
.
get
(
`quotes/
${
props
.
match
.
params
.
id
}
.json`
)
.
then
(
response
=>
{
setQuoteInfo
(
response
.
data
)
}
)
}
else
{
let
resetQuoteInfo
=
{
author
:
''
,
category
:
CATEGORIES
[
0
].
id
,
text
:
''
};
setQuoteInfo
(
resetQuoteInfo
)
}
},[
props
.
match
.
params
.
id
]);
const
inputHandler
=
(
e
)
=>
{
setQuoteInfo
({
...
quoteInfo
,
...
...
@@ -25,7 +44,7 @@ const QuoteForm = props => {
}
axios
.
post
(
'/quotes.json'
,
quoteInfo
).
then
(
response
=>
{
()
=>
{
props
.
history
.
push
(
'./'
)
}
)
...
...
@@ -34,7 +53,12 @@ const QuoteForm = props => {
return
(
<
div
className
=
'QuoteForm'
>
<
FormToFill
submitQuote
=
{
submitQuote
}
inputHandler
=
{
inputHandler
}
/
>
<
FormToFill
submitQuote
=
{
submitQuote
}
inputHandler
=
{
inputHandler
}
text
=
{
quoteInfo
.
text
}
category
=
{
quoteInfo
.
category
}
author
=
{
quoteInfo
.
author
}
/
>
<
/div
>
)
};
...
...
src/containers/Quotes/Quotes.js
View file @
ce569a5d
...
...
@@ -40,6 +40,7 @@ const Quotes = props => {
category
=
{
quotes
[
quote
].
category
}
key
=
{
quote
}
delete
=
{()
=>
deleteQuote
(
quote
)}
id
=
{
quote
}
/
>
})
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment