import { DeleteFilled, ReloadOutlined } from "@ant-design/icons"; import { Button, Col, Form, Input, InputNumber, Row, Select, Space, Switch, TimePicker, Tooltip } from "antd"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import ColorpickerFormItemComponent from "../form-items-formatted/colorpicker-form-item.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import ConfigListEmptyState from "../layout-form-row/config-list-empty-state.component.jsx"; import InlineValidatedFormRow from "../layout-form-row/inline-validated-form-row.component.jsx"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import { ColorPicker } from "./shop-info.rostatus.component"; import { DEFAULT_TRANSLUCENT_CARD_COLOR, DEFAULT_TRANSLUCENT_PICKER_COLOR, getTintedCardSurfaceStyles } from "./shop-info.color.utils"; import "./shop-info.scheduling.styles.scss"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); const mapDispatchToProps = () => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); const WORKING_DAYS = [ { key: "sunday", labelKey: "general.labels.sunday" }, { key: "monday", labelKey: "general.labels.monday" }, { key: "tuesday", labelKey: "general.labels.tuesday" }, { key: "wednesday", labelKey: "general.labels.wednesday" }, { key: "thursday", labelKey: "general.labels.thursday" }, { key: "friday", labelKey: "general.labels.friday" }, { key: "saturday", labelKey: "general.labels.saturday" } ]; const APPOINTMENT_COLOR_PICKER_STYLES = { default: { wrap: { display: "flex", flexWrap: "wrap", gap: "12px", alignItems: "flex-start" }, hue: { flex: "1 1 180px", height: "12px", position: "relative", marginTop: "20px" }, swatches: { flex: "1 1 160px" } } }; const SCHEDULING_BUCKET_COLOR_PICKER_STYLES = { default: { picker: { width: "100%", height: "100%", background: "color-mix(in srgb, var(--imex-form-surface) 92%, transparent)", boxShadow: "none", border: "1px solid color-mix(in srgb, var(--imex-form-surface-border) 72%, transparent)", borderRadius: "8px", boxSizing: "border-box", overflow: "hidden" }, saturation: { width: "100%", paddingBottom: "48%", position: "relative", borderRadius: "8px 8px 0 0", overflow: "hidden" }, body: { padding: "12px" }, controls: { display: "flex", gap: "10px" }, color: { width: "28px" }, swatch: { marginTop: "0", width: "12px", height: "12px", borderRadius: "999px" }, toggles: { flex: "1" }, hue: { height: "10px", position: "relative", marginBottom: "8px" }, alpha: { height: "10px", position: "relative" } } }; const SECTION_TITLE_INPUT_STYLE = { background: "color-mix(in srgb, var(--imex-form-surface) 78%, transparent)", border: "1px solid color-mix(in srgb, var(--imex-form-surface-border) 72%, transparent)", borderRadius: 6, fontWeight: 500 }; const SECTION_TITLE_INPUT_ROW_STYLE = { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center", minWidth: 180, maxWidth: "100%" }; const SECTION_TITLE_INPUT_GROUP_STYLE = { display: "flex", alignItems: "center", gap: 6, minWidth: 0 }; const SECTION_TITLE_INPUT_LABEL_STYLE = { fontSize: 12, lineHeight: 1.1, opacity: 0.75, whiteSpace: "nowrap" }; export function ShopInfoSchedulingComponent({ form, bodyshop }) { const { t } = useTranslation(); const appointmentColors = Form.useWatch(["appt_colors"], form) || form.getFieldValue(["appt_colors"]) || []; const schedulingBuckets = Form.useWatch(["ssbuckets"], form) || form.getFieldValue(["ssbuckets"]) || []; return (
<> {WORKING_DAYS.map(({ key, labelKey }) => ( ))} {(fields, { add, remove, move }) => { return ( { add({ color: { ...DEFAULT_TRANSLUCENT_PICKER_COLOR, rgb: { ...DEFAULT_TRANSLUCENT_PICKER_COLOR.rgb } } }); }} > {t("bodyshop.actions.addapptcolor")} ]} >
{fields.length === 0 ? ( ) : ( fields.map((field, index) => { const appointmentColor = appointmentColors[field.name] || form.getFieldValue(["appt_colors", field.name]) || {}; const appointmentColorSurfaceStyles = getTintedCardSurfaceStyles(appointmentColor.color); return (
} extra={
); }} {HasFeatureAccess({ featureName: "smartscheduling", bodyshop }) && ( {(fields, { add, remove, move }) => { return ( { add({ color: { ...DEFAULT_TRANSLUCENT_CARD_COLOR } }); }} > {t("bodyshop.actions.addbucket")} ]} >
{fields.length === 0 ? ( ) : ( fields.map((field, index) => { const schedulingBucket = schedulingBuckets[field.name] || form.getFieldValue(["ssbuckets", field.name]) || {}; const schedulingBucketSurfaceStyles = getTintedCardSurfaceStyles(schedulingBucket.color); return (
{t("bodyshop.fields.ssbuckets.id")}
{t("bodyshop.fields.ssbuckets.label")}
} extra={