Skip to content

Commit fd97570

Browse files
committed
Fixed issue #91- Enhance Section Selection with Dropdown for First, Last, and Custom Options
1 parent 332e995 commit fd97570

File tree

2 files changed

+72
-71
lines changed

2 files changed

+72
-71
lines changed

client-app/src/components/DraftOrcaDashboard.js

+35-37
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ const DraftOrcaDashboard = () => {
101101
file_path: filePath.toString(),
102102
search_terms: searchTerms.split(","),
103103
sections: sections.type === "Custom"
104-
? sections.value.split(",") // Convert custom value into an array
105-
: sections.value.split(","), // Handle First/Last consistently
104+
? sections.value.split(",")
105+
: sections.value.split(","),
106106
specify_lines: specifyLines.toString(),
107107
};
108108

@@ -176,8 +176,8 @@ const DraftOrcaDashboard = () => {
176176
file_path: filePath.toString(),
177177
search_terms: searchTerms.split(","),
178178
sections: sections.type === "Custom"
179-
? sections.value.split(",") // Convert custom value into an array
180-
: sections.value.split(","), // Handle First/Last consistently
179+
? sections.value.split(",")
180+
: sections.value.split(","),
181181
specify_lines: specifyLines.toString(),
182182
};
183183

@@ -268,40 +268,38 @@ const DraftOrcaDashboard = () => {
268268
</div>
269269

270270
<div className="mb-3 text-start">
271-
<span>Number of sections?</span>
272-
<select
273-
className="form-select mb-2"
274-
value={sections.type || "Custom"} // Bind the value to sections.type
275-
onChange={(e) => {
276-
const selectedValue = e.target.value;
277-
if (selectedValue === "First") {
278-
setSections({ type: "First", value: "1" }); // Consistent object format
279-
} else if (selectedValue === "Last") {
280-
setSections({ type: "Last", value: "0" }); // Consistent object format
281-
} else {
282-
setSections({ type: "Custom", value: "" }); // Clear for custom input
283-
}
284-
}}
285-
>
286-
<option value="First">First</option>
287-
<option value="Last">Last</option>
288-
<option value="Custom">Custom</option>
289-
</select>
290-
291-
{/* Custom input field */}
292-
{sections.type === "Custom" && (
293-
<input
294-
type="text"
295-
className="form-control"
296-
placeholder="Enter custom sections (e.g., 1-5 or 1,3,5)"
297-
value={sections.value} // Bind to sections.value
298-
onChange={(e) =>
299-
setSections({ type: "Custom", value: e.target.value.trim() })
300-
}
301-
/>
302-
)}
271+
<span>Number of sections?</span>
272+
<select
273+
className="form-select mb-2"
274+
value={sections.type || "Custom"}
275+
onChange={(e) => {
276+
const selectedValue = e.target.value;
277+
if (selectedValue === "First") {
278+
setSections({ type: "First", value: "1" });
279+
} else if (selectedValue === "Last") {
280+
setSections({ type: "Last", value: "0" });
281+
} else {
282+
setSections({ type: "Custom", value: "" });
283+
}
284+
}}
285+
>
286+
<option value="First">First</option>
287+
<option value="Last">Last</option>
288+
<option value="Custom">Custom</option>
289+
</select>
303290

304-
</div>
291+
{sections.type === "Custom" && (
292+
<input
293+
type="text"
294+
className="form-control"
295+
placeholder="Enter custom sections (e.g., 1-5 or 1,3,5)"
296+
value={sections.value}
297+
onChange={(e) =>
298+
setSections({ type: "Custom", value: e.target.value.trim() })
299+
}
300+
/>
301+
)}
302+
</div>
305303

306304

307305

client-app/src/components/OrcaDashboardComponent.js

+37-34
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const OrcaDashboardComponent = () => {
4747
file_path: filePath.toString(),
4848
search_terms: searchTerms.split(","),
4949
sections: sections.type === "Custom"
50-
? sections.value.split(",") // Convert custom value into an array
51-
: sections.value.split(","), // Handle First/Last consistently
50+
? sections.value.split(",")
51+
: sections.value.split(","),
5252
specify_lines: specifyLines.toString(),
5353
};
5454

@@ -87,8 +87,8 @@ const OrcaDashboardComponent = () => {
8787
file_path: filePath.toString(),
8888
search_terms: searchTerms.split(","),
8989
sections: sections.type === "Custom"
90-
? sections.value.split(",") // Convert custom value into an array
91-
: sections.value.split(","), // Handle First/Last consistently
90+
? sections.value.split(",")
91+
: sections.value.split(","),
9292
specify_lines: specifyLines.toString(),
9393
};
9494

@@ -148,36 +148,39 @@ const OrcaDashboardComponent = () => {
148148
</div>
149149

150150
<div className="mb-3 text-start">
151-
<span>Number of sections?</span>
152-
<select
153-
className="form-select mb-2"
154-
value={sections.type || "Custom"}
155-
onChange={(e) => {
156-
const selectedValue = e.target.value;
157-
if (selectedValue === "First") {
158-
setSections({ type: "First", value: "1" });
159-
} else if (selectedValue === "Last") {
160-
setSections({ type: "Last", value: "0" });
161-
} else {
162-
setSections({ type: "Custom", value: "" });
163-
}
164-
}}>
165-
<option value="First">First</option>
166-
<option value="Last">Last</option>
167-
<option value="Custom">Custom</option>
168-
</select>
169-
{sections.type === "Custom" && (
170-
<input
171-
type="text"
172-
className="form-control"
173-
placeholder="Enter custom sections (e.g., 1-5 or 1,3,5)"
174-
value={sections.value}
175-
onChange={(e) =>
176-
setSections({ type: "Custom", value: e.target.value.trim() })
177-
}
178-
/>
179-
)}
180-
</div>
151+
<span>Number of sections?</span>
152+
<select
153+
className="form-select mb-2"
154+
value={sections.type || "Custom"}
155+
onChange={(e) => {
156+
const selectedValue = e.target.value;
157+
if (selectedValue === "First") {
158+
setSections({ type: "First", value: "1" });
159+
} else if (selectedValue === "Last") {
160+
setSections({ type: "Last", value: "0" });
161+
} else {
162+
setSections({ type: "Custom", value: "" });
163+
}
164+
}}
165+
>
166+
<option value="First">First</option>
167+
<option value="Last">Last</option>
168+
<option value="Custom">Custom</option>
169+
</select>
170+
171+
{sections.type === "Custom" && (
172+
<input
173+
type="text"
174+
className="form-control"
175+
placeholder="Enter custom sections (e.g., 1-5 or 1,3,5)"
176+
value={sections.value}
177+
onChange={(e) =>
178+
setSections({ type: "Custom", value: e.target.value.trim() })
179+
}
180+
/>
181+
)}
182+
183+
</div>
181184

182185

183186
<div className="mb-3 text-start">

0 commit comments

Comments
 (0)