import React, { useState } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@components/ui/card'; import { Button } from '@components/ui/button'; import { Input } from '@components/ui/input'; import { useGlobalState } from '@contexts/state/StateContext'; import { Trash2, Plus } from 'lucide-react'; const FourActions = () => { const { state, dispatch } = useGlobalState(); const [newItems, setNewItems] = useState({ eliminate: '', reduce: '', raise: '', create: '', }); const addItem = (actionType: keyof typeof newItems) => { if (!newItems[actionType]) return; dispatch({ type: 'ADD_ACTION', payload: { actionType, value: newItems[actionType], }, }); setNewItems((prev) => ({ ...prev, [actionType]: '' })); }; const removeItem = ( actionType: keyof typeof state.fourActions, index: number ) => { dispatch({ type: 'SET_STATE', payload: { ...state, fourActions: { ...state.fourActions, [actionType]: state.fourActions[actionType].filter( (_, i) => i !== index ), }, }, }); }; const renderActionSection = ( title: string, actionType: keyof typeof state.fourActions, description: string, colorClasses: string ) => ( {title}

{description}

setNewItems((prev) => ({ ...prev, [actionType]: e.target.value })) } className="flex-1" />
{state.fourActions[actionType].map((item, index) => (
{item}
))}
); return (
{renderActionSection( 'Eliminate', 'eliminate', 'Which factors should be eliminated?', 'border-red-500/50 dark:border-red-500/30 bg-red-50/50 dark:bg-red-950/10' )} {renderActionSection( 'Reduce', 'reduce', 'Which factors should be reduced well below the industry standard?', 'border-yellow-500/50 dark:border-yellow-500/30 bg-yellow-50/50 dark:bg-yellow-950/10' )} {renderActionSection( 'Raise', 'raise', 'Which factors should be raised well above the industry standard?', 'border-green-500/50 dark:border-green-500/30 bg-green-50/50 dark:bg-green-950/10' )} {renderActionSection( 'Create', 'create', 'Which factors should be created that the industry has never offered?', 'border-blue-500/50 dark:border-blue-500/30 bg-blue-50/50 dark:bg-blue-950/10' )}
); }; export default FourActions;