| 1 | import { useContext } from "react"; |
| 2 | import { IdeMessengerContext } from "../../../../context/IdeMessenger"; |
| 3 | import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; |
| 4 | import { exitEdit } from "../../../../redux/thunks/edit"; |
| 5 | import AcceptRejectDiffButtons from "../../../AcceptRejectDiffButtons"; |
| 6 | import { useMainEditor } from "../../TipTapEditor"; |
| 7 | |
| 8 | export function EditOutcomeToolbar() { |
| 9 | const dispatch = useAppDispatch(); |
| 10 | const editApplyState = useAppSelector( |
| 11 | (store) => store.editModeState.applyState, |
| 12 | ); |
| 13 | const { mainEditor } = useMainEditor(); |
| 14 | const ideMessenger = useContext(IdeMessengerContext); |
| 15 | |
| 16 | return ( |
| 17 | <div className="text-description-muted flex items-center justify-between py-0.5 text-xs"> |
| 18 | <div className="bg-badge rounded px-1.5"> |
| 19 | <span>{`${editApplyState.numDiffs} diff${editApplyState.numDiffs !== 1 ? "s" : ""}`}</span> |
| 20 | </div> |
| 21 | <AcceptRejectDiffButtons |
| 22 | applyStates={[editApplyState]} |
| 23 | onAcceptOrReject={async (outcome) => { |
| 24 | if (outcome === "acceptDiff") { |
| 25 | await dispatch(exitEdit({})); |
| 26 | ideMessenger.post("focusEditor", undefined); |
| 27 | } else { |
| 28 | mainEditor?.commands.focus(); |
| 29 | } |
| 30 | }} |
| 31 | /> |
| 32 | </div> |
| 33 | ); |
| 34 | } |