CLEANUP Refactored note upsert to use redux modals.
This commit is contained in:
@@ -1,25 +1,32 @@
|
||||
import React, { useState } from "react";
|
||||
import { Table, Button, notification } from "antd";
|
||||
import {
|
||||
WarningFilled,
|
||||
EyeInvisibleFilled,
|
||||
DeleteFilled,
|
||||
EditFilled
|
||||
EditFilled,
|
||||
EyeInvisibleFilled,
|
||||
WarningFilled
|
||||
} from "@ant-design/icons";
|
||||
import { Button, notification, Table } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Moment from "react-moment";
|
||||
import { connect } from "react-redux";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import NoteUpsertModal from "../note-upsert-modal/note-upsert-modal.container";
|
||||
|
||||
export default function JobNotesComponent({
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setNoteUpsertContext: context =>
|
||||
dispatch(setModalContext({ context: context, modal: "noteUpsert" }))
|
||||
});
|
||||
|
||||
export function JobNotesComponent({
|
||||
loading,
|
||||
data,
|
||||
refetch,
|
||||
deleteNote,
|
||||
jobId
|
||||
jobId,
|
||||
setNoteUpsertContext
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [noteModalVisible, setNoteModalVisible] = useState(false);
|
||||
const [existingNote, setExistingNote] = useState(null);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: "",
|
||||
@@ -28,7 +35,6 @@ export default function JobNotesComponent({
|
||||
width: 80,
|
||||
render: (text, record) => (
|
||||
<span>
|
||||
{" "}
|
||||
{record.critical ? (
|
||||
<WarningFilled style={{ margin: 4, color: "red" }} />
|
||||
) : null}
|
||||
@@ -87,8 +93,13 @@ export default function JobNotesComponent({
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setExistingNote(record);
|
||||
setNoteModalVisible(true);
|
||||
setNoteUpsertContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
jobId: jobId,
|
||||
existingNote: record
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
<EditFilled />
|
||||
@@ -100,17 +111,15 @@ export default function JobNotesComponent({
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NoteUpsertModal
|
||||
jobId={jobId}
|
||||
visible={noteModalVisible}
|
||||
changeVisibility={setNoteModalVisible}
|
||||
refetch={refetch}
|
||||
existingNote={existingNote}
|
||||
/>
|
||||
<NoteUpsertModal />
|
||||
<Button
|
||||
onClick={() => {
|
||||
setExistingNote(null);
|
||||
setNoteModalVisible(true);
|
||||
setNoteUpsertContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
jobId: jobId
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("notes.actions.new")}
|
||||
@@ -125,3 +134,4 @@ export default function JobNotesComponent({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(null, mapDispatchToProps)(JobNotesComponent);
|
||||
|
||||
Reference in New Issue
Block a user