Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
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
Евгений Положенцев
planner-team-one
Commits
8a1dd26e
Commit
8a1dd26e
authored
Nov 29, 2022
by
Ibadullina Inabat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#73
реализована модалка на добавление проекта
parent
5c2142fd
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
27 deletions
+51
-27
App.js
planner-front/src/App.js
+0
-8
ProjectForm.js
planner-front/src/components/ProjectForm/ProjectForm.js
+40
-11
FullProject.js
planner-front/src/containers/FullProject/FullProject.js
+1
-1
NewProject.js
planner-front/src/containers/NewProject/NewProject.js
+5
-2
Projects.js
planner-front/src/containers/Projects/Projects.js
+2
-3
projectsActions.js
planner-front/src/store/actions/projectsActions.js
+3
-2
No files found.
planner-front/src/App.js
View file @
8a1dd26e
...
@@ -51,14 +51,6 @@ const App = () => {
...
@@ -51,14 +51,6 @@ const App = () => {
<
FullProject
/>
<
FullProject
/>
<
/ProtectedRoute
>
<
/ProtectedRoute
>
}
/
>
}
/
>
<
Route
path
=
{
"/projects/add"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/sign-in"
}
>
<
NewProject
/>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/"
}
element
=
{
<
Route
path
=
{
"/"
}
element
=
{
<
ProtectedRoute
<
ProtectedRoute
isAllowed
=
{
user
}
isAllowed
=
{
user
}
...
...
planner-front/src/components/ProjectForm/ProjectForm.js
View file @
8a1dd26e
import
{
B
utton
,
Grid
}
from
"@mui/material"
;
import
{
B
ox
,
Button
,
Grid
,
Modal
}
from
"@mui/material"
;
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
{
useSelector
}
from
"react-redux"
;
import
{
useSelector
}
from
"react-redux"
;
import
FormElement
from
"../UI/Form/FormElement/FormElement"
;
import
FormElement
from
"../UI/Form/FormElement/FormElement"
;
import
{
Typography
}
from
"@mui/material"
;
const
style
=
{
position
:
'absolute'
,
top
:
'50%'
,
left
:
'50%'
,
transform
:
'translate(-50%, -50%)'
,
width
:
400
,
bgcolor
:
'background.paper'
,
border
:
'2px solid #000'
,
boxShadow
:
24
,
p
:
4
,
};
const
ProjectForm
=
({
onSubmit
})
=>
{
const
ProjectForm
=
({
onSubmit
})
=>
{
const
users
=
useSelector
(
state
=>
state
.
users
)
const
users
=
useSelector
(
state
=>
state
.
users
)
console
.
log
(
users
)
console
.
log
(
users
)
const
[
open
,
setOpen
]
=
useState
(
false
);
const
handleOpen
=
()
=>
setOpen
(
true
);
const
handleClose
=
()
=>
setOpen
(
false
);
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
title
:
""
,
title
:
""
color
:
""
});
});
const
submitFormHandler
=
(
e
)
=>
{
const
submitFormHandler
=
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
let
project
=
{
title
:
state
.
title
,
color
:
state
.
color
}
let
project
=
{
title
:
state
.
title
}
console
.
log
(
project
);
console
.
log
(
project
);
onSubmit
(
project
);
onSubmit
(
project
);
};
};
const
inputChangeHandler
=
(
e
)
=>
{
const
inputChangeHandler
=
(
e
)
=>
{
...
@@ -26,31 +42,44 @@ const ProjectForm = ({onSubmit}) => {
...
@@ -26,31 +42,44 @@ const ProjectForm = ({onSubmit}) => {
});
});
};
};
return
<
form
onSubmit
=
{
submitFormHandler
}
>
return
(
<
div
>
<
Button
onClick
=
{
handleOpen
}
>
Add
project
<
/Button
>
<
Modal
open
=
{
open
}
onClose
=
{
handleClose
}
aria
-
labelledby
=
"modal-modal-title"
aria
-
describedby
=
"modal-modal-description"
onSubmit
=
{
submitFormHandler
}
>
<
Box
sx
=
{
style
}
>
<
form
>
<
Grid
container
direction
=
"column"
spacing
=
{
2
}
>
<
Grid
container
direction
=
"column"
spacing
=
{
2
}
>
<
Typography
variant
=
"h4"
>
New
project
<
/Typography
>
<
FormElement
<
FormElement
onChange
=
{
inputChangeHandler
}
onChange
=
{
inputChangeHandler
}
name
=
{
"title"
}
name
=
{
"title"
}
label
=
{
"Title"
}
label
=
{
"Title"
}
state
=
{
state
}
state
=
{
state
}
/
>
<
FormElement
onChange
=
{
inputChangeHandler
}
name
=
{
"color"
}
label
=
{
"Color"
}
state
=
{
state
}
/
>
/
>
<
Grid
item
>
<
Grid
item
>
<
Button
<
Button
type
=
"submit"
type
=
"submit"
color
=
"primary"
color
=
"primary"
variant
=
"contained"
variant
=
"contained"
>
>
Create
Create
<
/Button
>
<
/Button
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
<
/form
>
<
/form
>
<
/Box
>
<
/Modal
>
<
/div
>
);
};
};
export
default
ProjectForm
;
export
default
ProjectForm
;
\ No newline at end of file
planner-front/src/containers/FullProject/FullProject.js
View file @
8a1dd26e
...
@@ -34,7 +34,7 @@ const FullProject = () => {
...
@@ -34,7 +34,7 @@ const FullProject = () => {
<
/strong
>
<
/strong
>
<
strong
>
<
strong
>
<
br
><
/br
>
<
br
><
/br
>
Админ
проекта
:
{
project
?.
project
?.
members
}
{
/* Админ проекта: {project?.project?.members} */
}
<
/strong
>
<
/strong
>
<
strong
>
<
strong
>
<
br
><
/br
>
<
br
><
/br
>
...
...
planner-front/src/containers/NewProject/NewProject.js
View file @
8a1dd26e
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
Typography
}
from
"@mui/material"
;
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
ProjectForm
from
"../../components/ProjectForm/ProjectForm"
;
import
ProjectForm
from
"../../components/ProjectForm/ProjectForm"
;
import
{
createProject
,
fetchProjects
}
from
"../../store/actions/projectsActions"
;
import
{
createProject
,
fetchProjects
}
from
"../../store/actions/projectsActions"
;
...
@@ -9,8 +9,12 @@ const NewProject = () => {
...
@@ -9,8 +9,12 @@ const NewProject = () => {
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
projects
=
useSelector
(
state
=>
state
.
projects
.
projects
);
const
projects
=
useSelector
(
state
=>
state
.
projects
.
projects
);
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
let
lastProject
=
projects
.
projects
[
projects
.
projects
.
length
-
1
];
const
onSubmit
=
async
(
projectData
)
=>
{
const
onSubmit
=
async
(
projectData
)
=>
{
await
dispatch
(
createProject
(
projectData
,
navigate
));
await
dispatch
(
createProject
(
projectData
,
navigate
));
console
.
log
(
projectData
)
console
.
log
(
lastProject
)
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -19,7 +23,6 @@ const NewProject = () => {
...
@@ -19,7 +23,6 @@ const NewProject = () => {
return
(
return
(
<>
<>
<
Typography
variant
=
"h2"
>
New
project
<
/Typography
>
<
ProjectForm
projects
=
{
projects
}
onSubmit
=
{
onSubmit
}
/
>
<
ProjectForm
projects
=
{
projects
}
onSubmit
=
{
onSubmit
}
/
>
<
/
>
<
/
>
);
);
...
...
planner-front/src/containers/Projects/Projects.js
View file @
8a1dd26e
...
@@ -6,6 +6,7 @@ import Loader from "../../components/UI/Loader/Loader";
...
@@ -6,6 +6,7 @@ import Loader from "../../components/UI/Loader/Loader";
import
HasAccess
from
"../../components/UI/HasAccess/HasAccess"
;
import
HasAccess
from
"../../components/UI/HasAccess/HasAccess"
;
import
{
fetchProjects
}
from
"../../store/actions/projectsActions"
;
import
{
fetchProjects
}
from
"../../store/actions/projectsActions"
;
import
ProjectsList
from
"../../components/ProjectsList/ProjectsList"
;
import
ProjectsList
from
"../../components/ProjectsList/ProjectsList"
;
import
NewProject
from
"../NewProject/NewProject"
;
const
Projects
=
()
=>
{
const
Projects
=
()
=>
{
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
...
@@ -34,9 +35,7 @@ const Projects = () => {
...
@@ -34,9 +35,7 @@ const Projects = () => {
<
/Grid
>
<
/Grid
>
<
HasAccess
roles
=
{[
"superuser"
,
"admin"
,
"user"
]}
>
<
HasAccess
roles
=
{[
"superuser"
,
"admin"
,
"user"
]}
>
<
Grid
item
>
<
Grid
item
>
<
Button
component
=
{
Link
}
to
=
"/projects/add"
>
<
NewProject
/>
Add
project
<
/Button
>
<
/Grid
>
<
/Grid
>
<
/HasAccess
>
<
/HasAccess
>
<
/Grid
>
<
/Grid
>
...
...
planner-front/src/store/actions/projectsActions.js
View file @
8a1dd26e
...
@@ -46,9 +46,10 @@ export const fetchProject = (id) => {
...
@@ -46,9 +46,10 @@ export const fetchProject = (id) => {
export
const
createProject
=
(
projectData
,
navigate
)
=>
{
export
const
createProject
=
(
projectData
,
navigate
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
try
{
try
{
await
axios
.
post
(
"/projects"
,
projectData
);
const
response
=
await
axios
.
post
(
"/projects"
,
projectData
);
dispatch
(
createProjectSuccess
());
dispatch
(
createProjectSuccess
());
navigate
(
"/"
);
console
.
log
(
response
.
data
)
navigate
(
"/projects/"
+
response
.
data
.
project
.
id
)
dispatch
(
showNotification
(
"Проект успешно создан"
))
dispatch
(
showNotification
(
"Проект успешно создан"
))
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
);
...
...
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