< Summary

Information
Class: rooms-list.tsx
Assembly: app.components.rooms
File(s): /home/runner/work/ClutterStock/ClutterStock/frontend/app/components/rooms/rooms-list.tsx
Tag: 58_25416222083
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 65
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/ClutterStock/ClutterStock/frontend/app/components/rooms/rooms-list.tsx

#LineLine coverage
 1import { Form, Link } from "react-router";
 2import type { RoomResponse } from "~/api/client";
 3
 4type RoomsListProps = {
 5  locationId: number;
 6  locationName: string;
 7  rooms: RoomResponse[];
 8};
 9
 010export function RoomsList({ locationId, locationName, rooms }: RoomsListProps) {
 011  const base = `/locations/${locationId}/rooms`;
 12
 013  if (rooms.length === 0) {
 014    return (
 15      <div className="card-empty">
 16        <p className="text-muted">No rooms in {locationName} yet.</p>
 17        <Link to={`${base}/new`} className="link-text" style={{ display: "inline-block", marginTop: 12 }}>
 18          Add the first room →
 19        </Link>
 20      </div>
 21    );
 22  }
 23
 024  return (
 25    <table className="console-table">
 26      <thead>
 27        <tr>
 28          <th>Name</th>
 29          <th>Description</th>
 30          <th style={{ width: 1, whiteSpace: "nowrap" }}></th>
 31        </tr>
 32      </thead>
 33      <tbody>
 034        {rooms.map((room) => (
 035          <tr key={room.id}>
 36            <td>
 37              <span style={{ fontWeight: 500 }}>{room.name ?? "Unnamed"}</span>
 38            </td>
 39            <td style={{ color: "var(--c-fg-3)", fontSize: 12 }}>
 40              {room.description || "—"}
 41            </td>
 42            <td>
 43              <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
 44                <Link to={`/locations/${locationId}/rooms/${room.id}/items`} className="link-chip">Items</Link>
 45                <Link to={`${base}/${room.id}/edit`} className="link-chip">Edit</Link>
 46                <Form
 47                  method="post"
 048                  onSubmit={(e) => {
 049                    if (!confirm("Delete this room and all its items?")) e.preventDefault();
 50                  }}
 51                >
 52                  <input type="hidden" name="_action" value="delete" />
 53                  <input type="hidden" name="id" value={room.id} />
 54                  <button type="submit" className="link-chip" style={{ color: "var(--c-danger)", borderColor: "transpare
 55                    Delete
 56                  </button>
 57                </Form>
 58              </div>
 59            </td>
 60          </tr>
 61        ))}
 62      </tbody>
 63    </table>
 64  );
 65}