EditableTimeField
EditableTimeField displays a time value in a read-only input. Clicking the edit icon activates a <input type="time"> picker. Supports an optional step interval (in seconds) to control the time granularity. On save the time string in HH:mm or HH:mm:ss format is persisted via API.
Props
| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| name | string | Yes | — | Field name sent as the key in the update payload. |
| value | string | No | — | Current time value in HH:mm or HH:mm:ss format. |
| updatePath | string | Yes | — | API endpoint path used to persist the change. |
| label | string | No | — | Label shown above the input. |
| description | string | No | — | Helper text shown below the label. |
| step | number | No | — | Step interval in seconds (e.g. 60 for minute-level precision). |
| apiBaseUrl | string | No | — | Base URL prepended to updatePath. |
| useAuthToken | boolean | No | false | When true, the request includes the authorization token. |
| onEditStart | () => void | No | — | Called when edit mode begins. |
| onEditSuccess | (updatedValue: string, newFormData: any) => void | No | — | Called after successful save. |
| onEditError | (error: any) => void | No | — | Called on API error; value is reverted. |
| onEditCancel | () => void | No | — | Called when the user cancels; value is reverted. |
| editIcon | string | No | "pencil" | Icon name for the edit button. |
| saveIcon | string | No | "check" | Icon name for the save button. |
| cancelIcon | string | No | "close" | Icon name for the cancel button. |
| containerStyle | React.CSSProperties | No | — | Style for the outermost wrapper. |
| inputStyle | React.CSSProperties | No | — | Style for the <input> element. |
| labelStyle | React.CSSProperties | No | — | Style for the <label> element. |
| descriptionStyle | React.CSSProperties | No | — | Style for the description <p> element. |
Usage
Basic
import React, { useState } from 'react';
import EditableTimeField from '@/components/editable-fields/EditableTimeField';
export default function Example() {
const [openingTime, setOpeningTime] = useState('09:00');
return (
<EditableTimeField
label="Opening Time"
name="opening_time"
value={openingTime}
updatePath="/v1/stores/1"
apiBaseUrl="https://api.example.com"
useAuthToken
onEditSuccess={(updated) => setOpeningTime(updated)}
/>
);
}
With minute-level step
<EditableTimeField
label="Appointment Time"
name="appointment_time"
value={appointmentTime}
step={900}
updatePath="/v1/appointments/8"
apiBaseUrl="https://api.example.com"
useAuthToken
onEditSuccess={(updated) => setAppointmentTime(updated)}
/>