-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from cultuurnet/feature/UIT-205-family-member…
…-scan-summary Family members scan summary
- Loading branch information
Showing
22 changed files
with
221 additions
and
69 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
src/_components/family/familyMemberPoints/FamilyMemberPoints.tsx
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
src/_components/family/familyMembersPoints/FamilyMembersPoints.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ReactElement } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { FlatList, StyleProp, View, ViewStyle } from 'react-native'; | ||
|
||
import { getAvatarByNameOrDefault } from '../../../_utils'; | ||
import { TFamilyMember } from '../../../profile/_models'; | ||
import Typography from '../../typography/Typography'; | ||
import * as Styled from './style'; | ||
|
||
type TProps<T extends { member: TFamilyMember }> = { | ||
ItemRightComponent?: ({ item }: { item: T }) => ReactElement; | ||
ItemSubtitle?: ({ item }: { item: T }) => ReactElement; | ||
members: Array<T>; | ||
style?: StyleProp<ViewStyle>; | ||
}; | ||
|
||
export const FamilyMembersPoints = <T extends { member: TFamilyMember }>({ | ||
members, | ||
ItemRightComponent, | ||
ItemSubtitle, | ||
style, | ||
}: TProps<T>) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<FlatList | ||
ItemSeparatorComponent={Styled.Divider} | ||
contentContainerStyle={style} | ||
data={members} | ||
keyExtractor={item => item.member.uitpasNumber} | ||
renderItem={({ item }) => ( | ||
<Styled.Item> | ||
<Styled.Avatar resizeMode="contain" source={getAvatarByNameOrDefault(item.member.icon)} /> | ||
<Styled.ItemBody> | ||
<Typography fontStyle="bold" numberOfLines={1}> | ||
{item.member.passholder.firstName} | ||
{item.member.mainFamilyMember ? ` ${t('SHOP_DETAIL.WHO_CAN_REDEEM.YOU')}` : ''} | ||
</Typography> | ||
{ItemSubtitle ? ( | ||
<ItemSubtitle item={item} /> | ||
) : ( | ||
<Typography color="primary.700" fontStyle="semibold" numberOfLines={1} size="small"> | ||
{t('SHOP_DETAIL.WHO_CAN_REDEEM.POINTS', { count: item.member.passholder.points })} | ||
</Typography> | ||
)} | ||
</Styled.ItemBody> | ||
{ItemRightComponent && ( | ||
<View> | ||
<ItemRightComponent item={item} /> | ||
</View> | ||
)} | ||
</Styled.Item> | ||
)} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,78 @@ | ||
import { useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
|
||
import { SafeAreaView } from '../../_components'; | ||
import { TRootStackNavigationProp } from '../../_routing'; | ||
import { Check } from '../../_assets/images'; | ||
import { DiagonalSplitView, FamilyMembersPoints, Typography } from '../../_components'; | ||
import { TRootStackNavigationProp, TRootStackRouteProp } from '../../_routing'; | ||
import { TFamilyMember } from '../../profile/_models'; | ||
import { TFamilyScanResponse } from './_models'; | ||
import { CheckinErrorIcon, CheckinSuccessIcon } from './icons'; | ||
import * as Styled from './style'; | ||
|
||
type TProps = { | ||
navigation: TRootStackNavigationProp<'FamilyCheckinSummary'>; | ||
route: TRootStackRouteProp<'FamilyCheckinSummary'>; | ||
}; | ||
|
||
export const FamilyCheckinSummary = ({ navigation }: TProps) => { | ||
type FamilyMembersSummaryItem = { item: { member: TFamilyMember; response: TFamilyScanResponse } }; | ||
|
||
export const FamilyCheckinSummary = ({ navigation, route }: TProps) => { | ||
const { memberResponses } = route.params; | ||
|
||
const { t } = useTranslation(); | ||
const { top } = useSafeAreaInsets(); | ||
|
||
const FamilyMembersSummary = useCallback(() => { | ||
const renderIcon = ({ item: { response } }: FamilyMembersSummaryItem) => { | ||
if (response.type === 'success') { | ||
return <CheckinSuccessIcon numberOfPoints={response.value.addedPoints} />; | ||
} | ||
return <CheckinErrorIcon />; | ||
}; | ||
|
||
const renderErrorDescription = ({ item: { member, response } }: FamilyMembersSummaryItem) => { | ||
if (response.type === 'error') { | ||
return <Typography size="small">{response.error.endUserMessage.nl}</Typography>; | ||
} | ||
return ( | ||
<Typography color="primary.700" fontStyle="semibold" numberOfLines={1} size="small"> | ||
{t('SHOP_DETAIL.WHO_CAN_REDEEM.POINTS', { count: member.passholder.points })} | ||
</Typography> | ||
); | ||
}; | ||
|
||
return ( | ||
<FamilyMembersPoints | ||
ItemRightComponent={renderIcon} | ||
ItemSubtitle={renderErrorDescription} | ||
members={memberResponses} | ||
style={{ paddingHorizontal: 16 }} | ||
/> | ||
); | ||
}, [memberResponses, t]); | ||
|
||
return ( | ||
<SafeAreaView backgroundColor="neutral.0" edges={['bottom']} isScrollable={false}> | ||
<Styled.Body /> | ||
<Styled.CloseButton | ||
label={t('SCAN.FAMILY_MEMBERS.SUMMARY.CLOSE')} | ||
onPress={() => navigation.reset({ index: 0, routes: [{ name: 'MainNavigator', params: { screen: 'Profile' } }] })} | ||
<> | ||
<DiagonalSplitView | ||
bottomContent={ | ||
<Styled.Body> | ||
<FamilyMembersSummary /> | ||
<Styled.CloseButton | ||
label={t('SCAN.FAMILY_MEMBERS.SUMMARY.CLOSE')} | ||
onPress={() => navigation.reset({ index: 0, routes: [{ name: 'MainNavigator', params: { screen: 'Profile' } }] })} | ||
/> | ||
</Styled.Body> | ||
} | ||
bottomContentStyle={{ paddingLeft: 0, paddingRight: 0 }} | ||
topContent={null} | ||
/> | ||
</SafeAreaView> | ||
<Styled.Header style={{ top: top + 16 }}> | ||
<Styled.HeaderImage source={Check} /> | ||
<Styled.HeaderTitle color="primary.700" fontStyle="bold" size="large"> | ||
{t('SCAN.FAMILY_MEMBERS.SUMMARY.DESCRIPTION')} | ||
</Styled.HeaderTitle> | ||
</Styled.Header> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { TApiError } from '../../../_http'; | ||
import { TCheckInResponse } from '../../_models'; | ||
|
||
export type TFamilyScanResponse = { type: 'success'; value: TCheckInResponse } | { error: TApiError; type: 'error' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Typography } from '../../../_components'; | ||
import * as Styled from './style'; | ||
|
||
export const CheckinErrorIcon = () => { | ||
return ( | ||
<Styled.Container type="error"> | ||
<Typography color="error.500" fontStyle="bold" size="large"> | ||
! | ||
</Typography> | ||
</Styled.Container> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/scan/familyCheckinSummary/icons/CheckinSuccessIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Typography } from '../../../_components'; | ||
import * as Styled from './style'; | ||
|
||
type TProps = { | ||
numberOfPoints: number; | ||
}; | ||
|
||
export const CheckinSuccessIcon = ({ numberOfPoints }: TProps) => { | ||
return ( | ||
<Styled.Container type="success"> | ||
<Typography color="primary.700" fontStyle="bold" size="small"> | ||
+{numberOfPoints} | ||
</Typography> | ||
</Styled.Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './CheckinErrorIcon'; | ||
export * from './CheckinSuccessIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import styled from 'styled-components/native'; | ||
|
||
export const Container = styled.View<{ type: 'success' | 'error' }>` | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 20px; | ||
border: ${({ type, theme }) => `4px solid ${type === 'success' ? theme.palette.primary['200'] : theme.palette.error['200']}`}; | ||
justify-content: center; | ||
align-items: center; | ||
`; |
Oops, something went wrong.