Skip to content

Commit

Permalink
fix: removed extra format, fixed initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
Anzhela-Sahakyan committed Sep 18, 2024
1 parent ba72e70 commit 458fc30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/Body/Fields/Time/Time.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useEffect, useState } from 'react'
import React, { Fragment } from 'react'
import { Input, Select } from 'boomform'
import { getTimeFields } from './../../../Helpers/time'
import { getInitial, getValidation } from './../../../Helpers/global'
Expand All @@ -15,10 +15,6 @@ const Time = ({
payment,
...props
}) => {
const [amPm, setAmPm] = useState(placeholders.format)
useEffect(() => {
setAmPm(placeholders.format)
}, [placeholders.format])
return (
<>
{getTimeFields(format, placeholders).map(item => {
Expand All @@ -45,10 +41,10 @@ const Time = ({
<Select
{...props}
id={`${id}.${key}`}
initial={initials?.format || 1}
initial={initials?.format === 'PM' ? 2 : 1}
options={[
{ key: 1, value: amPm },
{ key: 2, value: amPm === 'AM' ? 'PM' : 'AM' }
{ key: 1, value: 'AM' },
{ key: 2, value: 'PM' }
]}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const getTimeFields = (format, placeholders) => {
const fields = [
{ key: 'hour', placeholder: placeholders?.hour || 'HH' },
{ key: 'minute', placeholder: placeholders?.minute || 'MM' },
{ key: 'format', placeholder: placeholders?.format || 'AM/PM' }
{ key: 'format' }
]
return format === '24h' ? fields.splice(0, 2) : fields
}

0 comments on commit 458fc30

Please sign in to comment.