Skip to content

Commit acd4284

Browse files
authored
fix: prevent to execute a chat task if a task is ongoing (#57)
* fix: prevent to execute a chat task if a task is ongoing * fix: handle enter keydown
1 parent 4cb9ccf commit acd4284

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

zendesk_app/src/app/components/RightPanelApp/RightPanelApp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const RightPanelApp = (): JSX.Element => {
130130
setValue={setIterationRequest}
131131
onSubmit={() => void handleSubmitTask('iterate')} // Utilise la nouvelle fonction
132132
hasDraftResponse={!!response}
133+
ongoingTask={ongoingTask}
133134
></IterationTextbox>
134135
</div>
135136
)}

zendesk_app/src/app/components/RightPanelApp/components/IterationTextbox/IterationTextbox.module.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@
3737
}
3838
}
3939

40-
.icon {
40+
.submit_button {
4141
cursor: pointer;
4242
display: flex;
43+
background-color: transparent;
44+
border: none;
45+
outline: none;
46+
47+
&:disabled {
48+
cursor: default;
49+
}
4350
}
4451
}
4552
}

zendesk_app/src/app/components/RightPanelApp/components/IterationTextbox/IterationTextbox.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ interface IterationTextboxProps {
88
hasDraftResponse: boolean
99
setValue: (value: string) => void
1010
onSubmit: () => void
11+
ongoingTask: boolean
1112
}
1213

1314
export const IterationTextbox = ({
1415
value,
1516
setValue,
1617
onSubmit,
17-
hasDraftResponse
18+
hasDraftResponse,
19+
ongoingTask
1820
}: IterationTextboxProps): JSX.Element => {
1921
const textareaRef = useRef<HTMLTextAreaElement>(null)
2022

2123
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
2224
if (e.key === 'Enter' && !e.shiftKey) {
2325
e.preventDefault()
24-
onSubmit()
25-
setValue('')
26+
27+
if (!ongoingTask) {
28+
onSubmit()
29+
setValue('')
30+
}
2631
}
2732
}
2833

@@ -53,9 +58,9 @@ export const IterationTextbox = ({
5358
onKeyDown={handleKeyDown}
5459
rows={1}
5560
/>
56-
<div className={styles.icon} onClick={onSubmit}>
57-
<Icon name="send" size="normal" color="accent" disabled={!value} />
58-
</div>
61+
<button className={styles.submit_button} onClick={onSubmit} disabled={ongoingTask || !value}>
62+
<Icon name="send" size="normal" color="accent" disabled={ongoingTask || !value} />
63+
</button>
5964
</div>
6065
</div>
6166
)

0 commit comments

Comments
 (0)