Sales overview

Sales against target on a grey canvas: key figures with their progress to target, the pipeline by stage and the deals closing this month.

Open full screen

Canvas · Top bar. <AppShell direction="canvas">: a grey page with the top bar on it; the content in white cards with no border.

npx wideset add block-sales-overview

Import the default export from @/blocks/wideset/sales-overview. The files below are relative to your project's source directory.

Installed with this block
  • app-shell
  • avatar
  • block-styles
  • button
  • dropdown-menu
  • icon-button
  • list-item
  • navigation-bar
  • progress-bar
  • status-badge
  • table
  • utils
blocks/wideset/sales-overview/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { AppShell } from '@/components/ui/wideset/app-shell/AppShell';

import { ClosingDealsTable } from './closing-deals-table';
import { KEY_FIGURES } from './data';
import { formatCount, formatPercent, formatUsd, formatUsdCompact } from './format';
import { KpiCard } from './kpi-card';
import { PageHeader } from './page-header';
import { PipelineByStage } from './pipeline-by-stage';
import { RepLeaderboard } from './rep-leaderboard';
import { TopBar } from './top-bar';

type Figure = (typeof KEY_FIGURES)[number];

/** A figure against its target, in the words the key figure card shows. */
const toKpi = ({ label, value, target, unit }: Figure) => {
  const format = unit === 'usd' ? formatUsd : formatCount;
  const short = unit === 'usd' ? formatUsdCompact : formatCount;
  return {
    label,
    value: format(value),
    progress: value / target,
    target: `${formatPercent(value / target)} of ${short(target)}`,
    remaining: value >= target ? 'Target met' : `${short(target - value)} to go`,
  };
};

/**
 * Sales against target, Canvas direction: the top bar and the page title on the grey canvas, every
 * block of content in its own white card.
 */
export default function SalesOverview() {
  return (
    <AppShell className="ws-block-utility" direction="canvas">
      <AppShell.Main className="flex flex-col">
        <TopBar />
        <div className="px-ws-12 pb-ws-9 pt-ws-13 flex-1">
          <div className="gap-ws-12 mx-auto flex w-full max-w-[80rem] flex-col">
            <PageHeader />
            <div className="gap-ws-9 flex flex-col">
              <section aria-label="Key figures" className="gap-ws-9 grid grid-cols-4">
                {KEY_FIGURES.map((figure) => (
                  <KpiCard key={figure.label} {...toKpi(figure)} />
                ))}
              </section>
              <div className="gap-ws-9 grid grid-cols-4">
                <ClosingDealsTable className="col-span-3" />
                <div className="gap-ws-9 flex flex-col">
                  <PipelineByStage />
                  <RepLeaderboard className="flex-1" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </AppShell.Main>
    </AppShell>
  );
}