export const getCityFromZip = async (zip: string): Promise<string | null> => {
  if (!zip || zip.length !== 5) return null;
  try {
    const response = await fetch(`https://api.zippopotam.us/de/${zip}`);
    if (response.ok) {
      const data = await response.json();
      if (data && data.places && data.places.length > 0) {
        return data.places[0]['place name'];
      }
    }
  } catch (error) {
    console.error('Error fetching city for zip:', error);
  }
  return null;
};
