Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AddressField/AddressField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const AddressField = ({ countryFieldProps, regionFieldProps }: AddressFie
return (
<>
<CountryField onChange={onCountryFieldChange} {...countryFieldProps}/>
<RegionField {...regionFieldProps}/>
<RegionField {...regionFieldProps} countryFieldName={countryFieldProps.name}/>
</>
);
};
7 changes: 3 additions & 4 deletions src/components/AddressField/RegionField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AutocompleteRenderInputParams } from "@mui/material/Autocomplete";
import { Field, FieldProps, useFormikContext } from "formik";
import { Field, FieldProps, getIn, useFormikContext } from "formik";
import { useEffect, useState } from "react";

import { InputWithLabel } from "@components/TextField";
Expand Down Expand Up @@ -30,13 +30,12 @@ export const RegionField =
values,
setFieldValue
} = useFormikContext<FormValues>();
const fieldValue = values[name]?.value;
const fieldValue = getIn(values, name)?.value;
const [inputValue, setInputValue] = useState(fieldValue || "");

const country = values[countryFieldName];
const country = getIn(values, countryFieldName);
const states = country?.value && locales[country.value] ? locales[country.value].states : undefined;


useEffect(() => {
if (!fieldValue) {
setInputValue("");
Expand Down
10 changes: 9 additions & 1 deletion src/components/Sidebar/defaultSidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LocalOfferOutlinedIcon from "@mui/icons-material/LocalOfferOutlined";
import CategoryOutlinedIcon from "@mui/icons-material/CategoryOutlined";
import AdminPanelSettingsOutlinedIcon from "@mui/icons-material/AdminPanelSettingsOutlined";
import FaceIcon from "@mui/icons-material/Face";
import LocationOnIcon from "@mui/icons-material/LocationOn";

import { SidebarItemProps } from "./SidebarItem";

Expand All @@ -25,7 +26,8 @@ export const FEATURE_KEYS = {
shippingFulfillment: "shippingFulfillment",
categories: "categories",
emails: "emails",
stores: "stores"
stores: "stores",
locations: "locations"
};

export type ItemProps = SidebarItemProps & {
Expand Down Expand Up @@ -101,6 +103,12 @@ export const CORE_FEATURES: ItemProps[] = [
icon: <LocalShippingOutlinedIcon fontSize="small" />,
to: "/settings/shipping-fulfillment"
},
{
key: FEATURE_KEYS.locations,
text: "Locations",
icon: <LocationOnIcon fontSize="small" />,
to: "/settings/locations/warehouses"
},
{
key: FEATURE_KEYS.emails,
text: "Transactional Emails",
Expand Down
57 changes: 57 additions & 0 deletions src/components/TimePickerField/TimePickerField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { TimePicker, TimePickerProps } from "@mui/x-date-pickers/TimePicker";
import { FieldProps, getIn } from "formik";

import { InputWithLabel } from "@components/TextField";


type TimePickerFieldProps = TimePickerProps<unknown, Date> & FieldProps
export const DEFAULT_TIME_FORMAT = "hh:mm a";

export const TimePickerField = ({
field,
form: { isSubmitting, errors, setFieldValue },
onChange,
disabled,
onAccept,
inputFormat = DEFAULT_TIME_FORMAT,
...props
}: TimePickerFieldProps) => {
const {
onChange: fieldOnChange,
onBlur: fieldOnBlur,
multiple: _multiple,
...restFieldProps
} = field;

const fieldError = getIn(errors, restFieldProps.name) as string;
const helperText = fieldError ?? undefined;

const _onChange =
onChange ?? ((value) => setFieldValue(restFieldProps.name, value));


const _onAccept = (value: Date | null) => {
onAccept?.(value) ?? setFieldValue(restFieldProps.name, value);
};

return (
<TimePicker
{...props}
{...restFieldProps}
onChange={_onChange}
disabled={disabled ?? isSubmitting}
inputFormat={inputFormat}
onAccept={_onAccept}
mask="__:__ _M"
renderInput={
({ inputRef, ...params }) =>
<InputWithLabel
{...params}
ref={inputRef}
error={!!helperText}
helperText={helperText}
/>
}
/>
);
};
1 change: 1 addition & 0 deletions src/components/TimePickerField/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./TimePickerField";
Loading