| | | 1 | | import { Form, Link } from "react-router"; |
| | | 2 | | import type { LocationResponse } from "~/api/client"; |
| | | 3 | | |
| | 0 | 4 | | export function LocationsList({ locations }: { locations: LocationResponse[] }) { |
| | 0 | 5 | | if (locations.length === 0) { |
| | 0 | 6 | | return ( |
| | | 7 | | <div className="card-empty"> |
| | | 8 | | <p className="text-muted">No locations yet.</p> |
| | | 9 | | <Link to="/locations/new" className="link-text" style={{ display: "inline-block", marginTop: 12 }}> |
| | | 10 | | Add your first location → |
| | | 11 | | </Link> |
| | | 12 | | </div> |
| | | 13 | | ); |
| | | 14 | | } |
| | | 15 | | |
| | 0 | 16 | | return ( |
| | | 17 | | <table className="console-table"> |
| | | 18 | | <thead> |
| | | 19 | | <tr> |
| | | 20 | | <th>Name</th> |
| | | 21 | | <th>Description</th> |
| | | 22 | | <th style={{ width: 1, whiteSpace: "nowrap" }}></th> |
| | | 23 | | </tr> |
| | | 24 | | </thead> |
| | | 25 | | <tbody> |
| | 0 | 26 | | {locations.map((loc) => ( |
| | 0 | 27 | | <tr key={loc.id}> |
| | | 28 | | <td> |
| | | 29 | | <span style={{ fontWeight: 500 }}>{loc.name ?? "Unnamed"}</span> |
| | | 30 | | </td> |
| | | 31 | | <td style={{ color: "var(--c-fg-3)", fontSize: 12 }}> |
| | | 32 | | {loc.description || "—"} |
| | | 33 | | </td> |
| | | 34 | | <td> |
| | | 35 | | <div style={{ display: "flex", alignItems: "center", gap: 6 }}> |
| | | 36 | | <Link to={`/locations/${loc.id}/rooms`} className="link-chip">Rooms</Link> |
| | | 37 | | <Link to={`/locations/${loc.id}/edit`} className="link-chip">Edit</Link> |
| | | 38 | | <Form |
| | | 39 | | method="post" |
| | 0 | 40 | | onSubmit={(e) => { |
| | 0 | 41 | | if (!confirm("Delete this location and all its rooms and items?")) e.preventDefault(); |
| | | 42 | | }} |
| | | 43 | | > |
| | | 44 | | <input type="hidden" name="_action" value="delete" /> |
| | | 45 | | <input type="hidden" name="id" value={loc.id} /> |
| | | 46 | | <button type="submit" className="link-chip" style={{ color: "var(--c-danger)", borderColor: "transpare |
| | | 47 | | Delete |
| | | 48 | | </button> |
| | | 49 | | </Form> |
| | | 50 | | </div> |
| | | 51 | | </td> |
| | | 52 | | </tr> |
| | | 53 | | ))} |
| | | 54 | | </tbody> |
| | | 55 | | </table> |
| | | 56 | | ); |
| | | 57 | | } |