Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
ESDP_froot.kz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
ESDP_froot.kz
ESDP_froot.kz
Commits
e9040e51
Commit
e9040e51
authored
Mar 23, 2021
by
Elena Tsoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#30
внесены корректировки
parent
14e185fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
40 deletions
+25
-40
PaymentForm.js
front/src/components/UI/Forms/PaymentForm/PaymentForm.js
+0
-10
EditPayment.js
front/src/containers/EditPayment/EditPayment.js
+25
-30
No files found.
front/src/components/UI/Forms/PaymentForm/PaymentForm.js
View file @
e9040e51
...
@@ -22,16 +22,6 @@ const PaymentForm = ({onSubmit, paymentId}) => {
...
@@ -22,16 +22,6 @@ const PaymentForm = ({onSubmit, paymentId}) => {
repeatibility
:
false
,
repeatibility
:
false
,
periodicity
:
""
periodicity
:
""
});
});
// const dispatch = useDispatch();
// useEffect(() => {
// dispatch(fetchPaymentById(paymentId)).then(payment=> {
// let stateCopy = {};
// Object.keys(state).forEach(key => {
// stateCopy[key] = payment[key];
// });
// setState({...stateCopy});
// })
// }, [dispatch]);
const
inputChangeHandler
=
(
event
)
=>
{
const
inputChangeHandler
=
(
event
)
=>
{
const
{
name
,
value
}
=
event
.
target
;
const
{
name
,
value
}
=
event
.
target
;
...
...
front/src/containers/EditPayment/EditPayment.js
View file @
e9040e51
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
editPayment
,
fetchPaymentById
}
from
"../../store/actions/paymentAction"
;
import
{
editPayment
,
fetchPaymentById
}
from
"../../store/actions/paymentAction"
;
import
icon
from
"../../assets/images/icon-close.png"
import
icon
from
"../../assets/images/icon-close.png"
import
{
push
}
from
'connected-react-router'
import
{
push
}
from
'connected-react-router'
...
@@ -10,38 +10,36 @@ import FileInput from "../../components/UI/Forms/FileInput";
...
@@ -10,38 +10,36 @@ import FileInput from "../../components/UI/Forms/FileInput";
const
EditPayment
=
()
=>
{
const
EditPayment
=
()
=>
{
const
{
id
}
=
useParams
()
const
{
id
}
=
useParams
()
const
payment
=
useSelector
((
state
)
=>
state
.
payments
.
paymentById
);
console
.
log
(
payment
)
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
dateOfPayment
:
payment
.
dateOfPayment
,
dateOfPayment
:
""
,
payer
:
payment
.
payer
,
payer
:
""
,
purpose
:
payment
.
purpose
,
purpose
:
""
,
invoice
:
payment
.
invoice
,
invoice
:
""
,
comment
:
payment
.
comment
?
payment
.
comment
:
""
,
comment
:
""
,
costCenter
:
payment
.
costCenter
?
payment
.
costCenter
:
""
,
costCenter
:
""
,
contractor
:
payment
.
contractor
,
contractor
:
""
,
termOfPayment
:
payment
.
termOfPayment
?
payment
.
termOfPayment
:
""
,
termOfPayment
:
""
,
daysOfTermPayment
:
payment
.
daysOfTermPayment
?
payment
.
daysOfTermPayment
:
""
,
daysOfTermPayment
:
""
,
priority
:
payment
.
priority
,
priority
:
"Стандартный"
,
image
:
payment
.
image
,
image
:
""
,
sum
:
payment
.
sum
,
sum
:
""
,
repeatibility
:
payment
.
repeatibility
?
payment
.
repeatibility
:
false
,
repeatibility
:
false
,
periodicity
:
payment
.
periodicity
?
payment
.
periodicity
:
""
periodicity
:
""
});
});
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchPaymentById
(
id
))
dispatch
(
fetchPaymentById
(
id
))
},
[
dispatch
]);
},
[
dispatch
]);
//
useEffect(() => {
useEffect
(()
=>
{
//
dispatch(fetchPaymentById(id)).then(payment=> {
dispatch
(
fetchPaymentById
(
id
)).
then
(
payment
=>
{
//
let stateCopy = {};
let
stateCopy
=
{};
//
Object.keys(state).forEach(key => {
Object
.
keys
(
state
).
forEach
(
key
=>
{
//
stateCopy[key] = payment[key];
stateCopy
[
key
]
=
payment
[
key
];
//
});
});
//
setState({...stateCopy});
setState
({...
stateCopy
});
//
console.log('state', state)
console
.
log
(
'state'
,
state
)
//
})
})
//
}, [dispatch]);
},
[
dispatch
]);
const
inputChangeHandler
=
(
event
)
=>
{
const
inputChangeHandler
=
(
event
)
=>
{
const
{
name
,
value
}
=
event
.
target
;
const
{
name
,
value
}
=
event
.
target
;
setState
((
prevState
)
=>
{
setState
((
prevState
)
=>
{
...
@@ -57,14 +55,11 @@ const EditPayment = () => {
...
@@ -57,14 +55,11 @@ const EditPayment = () => {
}));
}));
};
};
const
submitFormHandler
=
async
event
=>
{
const
submitFormHandler
=
async
event
=>
{
console
.
log
(
"state"
,
state
)
event
.
preventDefault
();
event
.
preventDefault
();
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
Object
.
keys
(
state
).
forEach
((
key
)
=>
{
Object
.
keys
(
state
).
forEach
((
key
)
=>
{
formData
.
append
(
key
,
state
[
key
]);
formData
.
append
(
key
,
state
[
key
]);
});
});
console
.
log
(
"formData"
,
formData
)
await
dispatch
(
editPayment
(
id
,
formData
))
await
dispatch
(
editPayment
(
id
,
formData
))
};
};
const
closeHandler
=
()
=>
{
const
closeHandler
=
()
=>
{
...
...
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