IO-940 Clear event color and ats.

This commit is contained in:
Patrick Fic
2021-04-26 13:40:39 -07:00
parent ccc1a37ebb
commit 438692ea7c
2 changed files with 17 additions and 3 deletions

View File

@@ -21,7 +21,10 @@ export function ScheduleEventColor({ bodyshop, event }) {
const onClick = async ({ key }) => { const onClick = async ({ key }) => {
const result = await updateAppointment({ const result = await updateAppointment({
variables: { appid: event.id, app: { color: key } }, variables: {
appid: event.id,
app: { color: key === "null" ? null : key },
},
}); });
if (!!!result.errors) { if (!!!result.errors) {
@@ -34,6 +37,13 @@ export function ScheduleEventColor({ bodyshop, event }) {
}); });
} }
}; };
const selectedColor =
event.color &&
bodyshop.appt_colors &&
bodyshop.appt_colors.filter((color) => color.color.hex === event.color)[0]
?.label;
const menu = ( const menu = (
<Menu selectedKeys={[event.color]} onClick={onClick}> <Menu selectedKeys={[event.color]} onClick={onClick}>
{bodyshop.appt_colors && {bodyshop.appt_colors &&
@@ -42,11 +52,15 @@ export function ScheduleEventColor({ bodyshop, event }) {
{color.label} {color.label}
</Menu.Item> </Menu.Item>
))} ))}
<Menu.Divider />
<Menu.Item key={"null"}>{t("general.actions.clear")}</Menu.Item>
</Menu> </Menu>
); );
console.log(`event`, event);
return ( return (
<Dropdown overlay={menu}> <Dropdown overlay={menu}>
<a href=" #" onClick={(e) => e.preventDefault()}> <a href=" #" onClick={(e) => e.preventDefault()}>
{selectedColor}
<DownOutlined /> <DownOutlined />
</a> </a>
</Dropdown> </Dropdown>

View File

@@ -134,7 +134,7 @@ export function ScheduleJobModalComponent({
</LayoutFormRow> </LayoutFormRow>
<LayoutFormRow grow> <LayoutFormRow grow>
<Form.Item name="color" label={t("appointments.fields.color")}> <Form.Item name="color" label={t("appointments.fields.color")}>
<Select> <Select allowClear>
{bodyshop.appt_colors && {bodyshop.appt_colors &&
bodyshop.appt_colors.map((color) => ( bodyshop.appt_colors.map((color) => (
<Select.Option <Select.Option
@@ -151,7 +151,7 @@ export function ScheduleJobModalComponent({
name={"alt_transport"} name={"alt_transport"}
label={t("jobs.fields.alt_transport")} label={t("jobs.fields.alt_transport")}
> >
<Select> <Select allowClear>
{bodyshop.appt_alt_transport && {bodyshop.appt_alt_transport &&
bodyshop.appt_alt_transport.map((alt) => ( bodyshop.appt_alt_transport.map((alt) => (
<Select.Option key={alt}>{alt}</Select.Option> <Select.Option key={alt}>{alt}</Select.Option>