'use client';

import { SubNav } from './parts';

const SUBS = [
  ['capacity', 'Capacity limits'],
  ['skills', 'Skills'],
] as const;
export type RoutingSub = (typeof SUBS)[number][0];
export const isRoutingSub = (value: string | null): value is RoutingSub =>
  SUBS.some(([id]) => id === value);

/** Routing tab (design user-details.php `data-up-panel="routing"`). */
export function RoutingPanel({
  sub,
  onSub,
}: {
  sub: RoutingSub;
  onSub: (sub: RoutingSub) => void;
}) {
  return (
    <section className="up-panel">
      <div className="up-split">
        <SubNav items={SUBS} value={sub} onChange={onSub} />
        <div className="up-subpanels">
          {sub === 'capacity' ? (
            <div>
              <h2>Capacity limits</h2>
              <h3>Ticket capacity limits</h3>
              <p className="up-muted">
                Set the maximum number of open tickets this user can have. Automatic assignments
                will temporarily pause while the user is at full capacity.
              </p>
              <p className="up-note">
                Ticket capacity limits are not stored in this CRM yet, so they can&apos;t be set.
              </p>
              <button type="button" className="up-link up-link--btn" disabled>
                + Add capacity
              </button>
            </div>
          ) : (
            <div>
              <h2>Skills</h2>
              <p className="up-muted">
                Add relevant skills and language fluency to this user. Then you can set up
                skill-based routing to make ticket assignments according to skills.
              </p>
              <p className="up-note">
                Skills are not stored in this CRM yet, so they can&apos;t be added.
              </p>
              <button type="button" className="up-link up-link--btn" disabled>
                + Add skills
              </button>
            </div>
          )}
        </div>
      </div>
    </section>
  );
}
