Added notes presets BOD-227
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import NotesPresetButton from "../notes-preset-button/notes-preset-button.component";
|
||||
|
||||
export default function NoteUpsertModalComponent() {
|
||||
export default function NoteUpsertModalComponent({ form }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
@@ -27,8 +28,8 @@ export default function NoteUpsertModalComponent() {
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.TextArea
|
||||
@@ -36,6 +37,7 @@ export default function NoteUpsertModalComponent() {
|
||||
placeholder={t("notes.labels.newnoteplaceholder")}
|
||||
/>
|
||||
</Form.Item>
|
||||
<NotesPresetButton form={form} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export function NoteUpsertModalContainer({
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} onFinish={handleFinish} initialValues={existingNote}>
|
||||
<NoteUpsertModalComponent />
|
||||
<NoteUpsertModalComponent form={form} />
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { DownOutlined } from "@ant-design/icons";
|
||||
import { Dropdown, Menu } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setMessage } from "../../redux/messaging/messaging.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function NotesPresetButton({ bodyshop, form }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSelect = (item) => {
|
||||
form.setFieldsValue({ text: item.text });
|
||||
};
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
{bodyshop.md_notes_presets.map((i, idx) => (
|
||||
<Menu.Item onClick={() => handleSelect(i)} onItemHover key={idx}>
|
||||
{i.label}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Dropdown trigger={["click"]} overlay={menu}>
|
||||
<a
|
||||
className="ant-dropdown-link"
|
||||
href="# "
|
||||
onClick={(e) => e.preventDefault()}
|
||||
>
|
||||
{t("messaging.labels.presets")} <DownOutlined />
|
||||
</a>
|
||||
</Dropdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(NotesPresetButton);
|
||||
@@ -275,6 +275,68 @@ export default function ShopInfoComponent({ form, saveLoading }) {
|
||||
}}
|
||||
</Form.List>
|
||||
|
||||
<Form.List name={["md_notes_presets"]}>
|
||||
{(fields, { add, remove }) => {
|
||||
return (
|
||||
<div>
|
||||
{fields.map((field, index) => (
|
||||
<Form.Item
|
||||
key={field.key}
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t("bodyshop.fields.noteslabel")}
|
||||
key={`${index}label`}
|
||||
name={[field.name, "label"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t("bodyshop.fields.notestext")}
|
||||
key={`${index}text`}
|
||||
name={[field.name, "text"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<DeleteFilled
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
))}
|
||||
<Form.Item>
|
||||
<Button
|
||||
type="dashed"
|
||||
onClick={() => {
|
||||
add();
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
>
|
||||
{t("general.actions.add")}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</Form.List>
|
||||
|
||||
<Form.List name={["md_parts_locations"]}>
|
||||
{(fields, { add, remove, move }) => {
|
||||
return (
|
||||
|
||||
@@ -49,6 +49,7 @@ export const QUERY_BODYSHOP = gql`
|
||||
intakechecklist
|
||||
speedprint
|
||||
md_parts_locations
|
||||
md_notes_presets
|
||||
employees {
|
||||
id
|
||||
first_name
|
||||
@@ -106,6 +107,7 @@ export const UPDATE_SHOP = gql`
|
||||
intakechecklist
|
||||
speedprint
|
||||
md_parts_locations
|
||||
md_notes_presets
|
||||
employees {
|
||||
id
|
||||
first_name
|
||||
|
||||
@@ -101,6 +101,8 @@
|
||||
"md_referral_sources": "Referral Sources",
|
||||
"messaginglabel": "Messaging Preset Label",
|
||||
"messagingtext": "Messaging Preset Text",
|
||||
"noteslabel": "Note Label",
|
||||
"notestext": "Note Text",
|
||||
"partslocation": "Parts Location",
|
||||
"responsibilitycenter": "Responsibility Center",
|
||||
"responsibilitycenter_accountdesc": "Account Description",
|
||||
|
||||
@@ -101,6 +101,8 @@
|
||||
"md_referral_sources": "",
|
||||
"messaginglabel": "",
|
||||
"messagingtext": "",
|
||||
"noteslabel": "",
|
||||
"notestext": "",
|
||||
"partslocation": "",
|
||||
"responsibilitycenter": "",
|
||||
"responsibilitycenter_accountdesc": "",
|
||||
|
||||
@@ -101,6 +101,8 @@
|
||||
"md_referral_sources": "",
|
||||
"messaginglabel": "",
|
||||
"messagingtext": "",
|
||||
"noteslabel": "",
|
||||
"notestext": "",
|
||||
"partslocation": "",
|
||||
"responsibilitycenter": "",
|
||||
"responsibilitycenter_accountdesc": "",
|
||||
|
||||
Reference in New Issue
Block a user