refactor: Use enum instead of string

This commit is contained in:
Aman Harwara
2021-10-01 20:46:00 +05:30
parent c48d9f2230
commit b4b1e42606

View File

@@ -93,7 +93,8 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
const [editorItems, setEditorItems] = useState<DropdownItem[]>([]); const [editorItems, setEditorItems] = useState<DropdownItem[]>([]);
const [defaultEditorValue] = useState( const [defaultEditorValue] = useState(
() => () =>
getDefaultEditor(application)?.package_info?.identifier || 'plain-editor' getDefaultEditor(application)?.package_info?.identifier ||
EditorIdentifier.PlainEditor
); );
useEffect(() => { useEffect(() => {
@@ -117,7 +118,7 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
{ {
icon: 'plain-text', icon: 'plain-text',
label: 'Plain Editor', label: 'Plain Editor',
value: 'plain-editor', value: EditorIdentifier.PlainEditor,
}, },
...editors, ...editors,
]); ]);
@@ -129,7 +130,7 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
); );
const currentDefault = getDefaultEditor(application); const currentDefault = getDefaultEditor(application);
if (value !== 'plain-editor') { if (value !== EditorIdentifier.PlainEditor) {
const editorComponent = editors.filter( const editorComponent = editors.filter(
(e) => e.package_info.identifier === value (e) => e.package_info.identifier === value
)[0]; )[0];