import React from 'react';
import { TextField } from '@mui/material';
import { LocationData } from '../types/fuel-logs.types';

interface Props {
  value?: LocationData;
  onChange: (value?: LocationData) => void;
  placeholder?: string;
}

export const LocationInput: React.FC<Props> = ({ value, onChange, placeholder }) => {
  return (
    <TextField
      label="Location (optional)"
      placeholder={placeholder}
      fullWidth
      value={value?.stationName || value?.address || ''}
      onChange={(e) => onChange({ ...(value || {}), stationName: e.target.value })}
    />
  );
};

