Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
My SU
frontend
Commits
05750918
Commit
05750918
authored
Jan 06, 2021
by
TJHeeringa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled Financial Settings
parent
ab7ae972
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
src/App/Pages/Financial/Settings.js
src/App/Pages/Financial/Settings.js
+28
-9
No files found.
src/App/Pages/Financial/Settings.js
View file @
05750918
...
...
@@ -2,7 +2,7 @@ import Button from "@material-ui/core/Button";
import
Container
from
"
@material-ui/core/Container
"
;
import
Typography
from
"
@material-ui/core/Typography
"
;
import
PropTypes
from
"
prop-types
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
use
Effect
,
use
State
}
from
"
react
"
;
import
{
ValidatorForm
}
from
"
react-material-ui-form-validator
"
;
import
NumberField
from
"
../../Components/Fields/NumberField
"
;
...
...
@@ -15,23 +15,42 @@ const Settings = ({ association: propAssociation }) => {
const
alerthandler
=
useAlertHandler
();
const
API
=
useAPI
();
const
[
association
,
setAssociation
]
=
useState
({...
propAssociation
});
const
[
financialSettings
,
setFinancialSettings
]
=
useState
({});
const
getFinancialSettings
=
()
=>
{
API
.
callv4
({
url
:
propAssociation
.
url
,
queryParams
:
{
fields
:
"
debt_collection_threshold
"
},
method
:
"
GET
"
,
on_succes
:
(
response
)
=>
{
setFinancialSettings
(
response
);
},
on_failure
:
()
=>
{
alerthandler
.
handleAlertHandler
(
"
error
"
,
"
Something went wrong
"
);
}
});
};
useEffect
(
getFinancialSettings
,
[
propAssociation
]);
// eslint-disable-line react-hooks/exhaustive-deps
const
handleSubmit
=
()
=>
{
alerthandler
.
handleAlertHandler
(
"
info
"
,
"
Not implemented
"
);
API
.
callv4
({
url
:
propAssociation
.
url
,
queryParams
:
{
fields
:
"
debt_collection_threshold
"
},
method
:
"
PATCH
"
,
object
:
{
debt_collection_threshold
:
association
.
debt_collection_threshold
},
on_succes
:
(
response
)
=>
setAssociation
({...
association
}),
object
:
financialSettings
,
on_succes
:
(
response
)
=>
{
alerthandler
.
handleAlertHandler
(
"
success
"
,
"
Association succesfully updated
"
);
setFinancialSettings
({...
response
});
},
on_failure
:
()
=>
{
alerthandler
.
handleAlertHandler
(
"
error
"
,
"
Something went wrong
"
);
}
});
};
const
handle
Association
Change
=
(
field
,
value
)
=>
{
set
Association
(
prevState
=>
({
const
handleChange
=
(
field
,
value
)
=>
{
set
FinancialSettings
(
prevState
=>
({
...
prevState
,
[
field
]:
value
}));
...
...
@@ -49,8 +68,8 @@ const Settings = ({ association: propAssociation }) => {
<
Wrapper
>
<
NumberField
name
=
{
"
Debt Collection Threshold
"
}
value
=
{
association
.
debt_collection_threshold
}
onChange
=
{(
event
)
=>
handle
Association
Change
(
"
debt_collection_threshold
"
,
event
.
target
.
value
)}
value
=
{
financialSettings
.
debt_collection_threshold
}
onChange
=
{(
event
)
=>
handleChange
(
"
debt_collection_threshold
"
,
event
.
target
.
value
)}
InputProps
=
{{
inputProps
:
{
step
:
0.1
,
min
:
0
...
...
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