IO-3624 Polish config empty states and admin cards
This commit is contained in:
@@ -7,6 +7,7 @@ import { ChromePicker } from "react-color";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { getFormListItemTitle } from "../form-list-move-arrows/form-list-item-title.utils";
|
||||
import ConfigListEmptyState from "../layout-form-row/config-list-empty-state.component.jsx";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
import { DEFAULT_TRANSLUCENT_CARD_COLOR, getTintedCardSurfaceStyles } from "./shop-info.color.utils";
|
||||
|
||||
@@ -405,106 +406,116 @@ export function ShopInfoROStatusComponent({ bodyshop, form }) {
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
{Production_List_Status_Colors.treatment === "on" && (
|
||||
<LayoutFormRow grow header={t("bodyshop.fields.statuses.production_colors")} id="production_colors">
|
||||
<Form.List name={["md_ro_statuses", "production_colors"]}>
|
||||
{(fields, { add, remove }) => {
|
||||
return (
|
||||
<Form.List name={["md_ro_statuses", "production_colors"]}>
|
||||
{(fields, { add, remove }) => {
|
||||
return (
|
||||
<LayoutFormRow
|
||||
grow
|
||||
header={t("bodyshop.fields.statuses.production_colors")}
|
||||
id="production_colors"
|
||||
actions={[
|
||||
<Button
|
||||
key="add-production-status-color"
|
||||
type="primary"
|
||||
block
|
||||
onClick={() => {
|
||||
add({
|
||||
color: { ...DEFAULT_TRANSLUCENT_CARD_COLOR }
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("bodyshop.actions.add_production_status_color")}
|
||||
</Button>
|
||||
]}
|
||||
>
|
||||
<div>
|
||||
<Space size="large" wrap align="start">
|
||||
{fields.map((field, index) => {
|
||||
const productionColor = productionColors[field.name] || {};
|
||||
const productionColorSurfaceStyles = getTintedCardSurfaceStyles(productionColor.color);
|
||||
const selectedProductionColorStatuses = productionColors
|
||||
.map((item) => item?.status)
|
||||
.filter(Boolean);
|
||||
const productionColorStatusOptions = [
|
||||
...new Set([productionColor.status, ...availableProductionStatuses])
|
||||
]
|
||||
.filter(Boolean)
|
||||
.filter(
|
||||
(status) =>
|
||||
status === productionColor.status || !selectedProductionColorStatuses.includes(status)
|
||||
);
|
||||
{fields.length === 0 ? (
|
||||
<ConfigListEmptyState actionLabel={t("bodyshop.actions.add_production_status_color")} />
|
||||
) : (
|
||||
<Space size="large" wrap align="start">
|
||||
{fields.map((field, index) => {
|
||||
const productionColor = productionColors[field.name] || {};
|
||||
const productionColorSurfaceStyles = getTintedCardSurfaceStyles(productionColor.color);
|
||||
const selectedProductionColorStatuses = productionColors
|
||||
.map((item) => item?.status)
|
||||
.filter(Boolean);
|
||||
const productionColorStatusOptions = [
|
||||
...new Set([productionColor.status, ...availableProductionStatuses])
|
||||
]
|
||||
.filter(Boolean)
|
||||
.filter(
|
||||
(status) =>
|
||||
status === productionColor.status || !selectedProductionColorStatuses.includes(status)
|
||||
);
|
||||
|
||||
return (
|
||||
<LayoutFormRow
|
||||
key={field.key}
|
||||
noDivider
|
||||
title={
|
||||
<Form.Item
|
||||
noStyle
|
||||
key={`${index}status`}
|
||||
name={[field.name, "status"]}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Select
|
||||
className="production-status-color-title-select"
|
||||
variant="borderless"
|
||||
placeholder={getFormListItemTitle(
|
||||
t("jobs.fields.status"),
|
||||
index,
|
||||
productionColor.status
|
||||
)}
|
||||
options={productionColorStatusOptions.map((item) => ({
|
||||
value: item,
|
||||
label: item
|
||||
}))}
|
||||
return (
|
||||
<LayoutFormRow
|
||||
key={field.key}
|
||||
noDivider
|
||||
title={
|
||||
<Form.Item
|
||||
noStyle
|
||||
key={`${index}status`}
|
||||
name={[field.name, "status"]}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Select
|
||||
className="production-status-color-title-select"
|
||||
variant="borderless"
|
||||
placeholder={getFormListItemTitle(
|
||||
t("jobs.fields.status"),
|
||||
index,
|
||||
productionColor.status
|
||||
)}
|
||||
options={productionColorStatusOptions.map((item) => ({
|
||||
value: item,
|
||||
label: item
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
}
|
||||
extra={
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<DeleteFilled />}
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
}
|
||||
extra={
|
||||
<Button
|
||||
type="text"
|
||||
icon={<DeleteFilled />}
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
{...productionColorSurfaceStyles}
|
||||
style={{ width: 260, marginBottom: 0 }}
|
||||
>
|
||||
<div>
|
||||
<Form.Item
|
||||
key={`${index}color`}
|
||||
name={[field.name, "color"]}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<ColorPicker />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</LayoutFormRow>
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
<Form.Item style={{ marginTop: 8 }}>
|
||||
<Button
|
||||
type="dashed"
|
||||
onClick={() => {
|
||||
add({
|
||||
color: { ...DEFAULT_TRANSLUCENT_CARD_COLOR }
|
||||
});
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
>
|
||||
{t("general.actions.add")}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
}
|
||||
{...productionColorSurfaceStyles}
|
||||
style={{ width: 260, marginBottom: 0 }}
|
||||
>
|
||||
<div>
|
||||
<Form.Item
|
||||
key={`${index}color`}
|
||||
name={[field.name, "color"]}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<ColorPicker />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</LayoutFormRow>
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</Form.List>
|
||||
</LayoutFormRow>
|
||||
</LayoutFormRow>
|
||||
);
|
||||
}}
|
||||
</Form.List>
|
||||
)}
|
||||
</SelectorDiv>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user