diff --git a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx index e00e83c14..9e65f5f05 100644 --- a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx +++ b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx @@ -8,7 +8,7 @@ import { INSERT_VACATION } from "../../graphql/employees.queries"; import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component.jsx"; import { useNotification } from "../../contexts/Notifications/notificationContext.jsx"; -export default function ShopEmployeeAddVacation({ employee }) { +export default function ShopEmployeeAddVacation({ employee, buttonProps }) { const { t } = useTranslation(); const [insertVacation] = useMutation(INSERT_VACATION); @@ -117,7 +117,7 @@ export default function ShopEmployeeAddVacation({ employee }) { return ( - diff --git a/client/src/components/shop-employees/shop-employees-form.component.jsx b/client/src/components/shop-employees/shop-employees-form.component.jsx index 547143592..447558ada 100644 --- a/client/src/components/shop-employees/shop-employees-form.component.jsx +++ b/client/src/components/shop-employees/shop-employees-form.component.jsx @@ -1,7 +1,7 @@ import { DeleteFilled } from "@ant-design/icons"; import { useApolloClient, useMutation, useQuery } from "@apollo/client/react"; import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react"; -import { Button, Card, Form, Input, InputNumber, Select, Space, Switch } from "antd"; +import { Button, Card, Col, Form, Input, InputNumber, Row, Select, Space, Switch } from "antd"; import ResponsiveTable from "../responsive-table/responsive-table.component"; import { useForm } from "antd/es/form/Form"; import queryString from "query-string"; @@ -30,6 +30,7 @@ import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.c import { getFormListItemTitle } from "../form-list-move-arrows/form-list-item-title.utils"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import ShopEmployeeAddVacation from "./shop-employees-add-vacation.component"; +import FormItemEmail from "../form-items-formatted/email-form-item.component.jsx"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop @@ -42,6 +43,14 @@ export function ShopEmployeesFormComponent({ bodyshop }) { const { t } = useTranslation(); const [form] = useForm(); const employeeRates = Form.useWatch(["rates"], form) || []; + const employeeOptionsColProps = { + xs: 24, + sm: 12, + md: 8, + lg: { flex: "0 0 320px" }, + xl: { flex: "0 0 280px" }, + xxl: { flex: "0 0 380px" } + }; const history = useNavigate(); const search = queryString.parse(useLocation().search); const [deleteVacation] = useMutation(DELETE_VACATION); @@ -177,237 +186,280 @@ export function ShopEmployeesFormComponent({ bodyshop }) { } >
- - - - - - - - ({ - async validator(rule, value) { - if (value) { - const response = await client.query({ - query: CHECK_EMPLOYEE_NUMBER, - variables: { - employeenumber: value - } - }); - - if (response.data.employees_aggregate.aggregate.count === 0) { - return Promise.resolve(); - } else if ( - response.data.employees_aggregate.nodes.length === 1 && - response.data.employees_aggregate.nodes[0].id === form.getFieldValue("id") - ) { - return Promise.resolve(); + +
+ + + - - - - - - - - - - - - - - - - - - - - ({ - async validator(rule, value) { - const user_email = getFieldValue("user_email"); - - if (user_email && value) { - const response = await client.query({ - query: QUERY_USERS_BY_EMAIL, - variables: { - email: user_email - } - }); - - if (response.data.users.length === 1) { - return Promise.resolve(); - } - return Promise.reject(t("bodyshop.validation.useremailmustexist")); - } else { - return Promise.resolve(); - } - } - }) - ]} - > - - - - - - - - {(fields, { add, remove, move }) => { - return ( -
- {fields.map((field, index) => { - const employeeRate = employeeRates[field.name] || {}; - - return ( - - -
- ); - }} -
+ + + + + + + + ({ + async validator(rule, value) { + if (value) { + const response = await client.query({ + query: CHECK_EMPLOYEE_NUMBER, + variables: { + employeenumber: value + } + }); + + if (response.data.employees_aggregate.aggregate.count === 0) { + return Promise.resolve(); + } else if ( + response.data.employees_aggregate.nodes.length === 1 && + response.data.employees_aggregate.nodes[0].id === form.getFieldValue("id") + ) { + return Promise.resolve(); + } + return Promise.reject(t("employees.validation.unique_employee_number")); + } else { + return Promise.resolve(); + } + } + }) + ]} + > + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + ({ + async validator(rule, value) { + const user_email = getFieldValue("user_email"); + + if (user_email && value) { + const response = await client.query({ + query: QUERY_USERS_BY_EMAIL, + variables: { + email: user_email + } + }); + + if (response.data.users.length === 1) { + return Promise.resolve(); + } + return Promise.reject(t("bodyshop.validation.useremailmustexist")); + } else { + return Promise.resolve(); + } + } + }) + ]} + > + + + + + + + + + +
+
+ + + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => { + const employeeRate = employeeRates[field.name] || {}; + + return ( + + +