Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
exam_9
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_9
Commits
a5378316
Commit
a5378316
authored
May 23, 2020
by
zarina
🌊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1
, реализована возможность создания контактов
parent
df875e31
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
0 deletions
+145
-0
axios-contacts.js
src/axios-contacts.js
+7
-0
FormToFill.js
src/components/FormToFill/FormToFill.js
+48
-0
Header.js
src/components/Header/Header.js
+21
-0
Layout.js
src/components/Layout/Layout.js
+15
-0
AddContactForm.js
src/containers/AddContactForm/AddContactForm.js
+54
-0
No files found.
src/axios-contacts.js
0 → 100644
View file @
a5378316
import
axios
from
"axios"
;
const
instance
=
axios
.
create
({
baseURL
:
"https://homeworks-33ebc.firebaseio.com/"
});
export
default
instance
;
src/components/FormToFill/FormToFill.js
0 → 100644
View file @
a5378316
import
React
from
'react'
;
import
{
Button
,
Form
,
FormGroup
,
Label
,
Input
}
from
'reactstrap'
;
const
FormToFill
=
props
=>
{
return
(
<
Form
onSubmit
=
{
props
.
submit
}
>
<
FormGroup
>
<
Label
for
=
"name"
>
Name
<
/Label
>
<
Input
type
=
"text"
name
=
"name"
value
=
{
props
.
name
}
onChange
=
{
props
.
inputHandler
}
id
=
"name"
placeholder
=
"enter name"
/>
<
/FormGroup
>
<
FormGroup
>
<
Label
for
=
"phone"
>
Phone
<
/Label
>
<
Input
type
=
"text"
name
=
"phone"
value
=
{
props
.
phone
}
onChange
=
{
props
.
inputHandler
}
id
=
"phone"
placeholder
=
"enter phone"
/>
<
/FormGroup
>
<
FormGroup
>
<
Label
for
=
"email"
>
Email
<
/Label
>
<
Input
type
=
"email"
name
=
"email"
value
=
{
props
.
email
}
onChange
=
{
props
.
inputHandler
}
id
=
"email"
placeholder
=
"enter email"
/>
<
/FormGroup
>
<
FormGroup
>
<
Label
for
=
"photo"
>
Photo
<
/Label
>
<
Input
type
=
"text"
name
=
"photo"
value
=
{
props
.
photo
}
onChange
=
{
props
.
inputHandler
}
id
=
"photo"
placeholder
=
"enter url"
/>
<
/FormGroup
>
<
Button
>
Submit
<
/Button
>
<
/Form
>
);
}
export
default
FormToFill
;
\ No newline at end of file
src/components/Header/Header.js
0 → 100644
View file @
a5378316
import
React
from
'react'
;
import
{
Navbar
,
NavbarBrand
,
Nav
,
NavItem
,}
from
'reactstrap'
;
import
{
NavLink
}
from
"react-router-dom"
;
import
Container
from
"reactstrap/es/Container"
;
const
Header
=
()
=>
{
return
(
<
Navbar
color
=
"light"
light
expand
=
"md mb-4"
>
<
Container
>
<
NavbarBrand
tag
=
{
NavLink
}
to
=
"/"
>
Contacts
<
/NavbarBrand
>
<
Nav
className
=
"ml-auto"
navbar
>
<
NavItem
>
<
NavLink
className
=
"nav-link"
to
=
"/add-contact"
>
Add
new
contact
<
/NavLink
>
<
/NavItem
>
<
/Nav
>
<
/Container
>
<
/Navbar
>
);
}
export
default
Header
;
\ No newline at end of file
src/components/Layout/Layout.js
0 → 100644
View file @
a5378316
import
React
from
"react"
;
import
Header
from
"../Header/Header"
;
const
Layout
=
props
=>
{
return
(
<>
<
Header
/>
<
main
className
=
"Layout_content"
>
{
props
.
children
}
<
/main
>
<
/
>
);
};
export
default
Layout
;
src/containers/AddContactForm/AddContactForm.js
0 → 100644
View file @
a5378316
import
React
,
{
useState
}
from
"react"
;
import
FormToFill
from
"../../components/FormToFill/FormToFill"
;
import
{
createContact
}
from
"../../store/actions"
;
import
{
connect
}
from
"react-redux"
;
const
AddContactForm
=
props
=>
{
const
[
contactInfo
,
setContactInfo
]
=
useState
({
name
:
''
,
phone
:
''
,
email
:
''
,
photo
:
''
});
const
inputHandler
=
(
e
)
=>
{
setContactInfo
({
...
contactInfo
,
[
e
.
target
.
name
]:
e
.
target
.
value
})
};
const
addContact
=
e
=>
{
e
.
preventDefault
();
const
contact
=
{
...
contactInfo
};
props
.
onContactCreated
(
contact
)
};
return
(
<>
<
div
>
<
FormToFill
inputHandler
=
{
inputHandler
}
name
=
{
contactInfo
.
name
}
phone
=
{
contactInfo
.
phone
}
email
=
{
contactInfo
.
email
}
photo
=
{
contactInfo
.
photo
}
submit
=
{
addContact
}
/
>
<
/div
>
<
/
>
);
};
const
mapDispatchToProps
=
dispatch
=>
{
return
{
onContactCreated
:
(
contact
)
=>
dispatch
(
createContact
(
contact
))
}
};
export
default
connect
(
null
,
mapDispatchToProps
)(
AddContactForm
);
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