Skip to content

Commit

Permalink
LOC comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
freddi301 committed Nov 18, 2024
1 parent b7baa9e commit 5048596
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 117 deletions.
9 changes: 0 additions & 9 deletions ts/features/bonus/cgn/saga/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
cgnEycaActivationStatusRequest
} from "../store/actions/eyca/activation";
import {
cgnMerchantsCount,
cgnOfflineMerchants,
cgnOnlineMerchants,
cgnSearchMerchants,
Expand All @@ -40,7 +39,6 @@ import { cgnMerchantDetail } from "./networking/merchants/cgnMerchantDetail";
import { cgnOfflineMerchantsSaga } from "./networking/merchants/cgnOfflineMerchantsSaga";
import { cgnOnlineMerchantsSaga } from "./networking/merchants/cgnOnlineMerchantsSaga";
import { cgnSearchMerchantsSaga } from "./networking/merchants/cgnSearchMerchantsSaga";
import { cgnGetMerchantsCountSaga } from "./networking/merchants/cgnGetMerchantsCountSaga";
import { cgnBucketConsuption } from "./networking/bucket";
import { cgnUnsubscriptionHandler } from "./networking/unsubscribe";
import { cgnCategoriesSaga } from "./networking/categories/cgnCategoriesSaga";
Expand Down Expand Up @@ -112,13 +110,6 @@ export function* watchBonusCgnSaga(bearerToken: string): SagaIterator {
backendCgnMerchants.getPublishedCategories
);

// CGN Merchants count
yield* takeLatest(
getType(cgnMerchantsCount.request),
cgnGetMerchantsCountSaga,
backendCgnMerchants.getMerchantsCount
);

// CGN Search Merchants
yield* takeLatest(
getType(cgnSearchMerchants.request),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,17 @@ import {
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useFocusEffect } from "@react-navigation/native";
import { NonEmptyString } from "@pagopa/ts-commons/lib/strings";
import { useQuery } from "@tanstack/react-query";
import I18n from "../../../../../i18n";
import { useIONavigation } from "../../../../../navigation/params/AppParamsList";
import { useDebouncedValue } from "../../../../../hooks/useDebouncedValue";
import { useIODispatch, useIOSelector } from "../../../../../store/hooks";
import {
cgnMerchantsCountSelector,
cgnSearchMerchantsSelector
} from "../../store/reducers/merchants";
import { cgnSearchMerchantsSelector } from "../../store/reducers/merchants";
import { getValue } from "../../../../../common/model/RemoteValue";
import { SearchItem } from "../../../../../../definitions/cgn/merchants/SearchItem";
import {
cgnMerchantsCount,
cgnSearchMerchants
} from "../../store/actions/merchants";
import { cgnSearchMerchants } from "../../store/actions/merchants";
import { MerchantSearchResultListItem } from "../../components/merchants/MerchantSearchResultListItem";
import { cgnMerchantsCountQueryOptions } from "../../../../../../fetch-sdk/cgnMerchants";

const INPUT_PADDING: IOSpacingScale = 16;
const MIN_SEARCH_TEXT_LENGTH: number = 3;
Expand Down Expand Up @@ -94,11 +90,8 @@ export function CgnMerchantSearchScreen() {
[searchTextDebouncedTrimmed]
);

const merchantsCountRemoteValue = useIOSelector(cgnMerchantsCountSelector);
useEffect(() => {
dispatch(cgnMerchantsCount.request());
}, [dispatch]);
const merchantsCount = getValue(merchantsCountRemoteValue);
const merchantsCountQuery = useQuery(cgnMerchantsCountQueryOptions());
const merchantsCount = merchantsCountQuery.data?.count;

const renderListEmptyComponent = useCallback(() => {
if (searchText.trim().length < MIN_SEARCH_TEXT_LENGTH) {
Expand Down
11 changes: 0 additions & 11 deletions ts/features/bonus/cgn/store/actions/merchants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ import { SearchRequest } from "../../../../../../definitions/cgn/merchants/Searc
import { OfflineMerchantSearchRequest } from "../../../../../../definitions/cgn/merchants/OfflineMerchantSearchRequest";
import { OnlineMerchantSearchRequest } from "../../../../../../definitions/cgn/merchants/OnlineMerchantSearchRequest";
import { Discount } from "../../../../../../definitions/cgn/merchants/Discount";
import { CountResult } from "../../../../../../definitions/cgn/merchants/CountResult";

/**
* count merchants conventioned with CGN
*/
export const cgnMerchantsCount = createAsyncAction(
"CGN_MERCHANTS_COUNT_REQUEST",
"CGN_MERCHANTS_COUNT_SUCCESS",
"CGN_MERCHANTS_COUNT_FAILURE"
)<void, CountResult, NetworkError>();

/**
* search merchants conventioned with CGN
Expand Down Expand Up @@ -69,7 +59,6 @@ export const resetMerchantDiscountCode = createStandardAction(
)<void>();

export type CgnMerchantsAction =
| ActionType<typeof cgnMerchantsCount>
| ActionType<typeof cgnSearchMerchants>
| ActionType<typeof cgnOfflineMerchants>
| ActionType<typeof cgnOnlineMerchants>
Expand Down
25 changes: 0 additions & 25 deletions ts/features/bonus/cgn/store/reducers/merchants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NetworkError } from "../../../../../utils/errors";
import { Action } from "../../../../../store/actions/types";
import { GlobalState } from "../../../../../store/reducers/types";
import {
cgnMerchantsCount,
cgnOfflineMerchants,
cgnOnlineMerchants,
cgnSearchMerchants,
Expand All @@ -27,7 +26,6 @@ import { Discount } from "../../../../../../definitions/cgn/merchants/Discount";
import { SearchResult } from "../../../../../../definitions/cgn/merchants/SearchResult";

export type CgnMerchantsState = {
merchantsCount: RemoteValue<number, NetworkError>;
searchMerchants: RemoteValue<SearchResult["items"], NetworkError>;
onlineMerchants: RemoteValue<OnlineMerchants["items"], NetworkError>;
offlineMerchants: RemoteValue<OfflineMerchants["items"], NetworkError>;
Expand All @@ -37,7 +35,6 @@ export type CgnMerchantsState = {
};

const INITIAL_STATE: CgnMerchantsState = {
merchantsCount: remoteUndefined,
searchMerchants: remoteUndefined,
onlineMerchants: remoteUndefined,
offlineMerchants: remoteUndefined,
Expand All @@ -51,23 +48,6 @@ const reducer = (
action: Action
): CgnMerchantsState => {
switch (action.type) {
// Merchants count
case getType(cgnMerchantsCount.request):
return {
...state,
merchantsCount: remoteLoading
};
case getType(cgnMerchantsCount.success):
return {
...state,
merchantsCount: remoteReady(action.payload.count)
};
case getType(cgnMerchantsCount.failure):
return {
...state,
merchantsCount: remoteError(action.payload)
};

// Search Merchants
case getType(cgnSearchMerchants.request):
return {
Expand Down Expand Up @@ -162,11 +142,6 @@ export default reducer;
export const cgnMerchantsSelector = (state: GlobalState) =>
state.bonus.cgn.merchants;

export const cgnMerchantsCountSelector = createSelector(
cgnMerchantsSelector,
merchantsState => merchantsState.merchantsCount
);

export const cgnSearchMerchantsSelector = createSelector(
cgnMerchantsSelector,
merchantsState => merchantsState.searchMerchants
Expand Down

0 comments on commit 5048596

Please sign in to comment.