import { getDeviceId } from '../lib/device';

export async function likePhoto(id: number): Promise<number> {
  const res = await fetch(`/api/v1/photos/${id}/like`, {
    method: 'POST',
    headers: {
      'X-Device-Id': getDeviceId(),
      'Content-Type': 'application/json',
    },
  });
  if (!res.ok) throw new Error('like failed');
  const json = await res.json();
  return json.likes_count ?? 0;
}

