import { Alert, Col, Form, Radio, Row, Skeleton, Space, Spin, Typography } from "antd"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; import ReadOnlyFormItemComponent from "../form-items-formatted/read-only-form-item.component"; import JobSearchSelectComponent from "../job-search-select/job-search-select.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop }); const mapDispatchToProps = () => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect(mapStateToProps, mapDispatchToProps)(TimeTicketTaskModalComponent); const getPayoutMethodLabel = (payoutMethod, t) => { if (!payoutMethod) { return ""; } if (payoutMethod === "hourly" || payoutMethod === "commission") { return t(`timetickets.labels.payout_methods.${payoutMethod}`); } return payoutMethod; }; export function TimeTicketTaskModalComponent({ bodyshop, form, loading, completedTasks, unassignedHours }) { const { t } = useTranslation(); return (
{loading ? ( ) : ( ({ value: preset.name, label: preset.name, disabled: completedTasks.map((task) => task.name).includes(preset.name) }))} /> )} {() => { const { task } = form.getFieldsValue(); const theTaskPreset = bodyshop.md_tasks_presets?.presets?.find((tp) => tp.name === task); if (!task) return null; return (
{t("bodyshop.fields.md_tasks_presets.percent")} {`${theTaskPreset.percent || 0}%`}
{t("bodyshop.fields.md_tasks_presets.hourstype")} {theTaskPreset.hourstype.join(", ")}
{t("bodyshop.fields.md_tasks_presets.nextstatus")} {theTaskPreset.nextstatus}
); }}
{loading ? ( ) : ( {(fields) => { return ( <> {t("timetickets.labels.claimtaskpreview")} {fields.map((field, index) => { const payoutMethod = form.getFieldValue(["timetickets", field.name, "payout_context", "payout_method"]); return ( ); })}
{t("timetickets.fields.employee")} {t("timetickets.fields.cost_center")} {t("timetickets.fields.ciecacode")} {t("timetickets.fields.productivehrs")} {t("timetickets.fields.payout_method")} {t("timetickets.fields.rate")} {t("timetickets.fields.amount")}
{getPayoutMethodLabel(payoutMethod, t)}
); }}
)} {unassignedHours > 0 && ( )}
{bodyshop?.md_tasks_presets?.use_approvals && ( )}
); }