Skip to content

Commit

Permalink
fix multipe ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo Cherblanc authored and Lucanis committed Jan 17, 2024
1 parent 5589378 commit 7339e07
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CHECKOUT_STEP } from './constants';
import { useFinalCheckout } from '@openstudio/thelia-api-utils';
import Loader from '../Loader';
import { CheckoutRequest } from './type';
import { Checkout } from '@js/types/checkout.types';

export function CheckoutFooter({
step,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import {
} from '@openstudio/thelia-api-utils';
import Title from '../Title';

function getModuleValidOptions(module) {
return module?.options?.filter((o) => o.valid) || [];
function getModuleValidOptions(module: any) {
return module?.options?.filter((o: any) => o.valid) || [];
}

function ModuleOption({
module = {},
option = {},
isSelected
}: {
module: {};
option: {};
module: any;
option: any;
isSelected: boolean;
}) {
const intl = useIntl();
Expand All @@ -47,7 +47,7 @@ function ModuleOption({
pickupAddress: null
});
} else {
queryClient.setQueryData('checkout', (oldData) => {
queryClient.setQueryData('checkout', (oldData: any) => {
return {
...oldData,
deliveryModuleId: module.id,
Expand Down Expand Up @@ -76,12 +76,9 @@ function ModuleOption({
export default function DeliveryModules() {
const intl = useIntl();

const selectedMode = useSelector((state) => state.checkout.mode);
const selectedMode = useSelector((state: any) => state.checkout.mode);
const { data: checkout } = useGetCheckout();
const { data: modules, isLoading } = useValidDeliveryModules(
selectedMode,
checkout?.deliveryAddressId
);
const { data: modules, isLoading } = useValidDeliveryModules(selectedMode);

return (
<>
Expand All @@ -101,8 +98,8 @@ export default function DeliveryModules() {
className="Title--3 mb-5 text-2xl"
title="CHOOSE_DELIVERY_PROVIDER"
/>
{modules.map((module) =>
getModuleValidOptions(module).map((option) => (
{modules.map((module: any) =>
getModuleValidOptions(module).map((option: any) => (
<ModuleOption
key={module.code}
module={module}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Checkout } from '@js/types/checkout.types';
import { Checkout, CheckoutRequest } from '@js/types/checkout.types';
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';

export default function useEnableCta(currentStep = 1, checkout: Checkout) {
export default function useEnableCta(
currentStep = 1,
checkout: CheckoutRequest
) {
const { mode: selectedMode, phoneNumberValid } = useSelector(
(state: any) => state.checkout
);
Expand All @@ -12,18 +15,14 @@ export default function useEnableCta(currentStep = 1, checkout: Checkout) {
setEnabledCta(false);
switch (currentStep) {
case 4:
if (
checkout?.isComplete &&
checkout.acceptedTermsAndConditions &&
phoneNumberValid
) {
if (checkout.acceptedTermsAndConditions && phoneNumberValid) {
setEnabledCta(true);
}
break;
case 3:
if (
selectedMode !== null &&
checkout?.deliveryModule &&
checkout?.deliveryModuleId &&
checkout?.deliveryModuleOptionCode &&
(checkout?.deliveryAddressId || checkout.pickupAddress) &&
checkout?.billingAddressId
Expand All @@ -35,7 +34,7 @@ export default function useEnableCta(currentStep = 1, checkout: Checkout) {
setEnabledCta(false);
if (
selectedMode !== null &&
checkout?.deliveryModule &&
checkout?.deliveryModuleId &&
checkout?.deliveryModuleOptionCode &&
(checkout?.deliveryAddressId || checkout.pickupAddress)
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1 @@
import Alert from '../Alert';
import React from 'react';

export default class ErrorBoundary extends React.Component {
constructor() {
super();
this.state = {
error: null
};
}

componentDidCatch(error) {
console.error(error);
this.setState({ error });
}
render() {
if (this.state.error) {
if (typeof this.props.fallback === 'function') {
return this.props.fallback(this.state.error?.message);
} else if (this.props.fallback) {
return this.props.fallback;
}
return <Alert type="error" title="Error" />;
}
return this.props.children;
}
}
export { default } from './ErrorBoundary';

0 comments on commit 7339e07

Please sign in to comment.