forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitMethodStep.tsx
More file actions
87 lines (81 loc) · 3.44 KB
/
Copy pathSplitMethodStep.tsx
File metadata and controls
87 lines (81 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { useTranslation } from 'react-i18next';
import { Equal, List, Percent, Sliders } from 'lucide-react';
import type { SplitMethod, WizardState } from '../../../types/wizard';
interface SplitMethodStepProps {
value: Pick<WizardState, 'splitMethod'>;
onChange: (patch: Partial<WizardState>) => void;
}
interface MethodOption {
id: SplitMethod;
icon: React.ReactNode;
labelKey: string;
descKey: string;
}
const METHOD_OPTIONS: MethodOption[] = [
{
id: 'equal',
icon: <Equal size={22} />,
labelKey: 'wizard.splitMethod.equal',
descKey: 'wizard.splitMethod.equalDesc',
},
{
id: 'itemized',
icon: <List size={22} />,
labelKey: 'wizard.splitMethod.itemized',
descKey: 'wizard.splitMethod.itemizedDesc',
},
{
id: 'percentage',
icon: <Percent size={22} />,
labelKey: 'wizard.splitMethod.percentage',
descKey: 'wizard.splitMethod.percentageDesc',
},
{
id: 'custom',
icon: <Sliders size={22} />,
labelKey: 'wizard.splitMethod.custom',
descKey: 'wizard.splitMethod.customDesc',
},
];
export const SplitMethodStep = ({ value, onChange }: SplitMethodStepProps) => {
const { t } = useTranslation();
return (
<div className="space-y-6">
<div>
<h2 className="text-xl font-bold text-gray-900">{t('wizard.splitMethod.title')}</h2>
<p className="text-sm text-gray-500 mt-1">{t('wizard.splitMethod.subtitle')}</p>
</div>
<div className="space-y-3">
{METHOD_OPTIONS.map((option) => {
const isSelected = value.splitMethod === option.id;
return (
<button
key={option.id}
type="button"
onClick={() => onChange({ splitMethod: option.id })}
className={`w-full flex items-center gap-4 p-4 rounded-xl border-2 text-left transition-all duration-200
${isSelected
? 'border-purple-500 bg-purple-50'
: 'border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50'
}`}
>
<div className={`p-2.5 rounded-lg flex-shrink-0 ${isSelected ? 'bg-purple-100 text-purple-600' : 'bg-gray-100 text-gray-500'}`}>
{option.icon}
</div>
<div className="flex-1 min-w-0">
<p className={`font-semibold text-sm ${isSelected ? 'text-purple-700' : 'text-gray-800'}`}>
{t(option.labelKey)}
</p>
<p className="text-xs text-gray-500 mt-0.5">{t(option.descKey)}</p>
</div>
<div className={`w-5 h-5 rounded-full border-2 flex-shrink-0 flex items-center justify-center transition-all
${isSelected ? 'border-purple-500 bg-purple-500' : 'border-gray-300'}`}>
{isSelected && <div className="w-2 h-2 rounded-full bg-white" />}
</div>
</button>
);
})}
</div>
</div>
);
};