Added formrow components and for fields changed components + reformatted couple of job detail screens. BOD-160 BOD-155

This commit is contained in:
Patrick Fic
2020-06-11 10:17:53 -07:00
parent cec3fec481
commit 886c7e9cb9
20 changed files with 405 additions and 174 deletions

View File

@@ -0,0 +1,50 @@
import React from "react";
import { Form } from "antd";
import { useTranslation } from "react-i18next";
import AlertComponent from "../alert/alert.component";
import { Prompt, useLocation } from "react-router-dom";
export default function FormsFieldChanged({ form }) {
const { t } = useTranslation();
const handleReset = () => {
form.resetFields();
};
const loc = useLocation();
return (
<Form.Item shouldUpdate style={{ margin: 0, padding: 0 }}>
{() => {
if (form.isFieldsTouched())
return (
<div>
<Prompt
when={true}
message={(location) => {
console.log("location", location);
if (loc.pathname === location.pathname) return false;
return t("general.messages.unsavedchangespopup");
}}
/>
<AlertComponent
type='warning'
message={
<div>
<span>{t("general.messages.unsavedchanges")}</span>
<span
onClick={handleReset}
style={{
cursor: "pointer",
textDecoration: "underline",
}}>
{t("general.actions.reset")}
</span>
</div>
}
/>
</div>
);
return null;
}}
</Form.Item>
);
}