Skip to content

Commit 715b5cb

Browse files
Findmitreyalexanderrudnik
authored andcommitted
fix: update types
1 parent dc9edce commit 715b5cb

File tree

11 files changed

+29
-11
lines changed

11 files changed

+29
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { WithChildrenProps } from '@app/types/generalTypes';
12
import React from 'react';
23
import { CustomArrowProps } from 'react-slick';
34
import * as S from './CarouselArrow.styles';
45

5-
export const CarouselArrow: React.FC<CustomArrowProps> = ({ children, ...props }) => {
6+
export const CarouselArrow: React.FC<WithChildrenProps<CustomArrowProps>> = ({ children, ...props }) => {
67
return <S.ArrowWrapper {...props}>{children}</S.ArrowWrapper>;
78
};

src/components/common/PageTitle/PageTitle.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { WithChildrenProps } from '@app/types/generalTypes';
12
import React from 'react';
23
import { Helmet } from 'react-helmet';
34

4-
export const PageTitle: React.FC = ({ children }) => {
5+
export const PageTitle: React.FC<WithChildrenProps> = ({ children }) => {
56
return (
67
<Helmet>
78
<title>{children} | Lightence Admin</title>

src/components/common/ThemeSwitcher.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { WithChildrenProps } from '@app/types/generalTypes';
12
import React, { useEffect, useState } from 'react';
23
import { useThemeSwitcher } from 'react-css-theme-switcher';
34

4-
interface ThemeSwitcherProps {
5+
interface ThemeSwitcherProps extends WithChildrenProps {
56
theme: string;
67
}
78

src/components/common/charts/PieChartCustomLegend.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const PieChartCustomLegend: React.FC<PieChartCustomLegend> = ({
2424
}) => {
2525
const [activeItemIndex, setActiveItemIndex] = useState<number | null>(null);
2626

27-
const onMouseOver = useCallback(({ dataIndex }) => setActiveItemIndex(dataIndex), [setActiveItemIndex]);
27+
const onMouseOver = useCallback(
28+
({ dataIndex }: { dataIndex: number | null }) => setActiveItemIndex(dataIndex),
29+
[setActiveItemIndex],
30+
);
2831
const onMouseOut = useCallback(() => setActiveItemIndex(null), [setActiveItemIndex]);
2932

3033
const onEvents = {

src/components/layouts/main/MainHeader/MainHeader.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { WithChildrenProps } from '@app/types/generalTypes';
12
import React from 'react';
23
import * as S from './MainHeader.styles';
34

4-
interface MainHeaderProps {
5+
interface MainHeaderProps extends WithChildrenProps {
56
isTwoColumnsLayout: boolean;
67
}
78

src/components/profile/profileCard/profileFormNav/nav/PersonalInfo/PersonalInfo.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ZipcodeItem } from '@app/components/profile/profileCard/profileFormNav/
1717
import { AddressItem } from '@app/components/profile/profileCard/profileFormNav/nav/PersonalInfo/AddressItem/AddressItem';
1818
import { WebsiteItem } from '@app/components/profile/profileCard/profileFormNav/nav/PersonalInfo/WebsiteItem/WebsiteItem';
1919
import { SocialLinksItem } from '@app/components/profile/profileCard/profileFormNav/nav/PersonalInfo/SocialLinksItem/SocialLinksItem';
20+
import { CreditCard } from '@app/components/profile/profileCard/profileFormNav/nav/payments/paymentMethod/paymentForm/interfaces';
2021
import { useAppSelector } from '@app/hooks/reduxHooks';
2122
import { Dates } from '@app/constants/Dates';
2223
import { notificationController } from '@app/controllers/notificationController';
@@ -98,7 +99,7 @@ export const PersonalInfo: React.FC = () => {
9899
const { t } = useTranslation();
99100

100101
const onFinish = useCallback(
101-
(values) => {
102+
(values: CreditCard) => {
102103
// todo dispatch an action here
103104
setLoading(true);
104105
setTimeout(() => {

src/components/profile/profileCard/profileFormNav/nav/payments/paymentMethod/paymentForm/CardThemeItem/CardThemeItem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { Col, Row } from 'antd';
44
import { BaseButtonsForm } from '@app/components/common/forms/BaseButtonsForm/BaseButtonsForm';
5-
import { cardThemes } from '@app/constants/cardThemes';
5+
import { CardTheme, cardThemes } from '@app/constants/cardThemes';
66
import { CreditCard } from '@app/components/profile/profileCard/profileFormNav/nav/payments/paymentMethod/paymentForm/interfaces';
77
import * as S from './CardThemeItem.styles';
88

@@ -15,7 +15,7 @@ export const CardThemeItem: React.FC<CardThemeItemProps> = ({ cardData, setCardD
1515
const { t } = useTranslation();
1616

1717
const handleChange = useCallback(
18-
(item) => () => {
18+
(item: CardTheme) => () => {
1919
setCardData({ ...cardData, background: item.background });
2020
},
2121
[setCardData, cardData],

src/components/profile/profileCard/profileFormNav/nav/payments/paymentMethod/paymentForm/PaymentForm/PaymentForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const PaymentForm: React.FC<PaymentFormProps> = ({ closeModal, onFormFini
4444
);
4545

4646
const onFinish = useCallback(
47-
(values) => {
47+
(values: CreditCard) => {
4848
setLoading(true);
4949
setTimeout(() => {
5050
setLoading(false);

src/components/router/RequireAuth.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
22
import { Navigate } from 'react-router-dom';
33
import { useAppSelector } from '@app/hooks/reduxHooks';
4+
import { WithChildrenProps } from '@app/types/generalTypes';
45

5-
const RequireAuth: React.FC = ({ children }) => {
6+
const RequireAuth: React.FC<WithChildrenProps> = ({ children }) => {
67
const token = useAppSelector((state) => state.auth.token);
78

89
return token ? <>{children}</> : <Navigate to="/auth/login" replace />;

src/constants/cardThemes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface CardTheme {
1+
export interface CardTheme {
22
id: number;
33
background: string;
44
}

src/types/generalTypes.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ReactNode } from 'react';
2+
3+
export type WithChildrenProps<T = undefined> = T extends undefined
4+
? {
5+
children?: ReactNode;
6+
}
7+
: T & {
8+
children?: ReactNode;
9+
};

0 commit comments

Comments
 (0)