diff --git a/src/components/common/Editor/Editor.component.tsx b/src/components/common/Editor/Editor.component.tsx index 44abe8de..b5bce129 100644 --- a/src/components/common/Editor/Editor.component.tsx +++ b/src/components/common/Editor/Editor.component.tsx @@ -15,6 +15,7 @@ const Editor = ({ id, savedData }: EditorProps) => { const editorRef = useRef(); const [editorData, setEditorData] = useState(savedData); const [editorReady, setEditorReady] = useState(false); + const [isDataChanged, setIsDataChanged] = useState(false); const initEditor = () => { const editor = new EditorJS({ @@ -27,9 +28,10 @@ const Editor = ({ id, savedData }: EditorProps) => { setEditorReady(true); }, onChange: async () => { - const content = (await editorRef.current?.saver.save()) as OutputData; - localStorage.setItem(id, JSON.stringify(content)); - setEditorData(content); + const newEditorData = (await editorRef.current?.saver.save()) as OutputData; + localStorage.setItem(id, JSON.stringify(newEditorData)); + setEditorData(newEditorData); + if (editorData.time !== newEditorData.time) setIsDataChanged(true); }, autofocus: true, // @ts-expect-error: third party plugin @@ -73,7 +75,7 @@ const Editor = ({ id, savedData }: EditorProps) => { return ( <>
; - + ); }; diff --git a/src/pages/UpdatePlatformRecruit/UpdatePlatformRecruit.page.tsx b/src/pages/UpdatePlatformRecruit/UpdatePlatformRecruit.page.tsx index a221f1da..fd040f97 100644 --- a/src/pages/UpdatePlatformRecruit/UpdatePlatformRecruit.page.tsx +++ b/src/pages/UpdatePlatformRecruit/UpdatePlatformRecruit.page.tsx @@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil'; import { OutputData } from '@editorjs/editorjs'; import { Editor, EditorAside } from '@/components'; import * as Styled from './UpdatePlatformRecruit.styled'; -import { $teams } from '@/store'; +import { $teams, $profile } from '@/store'; import { SelectSize } from '@/components/common/Select/Select.component'; import { decodeHTMLEntities, getDefaultEditorData, removeWrongAmpString, request } from '@/utils'; import { useToast } from '@/hooks'; @@ -11,6 +11,7 @@ import { ToastType } from '@/components/common/Toast/Toast.component'; import * as api from '@/api'; const EDITOR_ID = 'platform-recruit-editor'; +const STAFF_PROFILES = ['BRANDING', 'MASHUP']; const UpdatePlatformRecruit = () => { const [isLoading, setIsLoading] = useState(false); @@ -25,6 +26,14 @@ const UpdatePlatformRecruit = () => { label: name, })); + const myTeamName = useRecoilValue($profile)[0]; + const getTeamSelectOptions = () => { + if (STAFF_PROFILES.includes(myTeamName)) return teamOptions; + const myTeamOptionObject = teamOptions.find(({ label }) => label.toUpperCase() === myTeamName); + return [myTeamOptionObject ?? { label: '', value: '' }]; + }; + const teamSelectOptions = getTeamSelectOptions(); + const handleUpdateButtonClick = async () => { const originalOutputData = JSON.parse(localStorage.getItem(EDITOR_ID) ?? '{}'); const storageValue = { editorData: originalOutputData }; @@ -89,9 +98,9 @@ const UpdatePlatformRecruit = () => { platform={ setSelectedPlatform(option.label.toLowerCase())} /> }