-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/categories-product-details-page
- Loading branch information
Showing
59 changed files
with
1,898 additions
and
957 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@medusajs/admin-ui": patch | ||
"@medusajs/medusa": patch | ||
--- | ||
|
||
feat(admin-ui): Adds metadata forms to all applicable domains in the UI. | ||
fix(medusa): Fixes an issue where metadata was not being set for order addresses using `setMetadata`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/admin-ui/ui/src/components/atoms/date-picker/types.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { InputHeaderProps } from "../../fundamentals/input-header" | ||
|
||
export type DateTimePickerProps = { | ||
date: Date | ||
onSubmitDate: (newDate: Date) => void | ||
date: Date | null | ||
onSubmitDate: (newDate: Date | null) => void | ||
} & InputHeaderProps |
34 changes: 34 additions & 0 deletions
34
...ges/admin-ui/ui/src/components/forms/customer-group/customer-group-general-form/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import FormValidator from "../../../../utils/form-validator" | ||
import { NestedForm } from "../../../../utils/nested-form" | ||
import InputField from "../../../molecules/input" | ||
|
||
export type CustomerGroupGeneralFormType = { | ||
name: string | ||
} | ||
|
||
type CustomerGroupGeneralFormProps = { | ||
form: NestedForm<CustomerGroupGeneralFormType> | ||
} | ||
|
||
export const CustomerGroupGeneralForm = ({ | ||
form, | ||
}: CustomerGroupGeneralFormProps) => { | ||
const { | ||
register, | ||
path, | ||
formState: { errors }, | ||
} = form | ||
|
||
return ( | ||
<div> | ||
<InputField | ||
label="Name" | ||
required | ||
{...register(path("name"), { | ||
required: FormValidator.required("Name"), | ||
})} | ||
errors={errors} | ||
/> | ||
</div> | ||
) | ||
} |
Empty file.
159 changes: 159 additions & 0 deletions
159
packages/admin-ui/ui/src/components/forms/discount/discount-configuration-form/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import { Controller } from "react-hook-form" | ||
import { NestedForm } from "../../../../utils/nested-form" | ||
import DatePicker from "../../../atoms/date-picker/date-picker" | ||
import TimePicker from "../../../atoms/date-picker/time-picker" | ||
import AvailabilityDuration from "../../../molecules/availability-duration" | ||
import InputField from "../../../molecules/input" | ||
import SwitchableItem from "../../../molecules/switchable-item" | ||
|
||
export type DiscountConfigurationFormType = { | ||
starts_at: Date | ||
ends_at: Date | null | ||
usage_limit: number | null | ||
valid_duration: string | null | ||
} | ||
|
||
type DiscountConfigurationFormProps = { | ||
form: NestedForm<DiscountConfigurationFormType> | ||
isDynamic?: boolean | ||
} | ||
|
||
const DiscountConfigurationForm = ({ | ||
form, | ||
isDynamic, | ||
}: DiscountConfigurationFormProps) => { | ||
const { control, path } = form | ||
|
||
return ( | ||
<div> | ||
<div className="gap-y-large flex flex-col"> | ||
<Controller | ||
name={path("starts_at")} | ||
control={control} | ||
render={({ field: { onChange, value } }) => { | ||
return ( | ||
<SwitchableItem | ||
open={!!value} | ||
onSwitch={() => { | ||
if (value) { | ||
onChange(null) | ||
} else { | ||
onChange(new Date()) | ||
} | ||
}} | ||
title="Discount has a start date?" | ||
description="Schedule the discount to activate in the future." | ||
> | ||
<div className="gap-x-xsmall flex items-center"> | ||
<DatePicker | ||
date={value!} | ||
label="Start date" | ||
onSubmitDate={onChange} | ||
/> | ||
<TimePicker | ||
label="Start time" | ||
date={value!} | ||
onSubmitDate={onChange} | ||
/> | ||
</div> | ||
</SwitchableItem> | ||
) | ||
}} | ||
/> | ||
<Controller | ||
name={path("ends_at")} | ||
control={control} | ||
render={({ field: { value, onChange } }) => { | ||
return ( | ||
<SwitchableItem | ||
open={!!value} | ||
onSwitch={() => { | ||
if (value) { | ||
onChange(null) | ||
} else { | ||
onChange( | ||
new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000) | ||
) | ||
} | ||
}} | ||
title="Discount has an expiry date?" | ||
description="Schedule the discount to deactivate in the future." | ||
> | ||
<div className="gap-x-xsmall flex items-center"> | ||
<DatePicker | ||
date={value!} | ||
label="Expiry date" | ||
onSubmitDate={onChange} | ||
/> | ||
<TimePicker | ||
label="Expiry time" | ||
date={value!} | ||
onSubmitDate={onChange} | ||
/> | ||
</div> | ||
</SwitchableItem> | ||
) | ||
}} | ||
/> | ||
<Controller | ||
name={path("usage_limit")} | ||
control={control} | ||
render={({ field: { value, onChange } }) => { | ||
return ( | ||
<SwitchableItem | ||
open={!!value} | ||
onSwitch={() => { | ||
if (value) { | ||
onChange(null) | ||
} else { | ||
onChange(10) | ||
} | ||
}} | ||
title="Limit the number of redemtions?" | ||
description="Limit applies across all customers, not per customer." | ||
> | ||
<InputField | ||
label="Number of redemptions" | ||
type="number" | ||
placeholder="5" | ||
min={1} | ||
defaultValue={value ?? undefined} | ||
onChange={(value) => onChange(value.target.valueAsNumber)} | ||
/> | ||
</SwitchableItem> | ||
) | ||
}} | ||
/> | ||
{isDynamic && ( | ||
<Controller | ||
name={path("valid_duration")} | ||
control={control} | ||
render={({ field: { onChange, value } }) => { | ||
return ( | ||
<SwitchableItem | ||
open={!!value} | ||
onSwitch={() => { | ||
if (value) { | ||
onChange(null) | ||
} else { | ||
onChange("P0Y0M0DT00H00M") | ||
} | ||
}} | ||
title="Availability duration?" | ||
description="Set the duration of the discount." | ||
> | ||
<AvailabilityDuration | ||
value={value ?? undefined} | ||
onChange={onChange} | ||
/> | ||
</SwitchableItem> | ||
) | ||
}} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default DiscountConfigurationForm |
Oops, something went wrong.