import { AuditOutlined, DeleteFilled, EditFilled, EyeInvisibleFilled, WarningFilled, } from "@ant-design/icons"; import { Button, Card, Form, Input, Space, Table } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; import { DateTimeFormatter } from "../../utils/DateFormatter"; import { TemplateList } from "../../utils/TemplateConstants"; import useLocalStorage from "../../utils/useLocalStorage"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import NoteUpsertModal from "../note-upsert-modal/note-upsert-modal.container"; import PrintWrapperComponent from "../print-wrapper/print-wrapper.component"; const mapStateToProps = createStructuredSelector({ jobRO: selectJobReadOnly, }); const mapDispatchToProps = (dispatch) => ({ setNoteUpsertContext: (context) => dispatch(setModalContext({ context: context, modal: "noteUpsert" })), }); export function JobNotesComponent({ jobRO, loading, data, refetch, handleNoteDelete, jobId, setNoteUpsertContext, deleteLoading, ro_number, relatedRos, }) { const { t } = useTranslation(); const [filter, setFilter] = useLocalStorage("filter_job_notes_icons", null); const Templates = TemplateList("job_special", { ro_number, }); const columns = [ { title: "", dataIndex: "icons", key: "icons", width: 80, filteredValue: filter?.icons || null, filters: [ { text: t("notes.labels.usernotes"), value: false, }, { text: t("notes.labels.systemnotes"), value: true, }, ], onFilter: (value, record) => record.audit === value, render: (text, record) => ( {record.critical ? ( ) : null} {record.private ? : null} {record.audit ? : null} ), }, { title: t("notes.fields.type"), dataIndex: "type", key: "type", width: 120, filteredValue: filter?.type || null, filters: [ { value: "general", text: t("notes.fields.types.general") }, { value: "customer", text: t("notes.fields.types.customer") }, { value: "shop", text: t("notes.fields.types.shop") }, { value: "office", text: t("notes.fields.types.office") }, { value: "parts", text: t("notes.fields.types.parts") }, { value: "paint", text: t("notes.fields.types.paint") }, { value: "supplement", text: t("notes.fields.types.supplement"), }, ], onFilter: (value, record) => value.includes(record.type), render: (text, record) => t(`notes.fields.types.${record.type}`), }, { title: t("notes.fields.text"), dataIndex: "text", key: "text", ellipsis: true, render: (text, record) => ( {text} ), }, { title: t("notes.fields.updatedat"), dataIndex: "updated_at", key: "updated_at", defaultSortOrder: "descend", width: 200, sorter: (a, b) => new Date(a.updated_at) - new Date(b.updated_at), render: (text, record) => ( {record.updated_at} ), }, { title: t("notes.fields.createdby"), dataIndex: "created_by", key: "created_by", width: 200, }, { title: t("notes.actions.actions"), dataIndex: "actions", key: "actions", width: 200, render: (text, record) => ( ), }, ]; const handleTableChange = (pagination, filters, sorter) => { setFilter(filters); }; return (
{ setNoteUpsertContext({ actions: { refetch: refetch }, context: { jobId: jobId, relatedRos: relatedRos, }, }); }} > {t("notes.actions.new")} } > ); } export default connect(mapStateToProps, mapDispatchToProps)(JobNotesComponent);