'use client';

import { updateOfferStatus } from '../../properties/[id]/offer/actions';

export default function OfferActions({ offerId }: { offerId: number }) {
  
  const handleAccept = async () => {
    await updateOfferStatus(offerId, 'accepted');
  };

  const handleReject = async () => {
    await updateOfferStatus(offerId, 'rejected');
  };

  const handleCounter = async () => {
    const price = prompt("Enter counter offer price:");
    if (price && !isNaN(parseFloat(price))) {
      await updateOfferStatus(offerId, 'counter_offered', parseFloat(price));
    }
  };

  return (
    <div className="flex gap-2 mt-4">
      <button onClick={handleAccept} className="px-3 py-1 bg-green-500 text-white rounded text-sm hover:bg-green-600">Accept</button>
      <button onClick={handleCounter} className="px-3 py-1 bg-yellow-500 text-white rounded text-sm hover:bg-yellow-600">Counter</button>
      <button onClick={handleReject} className="px-3 py-1 bg-red-500 text-white rounded text-sm hover:bg-red-600">Reject</button>
    </div>
  );
}
