Dev Helpers
← Back

Remove a withdrawn candidate and close ranks

Remove a withdrawn candidate and close ranks. Build the result in an App Router server page and send the rendered entries to the client.

Open this example in the interactive library

Source code

// app/remove-a-withdrawn-candidate-and-close-ranks/page.tsx
export const metadata = {
  title: "Remove a withdrawn candidate and close ranks",
};
export default function Page() {
  const rows = [
    { name: "Ada", picks: ["A", "C", "B"] },
    { name: "Kim", picks: ["C", "A", "B"] },
    { name: "Leo", picks: ["A", "B", "C"] },
  ];
  const result = rows.map((r) => ({
    ...r,
    picks: r.picks.filter((p) => p !== "A"),
  }));
  const entries = Object.entries(
    typeof result === "object" && result !== null ? result : { value: result },
  );
  return (
    <section>
      <h2>{"Remove a withdrawn candidate and close ranks"}</h2>
      {entries.length ? (
        <dl>
          {entries.map(([key, value]) => (
            <div key={key}>
              <dt>{key}</dt>
              <dd>
                {typeof value === "string" ? value : JSON.stringify(value)}
              </dd>
            </div>
          ))}
        </dl>
      ) : (
        <p>No matching entries.</p>
      )}
    </section>
  );
}