import dayjs from 'dayjs';

const InstagramDateChip = ({ 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-0.5 rounded-md text-[11px] font-bold uppercase tracking-[0.12em] text-[var(--tg-text-secondary)] bg-transparent">
        {label}
      </div>
    </div>
  );
};

export default InstagramDateChip;
