import { View, Text, Pressable, StyleSheet } from 'react-native';
import { EnumOption } from '../../../api/profile';
import { colors, spacing, radii } from '../../../theme';

type Props = {
  options: EnumOption[];
  value: string | null;
  onChange: (value: string) => void;
  disabled?: boolean;
};

export function PillGroup({ options, value, onChange, disabled }: Props) {
  return (
    <View style={styles.row}>
      {options.map((option) => {
        const selected = option.value === value;
        return (
          <Pressable
            key={option.value}
            style={[styles.pill, selected && styles.pillSelected]}
            onPress={() => onChange(option.value)}
            disabled={disabled}
          >
            <Text style={[styles.pillText, selected && styles.pillTextSelected]}>{option.label}</Text>
          </Pressable>
        );
      })}
    </View>
  );
}

const styles = StyleSheet.create({
  row: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.xs },
  pill: {
    paddingHorizontal: spacing.md,
    paddingVertical: spacing.sm,
    borderRadius: radii.pill,
    borderWidth: 1,
    borderColor: colors.border,
    backgroundColor: colors.card,
  },
  pillSelected: { backgroundColor: colors.primary, borderColor: colors.primary },
  pillText: { fontSize: 14, fontWeight: '600', color: colors.text },
  pillTextSelected: { color: '#fff' },
});
