Skip to content

Commit

Permalink
Merge branch 'bugfix/family-rewards' into feature/UIT-203-family-memb…
Browse files Browse the repository at this point in the history
…ers-redeem
  • Loading branch information
chennara committed Dec 4, 2023
2 parents f4114c2 + 4be1e47 commit 8d06388
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/scan/camera/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useCheckin } from '../_queries/useCheckin';
import { isInRange } from '../_util/isInRange';
import CameraSettings from '../cameraSettings/CameraSettings';
import CameraOverlay from './CameraOverlay';
import { useGetMe } from '../../profile/_queries/useGetMe';

const overlaySettings: TOverlayDimensions = {
cornerLength: 20,
Expand Down
2 changes: 1 addition & 1 deletion src/shopDetail/ShopDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const ShopDetail = ({ route }: TProps) => {
{hasFamilyMembers && !isRedeemStatusLoading && redeemStatus?.redeemable && !redeemStatusError && (
<View ref={rewardsSection}>
<Section title={t('SHOP_DETAIL.WHO_CAN_REDEEM.TITLE')}>
<RedeemFamilyMembers onRedeem={handleRedeemReward} rewardId={reward.id} />
<RedeemFamilyMembers onRedeem={handleRedeemReward} reward={reward} />
</Section>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import { useCallback } from 'react';
import { FamilyMembersPoints } from '../../../_components/family/familyMembersPoints/FamilyMembersPoints';
import { useGetFamilyMembers } from '../../../onboarding/family/_queries';
import { TFamilyMember } from '../../../profile/_models';
import { TReward } from '../../../shop/_models/reward';
import { RedeemButton } from './redeemButton/RedeemButton';

type TProps = {
onRedeem: (member: TFamilyMember) => void;
rewardId: string;
reward: TReward;
};

export const RedeemFamilyMembers = ({ rewardId, onRedeem }: TProps) => {
export const RedeemFamilyMembers = ({ reward, onRedeem }: TProps) => {
const { data: familyMembers = [] } = useGetFamilyMembers();

const RedeemButtonMemoized = useCallback(
({ item: { member } }) => <RedeemButton member={member} onPress={() => onRedeem(member)} rewardId={rewardId} />,
[onRedeem, rewardId],
({ item: { member } }) => <RedeemButton member={member} onPress={() => onRedeem(member)} reward={reward} />,
[onRedeem, reward],
);

return <FamilyMembersPoints ItemRightComponent={RedeemButtonMemoized} members={familyMembers.map(member => ({ member }))} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { useTranslation } from 'react-i18next';

import { BlurredModal, Button, Typography } from '../../../../_components';
import { BlurredModal, Button, Icon, Typography } from '../../../../_components';
import { useToggle } from '../../../../_hooks';
import { TFamilyMember } from '../../../../profile/_models';
import { TReward } from '../../../../shop/_models/reward';
import { useGetRedeemStatus } from '../../../_queries/useGetRedeemStatus';
import * as Styled from './style';

type TProps = {
member: TFamilyMember;
onPress: () => void;
rewardId: string;
reward: TReward;
};

export const RedeemButton = ({ member, onPress, rewardId }: TProps) => {
export const RedeemButton = ({ member, onPress, reward }: TProps) => {
const { t } = useTranslation();
const [showUnredeemableModal, toggleUnredeemableModal] = useToggle(false);

const { error, isLoading } = useGetRedeemStatus({ passHolder: member.passholder, rewardId });
const { error, isLoading } = useGetRedeemStatus({ passHolder: member.passholder, rewardId: reward.id });

if (isLoading) {
return <Button color="primary.700" loading variant="link" />;
Expand Down Expand Up @@ -44,5 +45,9 @@ export const RedeemButton = ({ member, onPress, rewardId }: TProps) => {
);
}

return <Styled.RedeemButton fontSize="small" label={t('SHOP_DETAIL.WHO_CAN_REDEEM.REDEEM')} onPress={onPress} />;
if (reward.online) {
return <Styled.RedeemButton fontSize="small" label={t('SHOP_DETAIL.WHO_CAN_REDEEM.REDEEM')} onPress={onPress} />;
}

return <Icon color="primary.700" name="CircledCheck" />;
};

0 comments on commit 8d06388

Please sign in to comment.