Skip to content

Commit

Permalink
wrapped rate editor in real form
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasFoydel committed Feb 20, 2023
1 parent df695cb commit 3511a49
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client/src/Pages/CoachPages/Settings/settingForms/RateEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { toast } from 'react-toastify'
const RateEditor = ({ props: { rate, onComplete, token } }) => {
const [input, setInput] = useState(rate || 0)

const handleSubmit = () => {
const handleSubmit = (e) => {
e.preventDefault()
axios
.put(
'/api/user/settings/trainer/rate/',
Expand All @@ -17,7 +18,7 @@ const RateEditor = ({ props: { rate, onComplete, token } }) => {
}

return (
<div className="rate-editor">
<form className="rate-editor" onSubmit={handleSubmit}>
{rate ? (
<div>
<h3>Current Rate:</h3> <span data-testid="rate-display">${rate}</span>
Expand All @@ -26,17 +27,18 @@ const RateEditor = ({ props: { rate, onComplete, token } }) => {
<div>rate not set</div>
)}
<input
min={1}
value={input}
type="number"
className="input"
placeholder="rate"
data-testid="rate-editor-input"
onChange={({ target: { value } }) => setInput(value)}
/>
<button onClick={handleSubmit} data-testid="rate-editor-btn">
<button type="submit" data-testid="rate-editor-btn">
update
</button>
</div>
</form>
)
}

Expand Down

0 comments on commit 3511a49

Please sign in to comment.