import dayjs from 'dayjs';

const TelegramDateChip = ({ ts }: { ts: number }) => {
  const d = dayjs.unix(ts);
  const now = dayjs();
  let label = d.format('D MMMM');
  if (d.isSame(now, 'day')) label = 'Сегодня';
  else if (d.isSame(now.subtract(1, 'day'), 'day')) label = 'Вчера';
  else if (d.isSame(now, 'year')) label = d.format('D MMMM');
  return (
    <div className="flex justify-center my-3 sticky top-2 z-[5]">
      <div className="px-3 py-1 rounded-full bg-black/40 text-white text-[12px] backdrop-blur-sm">
        {label}
      </div>
    </div>
  );
};

export default TelegramDateChip;
