();
const { notesStore } = useStore();
React.useEffect(() => {
@@ -50,14 +57,12 @@ function CreateNote({
React.useEffect(() => {
if (inputRef.current) {
- inputRef.current.focus()
+ fetchSlack();
+ inputRef.current.focus();
}
- }, [isVisible])
+ }, [isVisible]);
const duration = Duration.fromMillis(time).toFormat('mm:ss');
- const stopEvents = (e: any) => {
- e.stopPropagation();
- };
const onSubmit = () => {
if (text === '') return;
@@ -68,29 +73,37 @@ function CreateNote({
timestamp: useTimestamp ? (isEdit ? editNote.timestamp : time) : -1,
isPublic,
};
-
+ const onSuccess = (noteId: string) => {
+ if (channel) {
+ notesStore.sendSlackNotification(noteId, channel)
+ }
+ }
if (isEdit) {
- return notesStore.updateNote(editNote.noteId, note).then((r) => {
- toast.success('Note updated');
- notesStore.fetchSessionNotes(sessionId).then((notes) => {
- injectNotes(notes);
- updateNote(r);
+ return notesStore
+ .updateNote(editNote.noteId, note)
+ .then((r) => {
+ toast.success('Note updated');
+ notesStore.fetchSessionNotes(sessionId).then((notes) => {
+ injectNotes(notes);
+ onSuccess(editNote.noteId)
+ updateNote(r);
+ });
+ })
+ .catch((e) => {
+ toast.error('Error updating note');
+ console.error(e);
+ })
+ .finally(() => {
+ setCreateNoteTooltip({ isVisible: false, time: 0 });
+ setText('');
+ setTag(undefined);
});
- })
- .catch((e) => {
- toast.error('Error updating note');
- console.error(e);
- })
- .finally(() => {
- setCreateNoteTooltip({ isVisible: false, time: 0 });
- setText('');
- setTag(undefined);
- });
}
return notesStore
.addNote(sessionId, note)
.then((r) => {
+ onSuccess(r.noteId as unknown as string)
toast.success('Note added');
notesStore.fetchSessionNotes(sessionId).then((notes) => {
injectNotes(notes);
@@ -109,7 +122,7 @@ function CreateNote({
};
const closeTooltip = () => {
- setCreateNoteTooltip({ isVisible: false, time: 0 });
+ setCreateNoteTooltip({ isVisible: false, time: 100 });
};
const tagActive = (noteTag: iTag) => tag === noteTag;
@@ -118,17 +131,27 @@ function CreateNote({
setTag(tag);
};
+ const slackChannelsOptions = slackChannels.map(({ webhookId, name }) => ({
+ value: webhookId,
+ label: name,
+ }));
+
+ const changeChannel = ({ value, name }: { value: string; name: string }) => {
+ setChannel(value);
+ };
+
return (
e.stopPropagation()}
>
@@ -176,13 +199,23 @@ function CreateNote({
onClick={() => addTag(tag)}
>
{tagActive(tag) ?
: null}
-
- {tag}
-
+
{tag}
))}
+ {slackChannelsOptions.length > 0 ? (
+
+
+
+ ) : null}
+