mirror of
https://github.com/pawelmalak/snippet-box.git
synced 2025-12-21 13:23:05 +01:00
Updating snippets with tags
This commit is contained in:
@@ -54,6 +54,10 @@ export const SnippetForm = (props: Props): JSX.Element => {
|
||||
});
|
||||
};
|
||||
|
||||
const tagsToString = (): string => {
|
||||
return formData.tags.join(',');
|
||||
};
|
||||
|
||||
const formHandler = (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -134,13 +138,13 @@ export const SnippetForm = (props: Props): JSX.Element => {
|
||||
className='form-control'
|
||||
id='tags'
|
||||
name='tags'
|
||||
// value={formData.tags}
|
||||
value={tagsToString()}
|
||||
placeholder='automation, files, loop'
|
||||
onChange={e => stringToTags(e)}
|
||||
/>
|
||||
<div className='form-text'>
|
||||
Tags should be separate with a comma. Language tag will be added
|
||||
automatically
|
||||
Tags should be separated with a comma. Language tag will be
|
||||
added automatically
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
@@ -53,13 +53,13 @@ export const SnippetsContextProvider = (props: Props): JSX.Element => {
|
||||
};
|
||||
|
||||
const setSnippet = (id: number): void => {
|
||||
getSnippetById(id);
|
||||
|
||||
if (id < 0) {
|
||||
setCurrentSnippet(null);
|
||||
return;
|
||||
}
|
||||
|
||||
getSnippetById(id);
|
||||
|
||||
const snippet = snippets.find(s => s.id === id);
|
||||
|
||||
if (snippet) {
|
||||
|
||||
Reference in New Issue
Block a user