< Summary

Information
Class: locations-list.tsx
Assembly: app.features.locations
File(s): /home/runner/work/ClutterStock/ClutterStock/frontend/app/features/locations/locations-list.tsx
Tag: 58_25416222083
Line coverage
75%
Covered lines: 6
Uncovered lines: 2
Coverable lines: 8
Total lines: 62
Line coverage: 75%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/ClutterStock/ClutterStock/frontend/app/features/locations/locations-list.tsx

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