Skip to content

Commit 5558224

Browse files
committed
wip: unify types
1 parent 09ff16f commit 5558224

File tree

3 files changed

+78
-9
lines changed

3 files changed

+78
-9
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { useEffect, useState } from "react";
2+
import {Textarea} from "@nextui-org/react";
3+
4+
5+
type DataPoints = {
6+
pass_1: string,
7+
pass_2: string,
8+
pass_3: string
9+
}
10+
11+
12+
export default function AIResponsePass({ pass_1, pass_2, pass_3 }: DataPoints ) {
13+
14+
const [submission, setSubmission] = useState<string>("");
15+
16+
useEffect(() => {
17+
// if all 3 entries are equal, enter the first one since it doesn't matter which one is set
18+
if (pass_1 === pass_2 && pass_1 === pass_3 && pass_2 === pass_3) {
19+
setSubmission(pass_1)
20+
}
21+
// if only 2 out of 3 entries are equal
22+
else if (pass_1 === pass_2 || pass_1 === pass_3) {
23+
setSubmission(pass_1)
24+
}
25+
else if (pass_2 === pass_3) {
26+
setSubmission(pass_2)
27+
}
28+
}, [pass_1, pass_2, pass_3])
29+
30+
return (
31+
<span className="flex-row">
32+
<div className="flex-col">
33+
<span>First Pass</span>
34+
{ pass_1 }
35+
</div>
36+
<div className="flex-col">
37+
<span>First Pass</span>
38+
{ pass_2 }
39+
</div>
40+
<div className="flex-col">
41+
<span>First Pass</span>
42+
{ pass_3 }
43+
</div>
44+
<div className="flex-col">
45+
<span>Final Result</span>
46+
<Textarea className="max-w-xs" placeholder="Enter your description" value={submission} />
47+
</div>
48+
</span>
49+
)
50+
}

web/src/pages/edit-entry.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HiArrowLeft } from "react-icons/hi";
22
import {Accordion, AccordionItem, Button} from "@nextui-org/react";
33
import { useState } from "react";
44
import { PaperData } from "../types/types";
5+
import { GPTResponse } from "../types/types";
56

67
type PaperProps = {
78
paperData: PaperData[];
@@ -14,15 +15,15 @@ export default function EditEntry({ paperData }: PaperProps ) {
1415
const [papers] = useState<PaperData[]>(paperData ?? []);
1516
const unresolvedConflicts: string[] = [];
1617

17-
if (papers.length > 1) {
18-
// if all 3 outputs are the same, add nothing to the unresolved conflicts
19-
// if any of 3 outputs are not the same, go through each property
20-
if (JSON.stringify(papers[0]) === JSON.stringify(papers[1]) &&
21-
JSON.stringify(papers[0]) === JSON.stringify(papers[2]) &&
22-
JSON.stringify(papers[1]) === JSON.stringify(papers[2])) {
23-
console.log('hello')
24-
}
25-
}
18+
// if (papers.length > 1) {
19+
// // if all 3 outputs are the same, add nothing to the unresolved conflicts
20+
// // if any of 3 outputs are not the same, go through each property
21+
// if (JSON.stringify(papers[0]) === JSON.stringify(papers[1]) &&
22+
// JSON.stringify(papers[0]) === JSON.stringify(papers[2]) &&
23+
// JSON.stringify(papers[1]) === JSON.stringify(papers[2])) {
24+
// console.log('hello')
25+
// }
26+
// }
2627

2728
return (
2829
<div className="flex flex-col gap-2 p-4">

web/src/types/types.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ export type PaperData = {
1313
*/
1414
};
1515

16+
export type GPTData = {
17+
paper_name: string;
18+
year: number;
19+
author: string[];
20+
part_no: string;
21+
type: string;
22+
manufacturer: string;
23+
testing_location: TestLocation;
24+
testing_type: Testing;
25+
data_type: number;
26+
}
27+
28+
export type GPTResponse = {
29+
pass_1: GPTData,
30+
pass_2: GPTData,
31+
pass_3: GPTData
32+
}
33+
1634
export type TestLocation = "Terrestrial" | "Flight";
1735

1836
// Type to ensure testing types are consistent

0 commit comments

Comments
 (0)