diff --git a/src/views/biz/board/Board.jsx b/src/views/biz/board/Board.jsx index 9e6e4cc..4ee0979 100644 --- a/src/views/biz/board/Board.jsx +++ b/src/views/biz/board/Board.jsx @@ -21,7 +21,6 @@ import NewBoardForm from './NewBoardForm'; const Board = () => { const { user } = useAuth(); - console.log(user); const [owner, setOwner] = useState(false); const [category, setCategory] = useState('ciTitle'); const [searchTxt, setSearchTxt] = useState(''); diff --git a/src/views/biz/board/ModifyBoardForm.jsx b/src/views/biz/board/ModifyBoardForm.jsx index 68db30b..eb389ac 100644 --- a/src/views/biz/board/ModifyBoardForm.jsx +++ b/src/views/biz/board/ModifyBoardForm.jsx @@ -48,9 +48,12 @@ const ModifyBoardForm = (props) => { () => ({ toolbar: { container: [ + [{ header: [1, 2, false] }], ['bold', 'italic', 'underline', 'strike', 'blockquote'], - [{ size: ['small', false, 'large', 'huge'] }, { color: [] }], - [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }, { align: [] }] + [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }], + ['link'], + [{ align: [] }, { color: [] }, { background: [] }], // dropdown with defaults from theme + ['clean'] // ['image', 'video'] ] } @@ -58,6 +61,26 @@ const ModifyBoardForm = (props) => { [] ); + const formats = useMemo( + () => [ + // 'font', + 'header', + 'bold', + 'italic', + 'underline', + 'strike', + 'blockquote', + 'list', + 'bullet', + 'indent', + 'link', + 'align', + 'color', + 'background' + ], + [] + ); + return ( <> @@ -100,6 +123,7 @@ const ModifyBoardForm = (props) => { value={contents} onChange={setContents} modules={modules} + formats={formats} theme="snow" placeholder="내용을 입력해주세요." /> diff --git a/src/views/biz/board/PublicBoard.jsx b/src/views/biz/board/PublicBoard.jsx index 4f65263..9555de9 100644 --- a/src/views/biz/board/PublicBoard.jsx +++ b/src/views/biz/board/PublicBoard.jsx @@ -16,7 +16,11 @@ import PublicBoardForm from './PublicBoardForm'; import { removePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public'; import { useAlert } from 'react-alert'; +import useAuth from 'hooks/useAuth'; + const PublicBoard = () => { + const { user } = useAuth(); + const [owner, setOwner] = useState(); const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, @@ -89,6 +93,9 @@ const PublicBoard = () => { setCreate(false); setTitle('공지사항 변경'); setSelectedRow(e?.row); + console.log(user.name === e?.row.inName); + console.log(user.name, e?.row.inName); + setOwner(user.name === e?.row.inName); modifyPublicBoardHitCount(e?.row?.inCode); setOpen(true); } @@ -144,7 +151,7 @@ const PublicBoard = () => { handleCellClick={handleOnCellClick} /> - + ); diff --git a/src/views/biz/board/PublicBoardForm.jsx b/src/views/biz/board/PublicBoardForm.jsx index a05f00c..40d2a90 100644 --- a/src/views/biz/board/PublicBoardForm.jsx +++ b/src/views/biz/board/PublicBoardForm.jsx @@ -4,9 +4,6 @@ import { useAlert } from 'react-alert'; // material-ui import { Button, Divider, FormControl, Grid, MenuItem, Select, TextField } from '@mui/material'; -// assets - -// berry ui import ReactQuill from 'react-quill'; import 'react-quill/dist/quill.snow.css'; @@ -16,17 +13,18 @@ import InputLabel from 'ui-component/extended/Form/InputLabel'; import { Delete, List, Save } from '@mui/icons-material'; import { fileDownload } from 'apis/common'; import FileForm from 'views/cmm/file-ctl/FileForm'; +import PropTypes from 'prop-types'; const PublicBoardForm = (props) => { // eslint-disable-next-line react/prop-types - const { create, inCode, inDept, inTitle, inHit, inName, inNalja, inFilename, inContents, setOpen, handleModalSave } = props; + const { create, setOpen, handleModalSave, rowData = {}, owner = false } = props; const alert = useAlert(); const quillRef = useRef(); - const [dept, setDept] = useState(create ? '주정차위반' : inDept); - const [subject, setSubject] = useState(create ? '' : inTitle); - const [contents, setContents] = useState(create ? '' : inContents); + const [dept, setDept] = useState(create ? '주정차위반' : rowData.inDept); + const [subject, setSubject] = useState(create ? '' : rowData.inTitle); + const [contents, setContents] = useState(create ? '' : rowData.inContents); const [filesInfo, setFilesInfo] = useState(); - const [selectedFile, setSelectedFile] = useState(create ? '' : inFilename); // 파일 + const [selectedFile, setSelectedFile] = useState(create ? '' : rowData.inFilename); // 파일 // const [fileData, setFileData] = useState(); const onList = () => { @@ -35,7 +33,7 @@ const PublicBoardForm = (props) => { const onSave = () => { // TODO : validation check 추가 const formData = new FormData(); - formData.append('inCode', inCode ?? ''); + formData.append('inCode', rowData.inCode ?? ''); formData.append('inTitle', subject); formData.append('inDept', dept); formData.append('inContents', contents); @@ -49,70 +47,46 @@ const PublicBoardForm = (props) => { }; const onRemove = () => { - handleModalSave('DELETE', inCode); - }; - - const imageHandler = () => { - const input = document.createElement('input'); - input.setAttribute('type', 'file'); - input.setAttribute('accept', 'image/*'); - input.click(); - - input.onchange = async () => { - if (input.files) { - const file = input.files[0]; - const formData = new FormData(); - formData.append('image', file); - - console.log(formData); - - // 파일이 input 태그에 담기면 실행 될 함수 - input.onchange = async () => { - const file = input.files; - if (file !== null) { - formData.append('image', file[0]); - - try { - // 서저 저장 - // const res = await axios.get('/'); - // - const url = '/Users/minuk/Pictures/test.png'; - - // 이미지 태그 생성 - const range = quillRef.current?.getEditor().getSelection()?.index; - if (range !== null && range !== undefined) { - const quill = quillRef.current?.getEditor(); - - quill?.setSelection(range, 1); - - quill?.clipboard.dangerouslyPasteHTML(range, `이미지 태그가 삽입됩니다.`); - } - } catch (error) { - console.log(error); - } - } - }; - } - }; + handleModalSave('DELETE', rowData.inCode); }; const modules = useMemo( () => ({ toolbar: { container: [ + [{ header: [1, 2, false] }], ['bold', 'italic', 'underline', 'strike', 'blockquote'], - [{ size: ['small', false, 'large', 'huge'] }, { color: [] }], - [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }, { align: [] }] + [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }], + ['link'], + [{ align: [] }, { color: [] }, { background: [] }], // dropdown with defaults from theme + ['clean'] // ['image', 'video'] - ], - handlers: { - image: imageHandler - } + ] } }), [] ); + const formats = useMemo( + () => [ + // 'font', + 'header', + 'bold', + 'italic', + 'underline', + 'strike', + 'blockquote', + 'list', + 'bullet', + 'indent', + 'link', + 'align', + 'color', + 'background' + ], + [] + ); + const onChangeFile = (file) => { setSelectedFile(file.name); setFilesInfo([file]); @@ -124,11 +98,11 @@ const PublicBoardForm = (props) => { // }; const handleFileDownload = () => { - if (!inFilename) { + if (!rowData.inFilename) { alert.show('등록된 파일이 없습니다.'); return; } - fileDownload(inCode, inFilename, alert).then(() => {}); + fileDownload(rowData.inCode, rowData.inFilename, alert).then(() => {}); }; return ( @@ -136,11 +110,19 @@ const PublicBoardForm = (props) => { - setSubject(e.target.value)} fullWidth /> + setSubject(e.target.value)} + fullWidth + /> - 진술유형 + 업무구분 @@ -47,6 +47,7 @@ FileForm.propTypes = { isDownload: PropTypes.bool.isRequired, labelName: PropTypes.number.isRequired, selectedFile: PropTypes.string, + isDisabled: PropTypes.bool.isRequired, handleChangeFile: PropTypes.func.isRequired, handleFileDownload: PropTypes.func.isRequired, alert: PropTypes.object.isRequired