Skip to content

Commit a9e2097

Browse files
committed
conciliate code
1 parent a2a60a0 commit a9e2097

File tree

3 files changed

+156
-173
lines changed

3 files changed

+156
-173
lines changed
Lines changed: 122 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import {
2-
Body1Strong,
3-
Button,
4-
Caption1,
5-
Title2,
2+
Body1Strong,
3+
Button,
4+
Caption1,
5+
Title2,
66
} from "@fluentui/react-components";
7-
import { Send20Regular } from "@fluentui/react-icons";
87
import React, { useRef, useEffect, useState } from "react";
98
import { useNavigate, useLocation } from "react-router-dom";
109

@@ -22,133 +21,133 @@ import PromptCard from "@/coral/components/PromptCard";
2221
import { Send } from "@/coral/imports/bundleicons";
2322

2423
const HomeInput: React.FC<HomeInputProps> = ({
25-
onInputSubmit,
26-
onQuickTaskSelect,
24+
onInputSubmit,
25+
onQuickTaskSelect,
2726
}) => {
28-
const [submitting, setSubmitting] = useState(false);
29-
const [input, setInput] = useState("");
30-
31-
const textareaRef = useRef<HTMLTextAreaElement>(null);
32-
const navigate = useNavigate();
33-
const location = useLocation(); // ✅ location.state used to control focus
34-
const { showToast, dismissToast } = useInlineToaster();
35-
36-
useEffect(() => {
37-
if (location.state?.focusInput) {
38-
textareaRef.current?.focus();
39-
}
40-
}, [location]);
41-
42-
const resetTextarea = () => {
43-
setInput("");
44-
if (textareaRef.current) {
45-
textareaRef.current.style.height = "auto";
46-
textareaRef.current.focus();
47-
}
48-
};
49-
50-
useEffect(() => {
51-
const cleanup = NewTaskService.addResetListener(resetTextarea);
52-
return cleanup;
53-
}, []);
54-
55-
const handleSubmit = async () => {
56-
if (input.trim()) {
57-
setSubmitting(true);
58-
let id = showToast("Creating a plan", "progress");
59-
60-
try {
61-
const response = await TaskService.submitInputTask(input.trim());
62-
setInput("");
27+
const [submitting, setSubmitting] = useState(false);
28+
const [input, setInput] = useState("");
29+
30+
const textareaRef = useRef<HTMLTextAreaElement>(null);
31+
const navigate = useNavigate();
32+
const location = useLocation(); // ✅ location.state used to control focus
33+
const { showToast, dismissToast } = useInlineToaster();
34+
35+
useEffect(() => {
36+
if (location.state?.focusInput) {
37+
textareaRef.current?.focus();
38+
}
39+
}, [location]);
6340

41+
const resetTextarea = () => {
42+
setInput("");
6443
if (textareaRef.current) {
65-
textareaRef.current.style.height = "auto";
44+
textareaRef.current.style.height = "auto";
45+
textareaRef.current.focus();
46+
}
47+
};
48+
49+
useEffect(() => {
50+
const cleanup = NewTaskService.addResetListener(resetTextarea);
51+
return cleanup;
52+
}, []);
53+
54+
const handleSubmit = async () => {
55+
if (input.trim()) {
56+
setSubmitting(true);
57+
let id = showToast("Creating a plan", "progress");
58+
59+
try {
60+
const response = await TaskService.submitInputTask(input.trim());
61+
setInput("");
62+
63+
if (textareaRef.current) {
64+
textareaRef.current.style.height = "auto";
65+
}
66+
67+
if (response.plan_id && response.plan_id !== null) {
68+
showToast("Plan created!", "success");
69+
dismissToast(id);
70+
navigate(`/plan/${response.plan_id}`);
71+
} else {
72+
console.log("Invalid plan:", response.status);
73+
showToast("Failed to create plan", "error");
74+
dismissToast(id);
75+
}
76+
} catch (error) {
77+
console.error("Failed to create plan:", error);
78+
dismissToast(id);
79+
showToast("Something went wrong", "error");
80+
} finally {
81+
setInput("");
82+
setSubmitting(false);
83+
}
6684
}
85+
};
6786

68-
if (response.plan_id && response.plan_id !== null) {
69-
showToast("Plan created!", "success");
70-
dismissToast(id);
71-
navigate(`/plan/${response.plan_id}`);
72-
} else {
73-
console.log("Invalid plan:", response.status);
74-
showToast("Failed to create plan", "error");
75-
dismissToast(id);
87+
const handleQuickTaskClick = (task: QuickTask) => {
88+
setInput(task.description);
89+
if (textareaRef.current) {
90+
textareaRef.current.focus();
7691
}
77-
} catch (error) {
78-
console.error("Failed to create plan:", error);
79-
dismissToast(id);
80-
showToast("Something went wrong", "error");
81-
} finally {
82-
setInput("");
83-
setSubmitting(false);
84-
}
85-
}
86-
};
87-
88-
const handleQuickTaskClick = (task: QuickTask) => {
89-
setInput(task.description);
90-
if (textareaRef.current) {
91-
textareaRef.current.focus();
92-
}
93-
onQuickTaskSelect(task.description);
94-
};
95-
96-
useEffect(() => {
97-
if (textareaRef.current) {
98-
textareaRef.current.style.height = "auto";
99-
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
100-
}
101-
}, [input]);
102-
103-
return (
104-
<div className="home-input-container">
105-
<div className="home-input-content">
106-
<div className="home-input-center-content">
107-
<div className="home-input-title-wrapper">
108-
<Title2>How can I help?</Title2>
109-
</div>
110-
111-
<ChatInput
112-
ref={textareaRef} // forwarding
113-
value={input}
114-
placeholder="Tell us what needs planning, building, or connecting—we'll handle the rest."
115-
onChange={setInput}
116-
onEnter={handleSubmit}
117-
disabledChat={submitting}
118-
>
119-
<Button
120-
appearance="subtle"
121-
className="home-input-send-button"
122-
onClick={handleSubmit}
123-
disabled={submitting}
124-
icon={<Send />}
125-
/>
126-
</ChatInput>
127-
128-
<InlineToaster />
129-
130-
<div className="home-input-quick-tasks-section">
131-
<div className="home-input-quick-tasks-header">
132-
<Body1Strong>Quick tasks</Body1Strong>
133-
</div>
92+
onQuickTaskSelect(task.description);
93+
};
13494

135-
<div className="home-input-quick-tasks">
136-
{quickTasks.map((task) => (
137-
<PromptCard
138-
key={task.id}
139-
title={task.title}
140-
icon={task.icon}
141-
description={task.description}
142-
onClick={() => handleQuickTaskClick(task)}
143-
disabled={submitting}
144-
/>
145-
))}
95+
useEffect(() => {
96+
if (textareaRef.current) {
97+
textareaRef.current.style.height = "auto";
98+
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
99+
}
100+
}, [input]);
101+
102+
return (
103+
<div className="home-input-container">
104+
<div className="home-input-content">
105+
<div className="home-input-center-content">
106+
<div className="home-input-title-wrapper">
107+
<Title2>How can I help?</Title2>
108+
</div>
109+
110+
<ChatInput
111+
ref={textareaRef} // forwarding
112+
value={input}
113+
placeholder="Tell us what needs planning, building, or connecting—we'll handle the rest."
114+
onChange={setInput}
115+
onEnter={handleSubmit}
116+
disabledChat={submitting}
117+
>
118+
<Button
119+
appearance="subtle"
120+
className="home-input-send-button"
121+
onClick={handleSubmit}
122+
disabled={submitting}
123+
icon={<Send />}
124+
/>
125+
</ChatInput>
126+
127+
<InlineToaster />
128+
129+
<div className="home-input-quick-tasks-section">
130+
<div className="home-input-quick-tasks-header">
131+
<Body1Strong>Quick tasks</Body1Strong>
132+
</div>
133+
134+
<div className="home-input-quick-tasks">
135+
{quickTasks.map((task) => (
136+
<PromptCard
137+
key={task.id}
138+
title={task.title}
139+
icon={task.icon}
140+
description={task.description}
141+
onClick={() => handleQuickTaskClick(task)}
142+
disabled={submitting}
143+
/>
144+
))}
145+
</div>
146+
</div>
147+
</div>
146148
</div>
147-
</div>
148149
</div>
149-
</div>
150-
</div>
151-
);
150+
);
152151
};
153152

154153
export default HomeInput;

src/frontend_react/src/components/content/TaskDetails.tsx

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,19 @@
22

33
import { HumanFeedbackStatus, Step, TaskDetailsProps } from "@/models";
44
import {
5-
Subtitle1,
65
Text,
7-
Divider,
86
Avatar,
9-
Checkbox,
107
Body1,
118
Body1Strong,
129
Caption1,
1310
Button,
1411
Tooltip,
1512
} from "@fluentui/react-components";
1613
import {
17-
Add20Regular,
18-
CheckmarkCircle20Regular,
1914
Dismiss20Regular,
20-
CircleHalfFill20Regular,
21-
CheckboxChecked20Regular,
22-
DismissSquare20Regular,
23-
Check20Regular,
2415
CheckmarkCircle20Filled,
25-
Circle20Regular,
26-
Dismiss20Filled,
2716
DismissCircle20Filled,
28-
Flash20Regular,
29-
ArrowForwardDownLightningRegular,
3017
Checkmark20Regular,
31-
CircleHint20Regular,
3218
CircleHint20Filled,
3319
} from "@fluentui/react-icons";
3420
import React, { useState } from "react";
@@ -154,11 +140,10 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
154140
</div>
155141
<div className="task-details-subtask-content">
156142
<Body1
157-
className={`task-details-subtask-description ${
158-
step.human_approval_status === "rejected"
159-
? "strikethrough"
160-
: ""
161-
}`}
143+
className={`task-details-subtask-description ${step.human_approval_status === "rejected"
144+
? "strikethrough"
145+
: ""
146+
}`}
162147
>
163148
{description}{" "}
164149
{functionOrDetails && (
@@ -168,22 +153,22 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
168153
<div className="task-details-action-buttons">
169154
{step.human_approval_status !== "accepted" &&
170155
step.human_approval_status !== "rejected" && (
171-
<> <Tooltip relationship="label" content="Approve">
172-
<Button
173-
icon={<Checkmark20Regular />}
174-
appearance="subtle"
175-
onClick={
176-
canInteract
177-
? () => preOnApproved(step)
178-
: undefined
179-
}
180-
className={
181-
canInteract
182-
? "task-details-action-button"
183-
: "task-details-action-button-disabled"
184-
}
185-
/>
186-
</Tooltip>
156+
<> <Tooltip relationship="label" content="Approve">
157+
<Button
158+
icon={<Checkmark20Regular />}
159+
appearance="subtle"
160+
onClick={
161+
canInteract
162+
? () => preOnApproved(step)
163+
: undefined
164+
}
165+
className={
166+
canInteract
167+
? "task-details-action-button"
168+
: "task-details-action-button-disabled"
169+
}
170+
/>
171+
</Tooltip>
187172

188173
<Tooltip relationship="label" content="Reject">
189174
<Button
@@ -201,7 +186,7 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
201186
}
202187
/>
203188
</Tooltip></>
204-
189+
205190
)}
206191
</div>
207192
</div>

0 commit comments

Comments
 (0)