Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

1.7 KB
Raw Blame
import { useTranslations } from 'next-intl';
import { cn } from '@/lib/utils';
import type { PulseUnit } from '@/lib/api/endpoints/analytics';
import type { WidgetConfig } from '@/utils/dashboardWidgets';

const UNIT_OPTIONS: PulseUnit[] = ['hour', 'day', 'week'];

export default function PulseWidgetSettings({
  config,
  onConfigChange,
}: {
  config: WidgetConfig;
  onConfigChange: (config: WidgetConfig) => void;
}) {
  const t = useTranslations('dashboards.pulse');
  const unit = config.granularity ?? 'day';
  return (
    <div className="flex flex-wrap gap-1">
      {(['project', 'me'] as const).map((scope) => (
        <button
          key={scope}
          aria-pressed={(config.pulseScope ?? 'project') === scope}
          type="button"
          onClick={() => onConfigChange({ pulseScope: scope })}
          className={cn(
            'rounded-md px-2 py-0.5 text-xs',
            (config.pulseScope ?? 'project') === scope
              ? 'bg-secondary font-medium'
              : 'text-muted-foreground hover:bg-accent',
          )}
        >
          {t(`scope.${scope}`)}
        </button>
      ))}
      {UNIT_OPTIONS.map((option) => (
        <button
          key={option}
          aria-pressed={unit === option}
          type="button"
          onClick={() => onConfigChange({ granularity: option })}
          className={cn(
            'rounded-md px-2 py-0.5 text-xs transition-colors',
            unit === option
              ? 'bg-secondary font-medium text-foreground'
              : 'text-muted-foreground hover:bg-accent hover:text-foreground',
          )}
        >
          {t(`unit.${option}`)}
        </button>
      ))}
    </div>
  );
}