39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useId } from "react";
|
|
import type { DredgingRegistrationMode } from "../model/types";
|
|
|
|
type Props = {
|
|
value: DredgingRegistrationMode;
|
|
labels: Record<string, string>;
|
|
onChange: (mode: DredgingRegistrationMode) => void;
|
|
testIdPrefix: string;
|
|
};
|
|
|
|
/** 업로드 실행 버튼과 구분되는 등록 방식 선택. 기존 전환 처리는 호출 화면이 담당한다. */
|
|
export const DredgingRegistrationModeSelector = ({
|
|
value, labels, onChange, testIdPrefix,
|
|
}: Props) => {
|
|
const name = useId();
|
|
|
|
return (
|
|
<fieldset className="m-0 flex flex-wrap items-center gap-x-4 gap-y-2 border-0 p-0">
|
|
<legend className="sr-only">등록 방식</legend>
|
|
{(["PHOTO", "MANUAL"] as const).map((mode) => (
|
|
<label key={mode} className="inline-flex cursor-pointer items-center gap-2 py-1 text-sm text-label">
|
|
<input
|
|
type="radio"
|
|
name={name}
|
|
value={mode}
|
|
checked={value === mode}
|
|
onChange={() => onChange(mode)}
|
|
className="h-4 w-4 shrink-0 cursor-pointer accent-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
|
|
data-testid={`${testIdPrefix}-${mode.toLowerCase()}-mode`}
|
|
/>
|
|
<span className={value === mode ? "font-medium text-foreground" : ""}>{labels[mode]}</span>
|
|
</label>
|
|
))}
|
|
</fieldset>
|
|
);
|
|
};
|