Retirement tax questions

I have similar but not exact case (more complicated case) so need help.
Contributed $6000 on Oct 19, 2022
Withdrew $6000 on May 2, 2023 (when I realized I made too much income to be able to contribute to ROTH)
So the mistake I made was that I did not withdraw excess + gains, only the excess. The gains are still sitting in the account.
Q1: The 1099-R for $6000 withdrawal has code J in box 7 indicating early withdrawal no exception. Do I add P myself to indicate this was excess contribution withdrawal?
Q2: Box 2a is empty, do I compute my gains for the year 2023 on this excess contribution and enter that amount?
Q3: How do I deal with gains that are still in the ROTH. Should I withdraw them now (and deal with 1099-R from that again next year)?