Skip to content

Commit af430a8

Browse files
committed
feat: adding validation header
1 parent 77f852b commit af430a8

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

exporter/SynthesisFusionAddin/web/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function App() {
261261
selection={{ isSelecting, setIsSelecting }}
262262
/>
263263
</TabPanel>
264-
<TabPanel value={activeTab} index={2}>
264+
<TabPanel value={activeTab} index={4}>
265265
<DesignCheckTab />
266266
</TabPanel>
267267
<Container

exporter/SynthesisFusionAddin/web/src/lib/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ export interface DesignRule {
154154
max_value: number
155155
}
156156
export async function getDesignRules(): Promise<DesignRule[] | undefined> {
157+
if (import.meta.env.DEV && typeof window.adsk === "undefined") {
158+
return new Promise<DesignRule[]>(resolve => {
159+
setTimeout(() => {
160+
resolve([
161+
{ name: "Rule 1", calculation: 10, max_value: 20 },
162+
{ name: "Rule 2", calculation: 25, max_value: 20 },
163+
{ name: "Rule 3", calculation: 5, max_value: 15 },
164+
])
165+
}, 1000)
166+
})
167+
}
157168
return await sendData("designRules", {})
158169
}
159170

exporter/SynthesisFusionAddin/web/src/ui/DesignCheckTab.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,31 @@ function DesignCheckTab({}: DesignCheckTabProps) {
1616
const [rules, setRules] = useState<DesignRule[]>([])
1717

1818
useEffect(() => {
19-
getDesignRules().then(data => {
19+
const fetchRules = async () => {
20+
const data = await getDesignRules()
2021
if (data) {
2122
setRules(data)
2223
}
23-
})
24+
}
25+
26+
fetchRules()
2427
}, [])
2528

29+
function isDesignValid(): string {
30+
rules.forEach(rule => {
31+
if (rule.calculation > rule.max_value) {
32+
return "Invalid"
33+
}
34+
})
35+
36+
return "Valid"
37+
}
38+
2639
return (
2740
<>
41+
<h4>
42+
Checks Passing: {isDesignValid()}
43+
</h4>
2844
<TableContainer component={Paper} elevation={6}>
2945
<Table sx={{ minWidth: 650 }} aria-label="simple table" size={"small"}>
3046
<TableHead>

0 commit comments

Comments
 (0)