Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/operator/communications/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
const offset = kind === "maintenance" ? maintenanceOffset : postsOffset;
const visible = kind === "maintenance" ? maintenanceVisible : postsVisible;
if (visible < items.length) {
kind === "maintenance" ? setMaintenanceVisible(visible + 12) : setPostsVisible(visible + 12);

Check warning on line 44 in app/operator/communications/editor.tsx

View workflow job for this annotation

GitHub Actions / validate

Expected an assignment or function call and instead saw an expression
return;
}
const hasMore = kind === "maintenance" ? maintenanceHasMore : postsHaveMore;
Expand All @@ -67,7 +67,7 @@
} catch (error) {
if (generation === paginationGeneration.current[kind]) {
const message = error instanceof Error ? error.message : "Older entries could not be loaded.";
kind === "maintenance" ? setMaintenanceMessage(message) : setPostMessage(message);

Check warning on line 70 in app/operator/communications/editor.tsx

View workflow job for this annotation

GitHub Actions / validate

Expected an assignment or function call and instead saw an expression
}
} finally {
if (generation === paginationGeneration.current[kind]) setLoadingMore(null);
Expand Down Expand Up @@ -108,7 +108,7 @@
? { kind, id: editing?.id, title: raw.title, subtitle: raw.subtitle, message: raw.message, startsAt: toIsoTimestamp(raw.startsAt), endsAt: toIsoTimestamp(raw.endsAt), status: raw.status, affectedServices: String(raw.affectedServices ?? "").split(",").map(value => value.trim()).filter(Boolean) }
: { kind, id: editing?.id, title: raw.title, subtitle: raw.subtitle, category: raw.category, slug: raw.slug, body: raw.body, status: raw.status, publishedAt };
setBusy(true);
kind === "maintenance" ? setMaintenanceMessage("") : setPostMessage("");

Check warning on line 111 in app/operator/communications/editor.tsx

View workflow job for this annotation

GitHub Actions / validate

Expected an assignment or function call and instead saw an expression
try {
const response = await fetch("/api/operator/communications", { method: editing ? "PATCH" : "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) });
const result = await response.json() as { item?: MaintenanceNotice | EditorialPost; error?: string };
Expand Down Expand Up @@ -138,7 +138,7 @@
form.reset();
} catch (error) {
const message = error instanceof Error ? error.message : "The update could not be saved.";
kind === "maintenance" ? setMaintenanceMessage(message) : setPostMessage(message);

Check warning on line 141 in app/operator/communications/editor.tsx

View workflow job for this annotation

GitHub Actions / validate

Expected an assignment or function call and instead saw an expression
} finally {
setBusy(false);
}
Expand All @@ -164,7 +164,7 @@
<p role="status" aria-live="polite">{maintenanceMessage}</p>
</form>
<h3>Recent notices</h3>
{maintenance.length ? <ul>{maintenance.slice(0, maintenanceVisible).map(item => <li key={item.id} style={{ margin: "12px 0" }}><strong>{item.title}</strong> · {item.status} · {new Date(item.starts_at).toLocaleString()} <button type="button" onClick={() => setEditingMaintenance(item)}>Edit</button></li>)}</ul> : <p>No notices yet.</p>}{maintenance.length > maintenanceVisible || maintenanceHasMore ? <button type="button" disabled={loadingMore !== null} onClick={() => void showMore("maintenance")}>{loadingMore === "maintenance" ? "Loading…" : maintenanceVisible < maintenance.length ? "Show more notices" : "Load older notices"}</button> : null}
{maintenance.length ? <ul>{maintenance.slice(0, maintenanceVisible).map(item => <li key={item.id} style={{ margin: "12px 0" }}><strong>{item.title}</strong> · {item.status} · {new Date(item.starts_at).toLocaleString()} <button type="button" onClick={() => setEditingMaintenance(item)}>Edit</button></li>)}</ul> : <p>No notices yet.</p>}{maintenance.length > maintenanceVisible || maintenanceHasMore ? <button type="button" disabled={loadingMore !== null || busy} onClick={() => void showMore("maintenance")}>{loadingMore === "maintenance" ? "Loading…" : maintenanceVisible < maintenance.length ? "Show more notices" : "Load older notices"}</button> : null}
</section>

<section className="settings-card">
Expand All @@ -185,7 +185,7 @@
<p role="status" aria-live="polite">{postMessage}</p>
</form>
<h3>Recent articles</h3>
{posts.length ? <ul>{posts.slice(0, postsVisible).map(item => <li key={item.id} style={{ margin: "12px 0" }}><strong>{item.title}</strong> · {item.status} <button type="button" onClick={() => setEditingPost(item)}>Edit</button></li>)}</ul> : <p>No articles yet.</p>}{posts.length > postsVisible || postsHaveMore ? <button type="button" disabled={loadingMore !== null} onClick={() => void showMore("blog")}>{loadingMore === "blog" ? "Loading…" : postsVisible < posts.length ? "Show more articles" : "Load older articles"}</button> : null}
{posts.length ? <ul>{posts.slice(0, postsVisible).map(item => <li key={item.id} style={{ margin: "12px 0" }}><strong>{item.title}</strong> · {item.status} <button type="button" onClick={() => setEditingPost(item)}>Edit</button></li>)}</ul> : <p>No articles yet.</p>}{posts.length > postsVisible || postsHaveMore ? <button type="button" disabled={loadingMore !== null || busy} onClick={() => void showMore("blog")}>{loadingMore === "blog" ? "Loading…" : postsVisible < posts.length ? "Show more articles" : "Load older articles"}</button> : null}
</section>
</div>;
}
Loading