Skip to content

Commit

Permalink
feat: add profile deletion confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Jun 23, 2023
1 parent d243b86 commit 880da61
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/renderer/components/combos/ComboForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { ComboConfiguration } from "@/lib/profile";
import type { iRootState } from "@/store";
import { DEFAULT_PROFILE } from "@/store/models/slippi";

import { Confirm } from "../Confirm";
import { CharacterSelectAdapter, CustomCharacterListAdapter } from "./CharacterSelect";
import { ToggleAdapter } from "./FormAdapters";
import { MoveSequenceFormAdapter } from "./MoveSequenceForm";
Expand Down Expand Up @@ -79,6 +80,7 @@ export const ComboForm: React.FC<{
onDelete: () => void;
onSubmit: (values: Values) => void;
}> = (props) => {
const [shouldConfirm, setShouldConfirm] = React.useState(false);
const [showAdvanced, setShowAdvanced] = React.useState(false);
const showDevOptions = useSelector((state: iRootState) => state.appContainer.showDevOptions);
return (
Expand All @@ -102,7 +104,7 @@ export const ComboForm: React.FC<{
<ButtonContainer
submitting={submitting}
currentProfile={props.currentProfile}
onDelete={props.onDelete}
onDelete={() => setShouldConfirm(true)}
currentProfileData={JSON.stringify(values)}
/>
<Field border="top">
Expand Down Expand Up @@ -254,13 +256,23 @@ export const ComboForm: React.FC<{
submitting={submitting}
currentProfile={props.currentProfile}
currentProfileData={JSON.stringify(values)}
onDelete={props.onDelete}
onDelete={() => setShouldConfirm(true)}
/>
<CodeBlock values={values} />
</SemanticForm>
</div>
)}
/>
<Confirm
open={shouldConfirm}
content="Are you sure you want to delete this profile? This cannot be undone."
confirmButton="Delete"
onCancel={() => setShouldConfirm(false)}
onConfirm={() => {
props.onDelete();
setShouldConfirm(false);
}}
/>
</div>
);
};
Expand Down

0 comments on commit 880da61

Please sign in to comment.