Skip to content

Commit

Permalink
Removed unnecessary props
Browse files Browse the repository at this point in the history
  • Loading branch information
IraSoro committed Dec 27, 2023
1 parent bd9d231 commit 6173ca8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 27 deletions.
6 changes: 1 addition & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const Badge = () => {
const App: React.FC = () => {
const [cycles, setCycles] = useState<Cycle[]>([]);
const [theme, setTheme] = useState("basic");
const [isLanguageModal, setIsLanguageModal] = useState(false);

const { t, i18n } = useTranslation();
const [needUpdate, setNeedUpdate] = useState(false);
Expand Down Expand Up @@ -162,10 +161,7 @@ const App: React.FC = () => {
exact
path="/peri/"
>
<TabHome
isLanguageModal={isLanguageModal}
setIsLanguageModal={setIsLanguageModal}
/>
<TabHome />
</Route>

<Route
Expand Down
3 changes: 0 additions & 3 deletions src/modals/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import { getCurrentTranslation } from "../utils/translation";
interface PropsWelcomeModal {
isOpen: boolean;
setIsOpen: (newIsOpen: boolean) => void;

isLanguageModal: boolean;
setIsLanguageModal: (newIsOpen: boolean) => void;
}

const Welcome = (props: PropsWelcomeModal) => {
Expand Down
14 changes: 3 additions & 11 deletions src/pages/TabHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,7 @@ const EditCalendar = (props: SelectCalendarProps) => {
);
};

interface HomeProps {
isLanguageModal: boolean;
setIsLanguageModal: (newIsOpen: boolean) => void;
}

const TabHome = (props: HomeProps) => {
const TabHome = () => {
const theme = useContext(ThemeContext).theme;

const [isInfoModal, setIsInfoModal] = useState(false);
Expand All @@ -309,9 +304,8 @@ const TabHome = (props: HomeProps) => {

useEffect(() => {
const backButtonHandler = () => {
if (isInfoModal || props.isLanguageModal) {
if (isInfoModal) {
setIsInfoModal(false);
props.setIsLanguageModal(false);
router.push("/home");
return;
}
Expand All @@ -326,7 +320,7 @@ const TabHome = (props: HomeProps) => {
return () => {
document.removeEventListener("ionBackButton", backButtonHandler);
};
}, [router, isInfoModal, props]);
}, [router, isInfoModal]);

const { t } = useTranslation();
const { cycles, updateCycles } = useContext(CyclesContext);
Expand All @@ -346,8 +340,6 @@ const TabHome = (props: HomeProps) => {
<Welcome
isOpen={isWelcomeModal}
setIsOpen={setIsWelcomeModal}
isLanguageModal={props.isLanguageModal}
setIsLanguageModal={props.setIsLanguageModal}
/>
<div id="context-size">
<div style={{ marginTop: "30px", marginBottom: "30px" }}>
Expand Down
7 changes: 1 addition & 6 deletions src/tests/TabHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { render } from "@testing-library/react";
import TabHome from "../pages/TabHome";

test("renders without crashing", () => {
const { baseElement } = render(
<TabHome
isLanguageModal
setIsLanguageModal={() => {}}
/>,
);
const { baseElement } = render(<TabHome />);
expect(baseElement).toBeDefined();
});
2 changes: 0 additions & 2 deletions src/tests/WelcomeModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ test("renders without crashing", () => {
<Welcome
isOpen
setIsOpen={() => {}}
isLanguageModal
setIsLanguageModal={() => {}}
/>,
);
expect(baseElement).toBeDefined();
Expand Down

0 comments on commit 6173ca8

Please sign in to comment.