Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Bonus Pagamenti Digitali): [#175142335] Connects Search Bank screen with store and remote data #2266

Merged
merged 60 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
50041d3
[#175011121] add foldering placeholders
fabriziofff Sep 29, 2020
b5524b1
[#175011121] Add screen placeholders
fabriziofff Sep 29, 2020
8b6dc1f
Merge branch 'master' into 175011121-bancomat-screens-placeholder
fabriziofff Sep 29, 2020
f034508
remove screen
fabriziofff Sep 29, 2020
031132a
[#175011879] Wip on bank search and list item component
CrisTofani Sep 30, 2020
a5b2883
[#175011879] Filter list and rework on list item
CrisTofani Oct 1, 2020
80b9634
[#175011879] Minor fix
CrisTofani Oct 1, 2020
eeccfb9
[#175011879] Minor improvements and adds
CrisTofani Oct 2, 2020
09a19fd
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 2, 2020
c3b4f1a
Minor fixes
CrisTofani Oct 2, 2020
c067175
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 2, 2020
0cb9afb
[#175011979] Minor fixes and improvements
CrisTofani Oct 2, 2020
8937e8c
Fix on imports
CrisTofani Oct 2, 2020
44d1e76
[#175011879] Fixes image width / height and minor improvements
CrisTofani Oct 2, 2020
463234b
Fixes
CrisTofani Oct 2, 2020
0bd7147
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 2, 2020
757a6ac
Fixes Missing style
CrisTofani Oct 2, 2020
f4488c3
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 5, 2020
221c4cd
[#175011879] Fixes and review, applies Abi type
CrisTofani Oct 5, 2020
a49991a
[#175011879] Renaming item component
CrisTofani Oct 5, 2020
090b2b0
Reverts navigator
CrisTofani Oct 5, 2020
d3e559f
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 5, 2020
24bf778
Adds some comments on image dimensions calculus
CrisTofani Oct 5, 2020
e71cf8c
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 6, 2020
4d9d303
[#175142335] Connects Search Bank screen with store and remote data
CrisTofani Oct 6, 2020
999fb87
Fixes lint warning
CrisTofani Oct 6, 2020
e12934d
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
CrisTofani Oct 7, 2020
a24462b
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
CrisTofani Oct 7, 2020
9c19eae
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 7, 2020
569b080
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
CrisTofani Oct 7, 2020
84335d3
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 7, 2020
8e7209d
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
CrisTofani Oct 7, 2020
ec24066
Fixes the bank logo dimension calculation and minor fixes
CrisTofani Oct 7, 2020
b789d8c
Merge branch 'master' into 175011879-bank-selection-screen
fabriziofff Oct 7, 2020
315e4c8
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 8, 2020
e924ae6
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 8, 2020
f1be00f
Merge branch 'master' into 175011879-bank-selection-screen
CrisTofani Oct 8, 2020
aea5663
Merge remote-tracking branch 'origin/master' into 175142335-connect-s…
CrisTofani Oct 8, 2020
719688b
Merge remote-tracking branch 'origin/175011879-bank-selection-screen'…
CrisTofani Oct 8, 2020
968ba45
Fixes reducer import
CrisTofani Oct 8, 2020
9f8d9dd
Fixes order abi function
CrisTofani Oct 8, 2020
b794a7c
fixes on typo and state types
CrisTofani Oct 8, 2020
858fbc8
Fixing loading transiction on search bank screen
CrisTofani Oct 8, 2020
6fd1f27
Retry abi search call if it fails
CrisTofani Oct 8, 2020
c6a191a
fixes eslint
CrisTofani Oct 8, 2020
a4b24bb
[#175011879] refactoring
Undermaken Oct 9, 2020
a712d3a
[#175011879] remove test
Undermaken Oct 9, 2020
164ac77
Fixes Logo display conditions
CrisTofani Oct 9, 2020
bd6eb36
Merge remote-tracking branch 'origin/master' into 175011879-bank-sele…
fabriziofff Oct 9, 2020
293ccfe
Merge branch '175011879-bank-selection-screen' into 175142335-connect…
fabriziofff Oct 9, 2020
574cf97
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
fabriziofff Oct 9, 2020
bb71f33
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
fabriziofff Oct 9, 2020
0c53610
Update locales/en/index.yml
CrisTofani Oct 9, 2020
c3b653c
Merge branch 'master' into 175142335-connect-search-bank-screen-redux
CrisTofani Oct 9, 2020
1b720bd
minor fixes
CrisTofani Oct 9, 2020
c29f535
Fixes search bug
CrisTofani Oct 9, 2020
54466dd
Fixes the retry logic on abi load error
CrisTofani Oct 9, 2020
869fc5d
Merge branch 'master' of github.com:pagopa/io-app into 175142335-conn…
CrisTofani Oct 9, 2020
0014914
fixes imports for selectors
CrisTofani Oct 9, 2020
90cb16a
[#175142335] refactor
Undermaken Oct 9, 2020
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
3 changes: 2 additions & 1 deletion locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ wallet:
text2: " on which you have an active Pagobancomat card. Otherwise we will look for all the cards associated with you: by continuing you accept the "
text3: information on the processing of personal data
bankName: Name of the bank
noName: Name not found
noName: Name unavailable
loading: Loading bank list...
accessibility:
cardsPreview: Payment methods' preview. Activate to navigate to the the list of payment methods.
transactionListItem:
Expand Down
3 changes: 2 additions & 1 deletion locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ wallet:
text2: " su cui hai un carta Pagobancomat attiva. Altrimenti cercheremo tutte le carta associate a te: proseguendo accetti l’"
text3: informativa sul trattamento dei dati personali
bankName: Denominazione della banca
noName: Nome non trovato
noName: Nome non disponibile
loading: Carico la lista delle banche...
accessibility:
cardsPreview: Anteprima dei metodi di pagamento. Attiva per accedere alla lista dei tuoi metodi
transactionListItem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import IconFont from "../../../../../components/ui/IconFont";
type Props = {
bank: Abi;
inList: boolean;
onPress: () => void;
onPress: (abi: string) => void;
};

const BASE_IMG_H = 40;
Expand Down Expand Up @@ -83,6 +83,7 @@ export const BankPreviewItem: React.FunctionComponent<Props> = (
resizeMode: "contain"
};

const onItemPress = () => props.bank.abi && props.onPress(props.bank.abi);
const bankName = props.bank.name || I18n.t("wallet.searchAbi.noName");
const bankLogo = (
<View style={styles.boundaryImage}>
Expand All @@ -93,7 +94,7 @@ export const BankPreviewItem: React.FunctionComponent<Props> = (
);

return props.inList ? (
<ListItem style={styles.flexRow} onPress={props.onPress}>
<ListItem style={styles.flexRow} onPress={onItemPress}>
<View style={styles.listItem}>
<View spacer={true} />
{bankLogo}
Expand All @@ -109,7 +110,7 @@ export const BankPreviewItem: React.FunctionComponent<Props> = (
<ButtonDefaultOpacity
white={true}
style={styles.gridItem}
onPress={props.onPress}
onPress={onItemPress}
>
{bankLogo}
<View spacer={true} />
Expand Down
150 changes: 0 additions & 150 deletions ts/features/wallet/onboarding/bancomat/screens/SearchBankScreen.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { Content, Input, Item, Text, View } from "native-base";
import * as React from "react";
import {
SafeAreaView,
FlatList,
ListRenderItemInfo,
ActivityIndicator
} from "react-native";
import { debounce } from "lodash";
import I18n from "../../../../../../i18n";
import { Body } from "../../../../../../components/core/typography/Body";
import { Link } from "../../../../../../components/core/typography/Link";
import { Label } from "../../../../../../components/core/typography/Label";
import IconFont from "../../../../../../components/ui/IconFont";
import FooterWithButtons from "../../../../../../components/ui/FooterWithButtons";
import { Abi } from "../../../../../../../definitions/pagopa/bancomat/Abi";
import { sortAbiByName } from "../../utils/abi";
import { BankPreviewItem } from "../../components/BankPreviewItem";
import {
cancelButtonProps,
confirmButtonProps
} from "../../../../../bonus/bonusVacanze/components/buttons/ButtonConfigurations";
import { IOColors } from "../../../../../../components/core/variables/IOColors";

type Props = {
bankList: ReadonlyArray<Abi>;
isLoading: boolean;
onItemPress: (abi: string) => void;
openTosModal: () => void;
onCancel: () => void;
onContinue: () => void;
};

export const SearchBankComponent: React.FunctionComponent<Props> = (
props: Props
) => {
const [searchText, setSearchText] = React.useState("");
const [filteredList, setFilteredList] = React.useState<ReadonlyArray<Abi>>(
[]
);
const [isSearchStarted, setIsSearchStarted] = React.useState(false);

const performSearch = (text: string, bankList: ReadonlyArray<Abi>) => {
if (text.length === 0) {
setFilteredList([]);
setIsSearchStarted(false);
return;
}
setIsSearchStarted(true);
const resultList = bankList.filter(
bank =>
(bank.abi && bank.abi.toLowerCase().indexOf(text.toLowerCase()) > -1) ||
(bank.name && bank.name.toLowerCase().indexOf(text.toLowerCase()) > -1)
);
setFilteredList(sortAbiByName(resultList));
};
const debounceRef = React.useRef(debounce(performSearch, 300));

React.useEffect(() => {
debounceRef.current(searchText, props.bankList);
}, [searchText, props.bankList]);

const handleFilter = (text: string) => {
setSearchText(text);
};

const keyExtractor = (bank: Abi, index: number): string =>
bank.abi ? bank.abi : `abi_item_${index}`;

const renderListItem = (isList: boolean) => (
info: ListRenderItemInfo<Abi>
) => (
<BankPreviewItem
bank={info.item}
inList={isList}
onPress={props.onItemPress}
/>
);

return (
<SafeAreaView style={{ flex: 1 }}>
<Content style={{ flex: 1 }}>
{!isSearchStarted && (
<>
<View spacer={true} large={true} />
<Body>
<Text bold={true}>
{I18n.t("wallet.searchAbi.description.text1")}
</Text>
{I18n.t("wallet.searchAbi.description.text2")}
<Link onPress={props.openTosModal}>
{I18n.t("wallet.searchAbi.description.text3")}
</Link>
</Body>
</>
)}
<View spacer={true} />
{!props.isLoading && (
<Label color={"bluegrey"}>
{I18n.t("wallet.searchAbi.bankName")}
</Label>
)}
<Item>
<Input
value={searchText}
onChangeText={handleFilter}
disabled={props.isLoading}
placeholderTextColor={IOColors.bluegreyLight}
placeholder={
props.isLoading ? I18n.t("wallet.searchAbi.loading") : undefined
}
/>
{!props.isLoading && <IconFont name="io-search" />}
</Item>
<View spacer={true} />
{props.isLoading ? (
<>
<View spacer={true} large={true} />
<ActivityIndicator
color={"black"}
size={"large"}
accessible={false}
importantForAccessibility={"no-hide-descendants"}
accessibilityElementsHidden={true}
/>
</>
) : (
<FlatList
data={filteredList}
renderItem={renderListItem(true)}
keyExtractor={keyExtractor}
/>
)}
</Content>
<FooterWithButtons
type={"TwoButtonsInlineThird"}
leftButton={cancelButtonProps(
props.onCancel,
I18n.t("global.buttons.cancel")
)}
rightButton={confirmButtonProps(
props.onContinue,
I18n.t("global.buttons.continue")
)}
/>
</SafeAreaView>
);
};
Loading