Fixed manual job creation validation errors BOD-252
This commit is contained in:
@@ -6,7 +6,7 @@ import FormItemEmail from "../form-items-formatted/email-form-item.component";
|
||||
import FormItemPhone from "../form-items-formatted/phone-form-item.component";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
|
||||
export default function JobsCreateJobsInfo({ form }) {
|
||||
export default function JobsCreateJobsInfo({ form, selected }) {
|
||||
const { t } = useTranslation();
|
||||
const { getFieldValue } = form;
|
||||
return (
|
||||
@@ -74,7 +74,7 @@ export default function JobsCreateJobsInfo({ form }) {
|
||||
name="est_ct_fn"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
required: selected && true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
@@ -86,7 +86,7 @@ export default function JobsCreateJobsInfo({ form }) {
|
||||
name="est_ct_ln"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
required: selected && true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
|
||||
@@ -12,11 +12,11 @@ export default function JobsCreateOwnerContainer() {
|
||||
skip: !state.owner.search,
|
||||
});
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type='error' />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
return (
|
||||
<JobsCreateOwnerInfoComponent
|
||||
loading={loading}
|
||||
owners={data ? data.search_owner : null}
|
||||
owners={data ? data.search_owners : null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -125,16 +125,11 @@ export default function JobsCreateOwnerInfoNewComponent() {
|
||||
},
|
||||
]}
|
||||
name={["owner", "data", "ownr_ea"]}
|
||||
shouldUpdate
|
||||
>
|
||||
{() => {
|
||||
return (
|
||||
<FormItemEmail
|
||||
//email={form.getFieldValue("ownr_ea")}
|
||||
disabled={!state.owner.new}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
<FormItemEmail
|
||||
//email={form.getFieldValue("ownr_ea")}
|
||||
disabled={!state.owner.new}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("owners.fields.ownr_ph1")}
|
||||
|
||||
@@ -20,27 +20,28 @@ export default function OwnerFindModalContainer({
|
||||
|
||||
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
|
||||
variables: {
|
||||
search: owner ? `${owner.ownr_fn || ""} ${owner.ownr_ln || ""}` : null
|
||||
search: owner ? `${owner.ownr_fn || ""} ${owner.ownr_ln || ""}` : null,
|
||||
},
|
||||
skip: !owner,
|
||||
fetchPolicy: "network-only"
|
||||
fetchPolicy: "network-only",
|
||||
});
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t("owners.labels.existing_owners")}
|
||||
width={"80%"}
|
||||
{...modalProps}>
|
||||
{...modalProps}
|
||||
>
|
||||
{loading ? <LoadingSpinner /> : null}
|
||||
{error ? <AlertComponent message={error.message} type='error' /> : null}
|
||||
{error ? <AlertComponent message={error.message} type="error" /> : null}
|
||||
{owner ? (
|
||||
<OwnerFindModalComponent
|
||||
selectedOwner={selectedOwner}
|
||||
setSelectedOwner={setSelectedOwner}
|
||||
ownersListLoading={ownersList.loading}
|
||||
ownersList={
|
||||
ownersList.data && ownersList.data.search_owner
|
||||
? ownersList.data.search_owner
|
||||
ownersList.data && ownersList.data.search_owners
|
||||
? ownersList.data.search_owners
|
||||
: null
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import PropTypes from "prop-types";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -46,12 +45,12 @@ function RbacWrapper({
|
||||
);
|
||||
}
|
||||
|
||||
RbacWrapper.propTypes = {
|
||||
currentUser: PropTypes.object.isRequired,
|
||||
authLevel: PropTypes.number.isRequired,
|
||||
noauth: PropTypes.oneOfType(PropTypes.string, PropTypes.func),
|
||||
requiredAuthLevel: PropTypes.number,
|
||||
action: PropTypes.string,
|
||||
};
|
||||
// RbacWrapper.propTypes = {
|
||||
// currentUser: PropTypes.object.isRequired,
|
||||
// authLevel: PropTypes.number.isRequired,
|
||||
// noauth: PropTypes.oneOfType(PropTypes.string, PropTypes.func),
|
||||
// requiredAuthLevel: PropTypes.number,
|
||||
// action: PropTypes.string,
|
||||
// };
|
||||
|
||||
export default connect(mapStateToProps, null)(RbacWrapper);
|
||||
|
||||
@@ -2,7 +2,7 @@ import gql from "graphql-tag";
|
||||
|
||||
export const QUERY_SEARCH_OWNER_BY_IDX = gql`
|
||||
query QUERY_SEARCH_OWNER_BY_IDX($search: String!) {
|
||||
search_owner(args: { search: $search }) {
|
||||
search_owners(args: { search: $search }) {
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_ph1
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function JobsCreateComponent({ form }) {
|
||||
},
|
||||
{
|
||||
title: t("jobs.labels.create.jobinfo"),
|
||||
content: <JobsCreateJobsInfo form={form} />,
|
||||
content: <JobsCreateJobsInfo form={form} selected={pageIndex === 2} />,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -47,7 +47,7 @@ export default function JobsCreateComponent({ form }) {
|
||||
{pageIndex > 0 && <Button onClick={() => prev()}>Previous</Button>}
|
||||
{pageIndex < steps.length - 1 && (
|
||||
<Button
|
||||
type='primary'
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
form
|
||||
.validateFields()
|
||||
@@ -60,12 +60,13 @@ export default function JobsCreateComponent({ form }) {
|
||||
}
|
||||
})
|
||||
.catch((error) => console.log("error", error));
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
Next
|
||||
</Button>
|
||||
)}
|
||||
{pageIndex === steps.length - 1 && (
|
||||
<Button type='primary' htmlType='submit'>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Done
|
||||
</Button>
|
||||
)}
|
||||
@@ -78,16 +79,16 @@ export default function JobsCreateComponent({ form }) {
|
||||
{state.created ? (
|
||||
<div>
|
||||
<Result
|
||||
status='success'
|
||||
status="success"
|
||||
title={t("jobs.successes.creatednoclick")}
|
||||
subTitle={t("jobs.successes.created_subtitle", {
|
||||
est_number: state.newJobEstNum,
|
||||
})}
|
||||
extra={[
|
||||
<Link to={`/manage/jobs/${state.newJobId}`} key='gotojob'>
|
||||
<Button type='primary'>{t("jobs.actions.gotojob")}</Button>
|
||||
<Link to={`/manage/jobs/${state.newJobId}`} key="gotojob">
|
||||
<Button type="primary">{t("jobs.actions.gotojob")}</Button>
|
||||
</Link>,
|
||||
<Link to={`/manage/jobs/`} key='gotojoblist'>
|
||||
<Link to={`/manage/jobs/`} key="gotojoblist">
|
||||
<Button>{t("menus.header.activejobs")}</Button>
|
||||
</Link>,
|
||||
]}
|
||||
@@ -121,7 +122,7 @@ export default function JobsCreateComponent({ form }) {
|
||||
|
||||
{errorMessage ? (
|
||||
<div>
|
||||
<AlertComponent message={errorMessage} type='error' />
|
||||
<AlertComponent message={errorMessage} type="error" />
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -131,7 +132,8 @@ export default function JobsCreateComponent({ form }) {
|
||||
style={{
|
||||
display: idx === pageIndex ? "" : "none",
|
||||
margin: "1rem",
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
{item.content}
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user