Skip to content

Commit

Permalink
Updated the formatSpecifyLines method
Browse files Browse the repository at this point in the history
  • Loading branch information
SiriChandanaGarimella committed Nov 25, 2024
1 parent 576355f commit f85c91e
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions client-app/src/components/DraftOrcaDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ const DraftOrcaDashboard = () => {
};

const handleSpecifyLineChange = (value) => {
setSpecifyLines([{ value, showInput: value === "FIRST" || value === "LAST", lineNumber: "" }]);
setSpecifyLines([{ value, showInput: value === "FIRST" || value === "LAST" }]);
};


const renderSpecifyLine = () => {
const line = specifyLines[0] || { value: "", showInput: false };
Expand All @@ -60,12 +59,19 @@ const DraftOrcaDashboard = () => {
const updatedLines = [{ ...line, lineNumber: e.target.value }];
setSpecifyLines(updatedLines);
}}
/>
/>
)}
</div>
);
};

const formatSpecifyLines = () => {
const line = specifyLines[0];
return line.value === "WHOLE" || line.value === "SELECT"
? line.value
: `${line.value} ${line.lineNumber}`;
};

const onUpload = () => {
if (!selectedFile) {
console.error("No file selected");
Expand Down Expand Up @@ -97,26 +103,12 @@ const DraftOrcaDashboard = () => {
return;
}

function formatSpecifyLines(specifyLines) {
return specifyLines
.map((line) => {
if (line.value === "WHOLE") {
return "WHOLE";
}
if (line.value === "FIRST" || line.value === "LAST") {
return `${line.value} ${line.lineNumber || ""}`.trim();
}
return "";
})
.join(", ");
}

const data = {
file_path: filePath.toString(),
search_terms: searchTerms,
sections: sections,
specify_lines: formatSpecifyLines(specifyLines),
};
const data = {
file_path: filePath.toString(),
search_terms: searchTerms,
sections: sections,
specify_lines: formatSpecifyLines()
};

axios
.post("http://localhost:5001/find-sections", data, {
Expand Down Expand Up @@ -187,7 +179,7 @@ const data = {
file_path: filePath.toString(),
search_terms: searchTerms,
sections: sections,
specify_lines: specifyLines.join(","),
specify_lines: formatSpecifyLines()
};

axios
Expand Down

0 comments on commit f85c91e

Please sign in to comment.