more rigbuilder fixes
This commit is contained in:
parent
9621dad341
commit
f334bcba73
1 changed files with 32 additions and 7 deletions
|
|
@ -5,6 +5,17 @@ import { useForm } from "react-hook-form";
|
|||
import { z } from "zod";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
function handleAuthError(err: any): boolean {
|
||||
const status = (err as any)?.status;
|
||||
const code = (err as any)?.code;
|
||||
if (status === 401 || code === "TOKEN_EXPIRED") {
|
||||
const next = encodeURIComponent(window.location.pathname + window.location.search);
|
||||
window.location.assign(`/auth/sign-in?next=${next}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
|
@ -101,6 +112,20 @@ export default function RigBuilderClient() {
|
|||
// Options that depend on rig type
|
||||
const [sourceOpts, setSourceOpts] = useState<Option[]>([]);
|
||||
const [softwareOpts, setSoftwareOpts] = useState<Option[]>([]);
|
||||
|
||||
// Load laser software list once (independent of rig type)
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const swJson = await apiJson<any>(`/api/options/laser_software`);
|
||||
const sw = Array.isArray(swJson?.data) ? swJson.data : Array.isArray(swJson) ? swJson : [];
|
||||
setSoftwareOpts(sw);
|
||||
} catch (e) { if (!handleAuthError(e)) {
|
||||
console.error('[laser_software] load failed:', e);
|
||||
setSoftwareOpts([]);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
const [scanLensOpts, setScanLensOpts] = useState<Option[]>([]);
|
||||
const [focusLensOpts, setFocusLensOpts] = useState<Option[]>([]);
|
||||
|
||||
|
|
@ -315,7 +340,7 @@ export default function RigBuilderClient() {
|
|||
<SelectValue placeholder="Choose a rig type" />
|
||||
</SelectTrigger>
|
||||
{/* add scroll so big lists are usable */}
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
{rigTypeItems.map((rt) => (
|
||||
<SelectItem key={rt.value} value={rt.value}>
|
||||
{rt.label}
|
||||
|
|
@ -335,7 +360,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
{sourceOpts.map((o) => (
|
||||
<SelectItem key={o.id} value={String(o.id)}>
|
||||
|
|
@ -356,7 +381,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
{softwareOpts.map((o) => (
|
||||
<SelectItem key={o.id} value={String(o.id)}>
|
||||
|
|
@ -385,7 +410,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
{focusLensOpts.map((o) => (
|
||||
<SelectItem key={o.id} value={String(o.id)}>
|
||||
|
|
@ -410,7 +435,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
{scanLensOpts.map((o) => (
|
||||
<SelectItem key={o.id} value={String(o.id)}>
|
||||
|
|
@ -430,7 +455,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
{/* These can be swapped to real options when you expose them as /api/options/... */}
|
||||
<SelectItem value="10mm">10 mm</SelectItem>
|
||||
|
|
@ -450,7 +475,7 @@ export default function RigBuilderClient() {
|
|||
<SelectTrigger>
|
||||
<SelectValue placeholder="Optional" />
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border">
|
||||
<SelectContent position="popper" className="max-h-64 overflow-y-auto z-50 bg-background text-foreground border z-50 bg-background text-foreground border">
|
||||
<SelectItem value="none">—</SelectItem>
|
||||
<SelectItem value="1.5x">1.5×</SelectItem>
|
||||
<SelectItem value="2x">2×</SelectItem>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue