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
b6b1b067
Commit
b6b1b067
authored
Apr 25, 2020
by
zarina
🌊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3
, Добавлен вывод всех цитат на главную страницу
parent
55815c3a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
Quote.js
src/components/Quote/Quote.js
+21
-0
App.js
src/containers/App.js
+3
-0
Quotes.js
src/containers/Quotes/Quotes.js
+39
-0
No files found.
src/components/Quote/Quote.js
0 → 100644
View file @
b6b1b067
import
React
from
'react'
;
import
{
Card
,
Button
,
CardHeader
,
CardFooter
,
CardBody
,
CardTitle
,
CardText
}
from
'reactstrap'
;
const
Quote
=
props
=>
{
return
(
<
div
>
<
Card
>
<
CardBody
>
<
CardTitle
>
{
props
.
author
}
<
/CardTitle
>
<
CardText
>
{
props
.
text
}
<
/CardText
>
<
Button
color
=
'danger'
>
Delete
<
/Button
>
<
Button
color
=
'info'
>
Edit
<
/Button
>
<
/CardBody
>
<
CardFooter
className
=
'text-hide'
>
{
props
.
category
}
<
/CardFooter
>
<
/Card
>
<
/div
>
);
};
export
default
Quote
;
\ No newline at end of file
src/containers/App.js
View file @
b6b1b067
...
...
@@ -3,6 +3,7 @@ import {Switch, Route} from "react-router-dom";
import
{
Container
}
from
"reactstrap"
;
import
'./App.css'
;
import
QuoteForm
from
"./QuoteForm/QuoteForm"
;
import
Quotes
from
"./Quotes/Quotes"
;
function
App
()
{
return
(
...
...
@@ -10,6 +11,8 @@ function App() {
<
Container
>
<
Switch
>
<
Route
path
=
"/add-quote"
exact
component
=
{
QuoteForm
}
/
>
<
Route
path
=
"/"
exact
component
=
{
Quotes
}
/
>
<
/Switch
>
<
/Container
>
<
/
>
...
...
src/containers/Quotes/Quotes.js
0 → 100644
View file @
b6b1b067
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
axios
from
'../../axios-quote'
import
Quote
from
"../../components/Quote/Quote"
;
const
Quotes
=
()
=>
{
const
[
quotes
,
setQuotes
]
=
useState
({});
useEffect
(()
=>
{
axios
.
get
(
'/quotes.json'
).
then
(
response
=>
{
setQuotes
(
response
.
data
)
}
)
},
[]);
const
printQuotes
=
()
=>
{
return
Object
.
keys
(
quotes
).
map
(
quote
=>
{
return
<
Quote
author
=
{
quotes
[
quote
].
author
}
text
=
{
quotes
[
quote
].
text
}
category
=
{
quotes
[
quote
].
category
}
key
=
{
quote
}
/
>
})
};
return
(
<
div
className
=
'Quotes'
>
{
Object
.
keys
(
quotes
).
length
>
0
?
printQuotes
()
:
'Please add quotes'
}
<
/div
>
)
};
export
default
Quotes
\ No newline at end of file
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