Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/mobile/src/libs/components/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export { Logo } from "./logo/logo";
export { Modal } from "./modal/modal";
export { MultipleCheckboxInput } from "./multiple-checkbox-input/multiple-checkbox-input";
export { MultipleSliderInput } from "./multiple-slider-input/multiple-slider-input";
export { OnLeaveModal } from "./on-leave-modal/on-leave-modal";
export { PageSwitcher } from "./page-switcher/page-switcher";
export { Planet } from "./planet/planet";
export { ProgressBar } from "./progress-bar/progress-bar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ type ModalButtonConfiguration = {

type Properties = {
buttonsConfiguration: ModalButtonConfiguration[];
description: string;
isVisible: boolean;
onBackdropPress: () => void;
};

const ICON_SIZE = 70;

const SignOutModal: FC<Properties> = ({
const OnLeaveModal: FC<Properties> = ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and file name as well

Suggested change
const OnLeaveModal: FC<Properties> = ({
const ConfirmationModal: FC<Properties> = ({

buttonsConfiguration,
description,
isVisible,
onBackdropPress,
}) => {
Expand All @@ -46,9 +48,8 @@ const SignOutModal: FC<Properties> = ({
name="directions-run"
size={ICON_SIZE}
/>
<Text preset="subheading" style={styles.text}>
Oh no! You&apos;re one step away from life balance. Are you sure you
want to leave?
<Text preset="subheading" style={styles.text} weight="bold">
{description}
</Text>
</View>
<View style={globalStyles.gap12}>
Expand All @@ -66,4 +67,4 @@ const SignOutModal: FC<Properties> = ({
);
};

export { SignOutModal };
export { OnLeaveModal };
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { StackActions } from "@react-navigation/native";
import React from "react";
import React, { type ComponentProps } from "react";

import {
CheckboxCategoriesForm,
LoaderWrapper,
OnLeaveModal,
PageSwitcher,
ScreenWrapper,
ScrollView,
Expand Down Expand Up @@ -42,8 +43,31 @@ const EditWheelResults: React.FC = () => {
>();

const { dataStatus, scores } = useAppSelector((state) => state.quiz);

const dispatch = useAppDispatch();

const [isConfirmationModalVisible, setIsConfirmationModalVisible] =
useState<boolean>(false);

const handleModalDismiss = useCallback((): void => {
setIsConfirmationModalVisible(false);
}, []);

const modalButtonsConfiguration: ComponentProps<
typeof OnLeaveModal
>["buttonsConfiguration"] = [
{
appearance: "filled",
label: "Yes",
onPress: handleModalDismiss,
},
{
appearance: "outlined",
label: "Cancel",
onPress: handleModalDismiss,
},
];

const handleEditScores = useCallback(
(payload: QuizScoresUpdateRequestDto) => {
void dispatch(quizActions.editScores(payload));
Expand Down Expand Up @@ -136,6 +160,12 @@ const EditWheelResults: React.FC = () => {
)}
</View>
</LoaderWrapper>
<OnLeaveModal
buttonsConfiguration={modalButtonsConfiguration}
description="Unsaved changes will be lost. Continue?"
isVisible={isConfirmationModalVisible}
onBackdropPress={handleModalDismiss}
/>
</ScreenWrapper>
);
};
Expand Down

This file was deleted.

8 changes: 5 additions & 3 deletions apps/mobile/src/screens/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { type ComponentProps } from "react";
import {
Button,
MultipleCheckboxInput,
OnLeaveModal,
RadioGroup,
ScreenWrapper,
ScrollView,
Expand Down Expand Up @@ -34,7 +35,6 @@ import {
import { actions as authActions } from "~/slices/auth/auth";
import { actions as userActions } from "~/slices/users/users";

import { SignOutModal } from "./libs/components/components";
import { styles } from "./styles";

const Settings: React.FC = () => {
Expand Down Expand Up @@ -70,7 +70,7 @@ const Settings: React.FC = () => {
);

const modalButtonsConfiguration: ComponentProps<
typeof SignOutModal
typeof OnLeaveModal
>["buttonsConfiguration"] = [
{
appearance: "outlined",
Expand Down Expand Up @@ -166,8 +166,10 @@ const Settings: React.FC = () => {
/>
</View>
</View>
<SignOutModal
<OnLeaveModal
buttonsConfiguration={modalButtonsConfiguration}
description="Oh no! You're one step away from life balance. Are you sure you
want to leave?"
isVisible={isConfirmationModalVisible}
onBackdropPress={handleModalDismiss}
/>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading