File size: 3,415 Bytes
0d9f1af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import React from "react";
import { Button } from "../components/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "../components/ui/card";
import { Alert, AlertDescription, AlertTitle } from "../components/ui/alert";
import { Badge } from "../components/ui/badge";
import type { ConnectedRobot } from "../types";

interface SetupProps {
  connectedRobots: ConnectedRobot[];
  onBack: () => void;
  onNext: (robot: ConnectedRobot) => void;
}

export function Setup({ connectedRobots, onBack, onNext }: SetupProps) {
  const configuredRobots = connectedRobots.filter(
    (r) => r.robotType && r.robotId
  );

  return (
    <div className="container mx-auto px-4 py-8 max-w-4xl">
      <div className="space-y-6">
        <div className="text-center space-y-2">
          <h1 className="text-3xl font-bold">Robot Setup</h1>
          <p className="text-muted-foreground">
            Select a connected robot to calibrate
          </p>
        </div>

        <div className="space-y-4">
          <div className="flex items-center justify-between">
            <h2 className="text-xl font-semibold">Connected Robots</h2>
            <Badge variant="outline">{configuredRobots.length} ready</Badge>
          </div>

          {configuredRobots.length === 0 ? (
            <Card>
              <CardContent className="text-center py-8">
                <div className="text-muted-foreground space-y-2">
                  <p>No configured robots found.</p>
                  <p className="text-sm">
                    Go back to the home page to connect and configure your
                    robots.
                  </p>
                </div>
              </CardContent>
            </Card>
          ) : (
            <div className="grid gap-4">
              {configuredRobots.map((robot, index) => (
                <Card
                  key={index}
                  className="cursor-pointer hover:shadow-md transition-shadow"
                >
                  <CardHeader>
                    <div className="flex items-center justify-between">
                      <div>
                        <CardTitle className="text-lg">
                          {robot.robotId}
                        </CardTitle>
                        <CardDescription>{robot.name}</CardDescription>
                      </div>
                      <div className="flex items-center space-x-2">
                        <Badge
                          variant={robot.isConnected ? "default" : "outline"}
                        >
                          {robot.isConnected ? "Connected" : "Available"}
                        </Badge>
                        <Badge variant="outline">
                          {robot.robotType?.replace("_", " ")}
                        </Badge>
                      </div>
                    </div>
                  </CardHeader>
                  <CardContent>
                    <Button onClick={() => onNext(robot)} className="w-full">
                      Calibrate This Robot
                    </Button>
                  </CardContent>
                </Card>
              ))}
            </div>
          )}
        </div>

        <div className="flex justify-center">
          <Button variant="outline" onClick={onBack}>
            Back to Home
          </Button>
        </div>
      </div>
    </div>
  );
}