From 029f684fc112ec39e2998bf8e4d02789032c0fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKire?= Date: Tue, 17 Oct 2023 17:10:09 +0200 Subject: [PATCH 01/22] fix: update payment card sdk version and types --- package.json | 2 +- src/services/inplayer.checkout.service.ts | 4 ++-- types/checkout.d.ts | 2 +- yarn.lock | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3c846608e..dad730a44 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "dependencies": { "@adyen/adyen-web": "^5.42.1", "@codeceptjs/allure-legacy": "^1.0.2", - "@inplayer-org/inplayer.js": "^3.13.15", + "@inplayer-org/inplayer.js": "^3.13.19", "classnames": "^2.3.1", "date-fns": "^2.28.0", "dompurify": "^2.3.8", diff --git a/src/services/inplayer.checkout.service.ts b/src/services/inplayer.checkout.service.ts index 84c00da9c..d12deeba4 100644 --- a/src/services/inplayer.checkout.service.ts +++ b/src/services/inplayer.checkout.service.ts @@ -150,11 +150,11 @@ export const updateOrder: UpdateOrder = async ({ order, couponCode }) => { export const directPostCardPayment = async (cardPaymentPayload: CardPaymentData, order: Order) => { const payload = { - number: parseInt(String(cardPaymentPayload.cardNumber).replace(/\s/g, ''), 10), + number: cardPaymentPayload.cardNumber.replace(/\s/g, ''), cardName: cardPaymentPayload.cardholderName, expMonth: cardPaymentPayload.cardExpMonth || '', expYear: cardPaymentPayload.cardExpYear || '', - cvv: parseInt(cardPaymentPayload.cardCVC), + cvv: cardPaymentPayload.cardCVC, accessFee: order.id, paymentMethod: 1, voucherCode: cardPaymentPayload.couponCode, diff --git a/types/checkout.d.ts b/types/checkout.d.ts index d3ee2b4f0..fb591f6ef 100644 --- a/types/checkout.d.ts +++ b/types/checkout.d.ts @@ -105,7 +105,7 @@ export type PaymentStatus = { export type CardPaymentData = { couponCode?: string; cardholderName: string; - cardNumber: string | number; + cardNumber: string; cardExpiry: string; cardExpMonth?: string; cardExpYear?: string; diff --git a/yarn.lock b/yarn.lock index 3486d0577..e34bf9fbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1480,10 +1480,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@inplayer-org/inplayer.js@^3.13.15": - version "3.13.17" - resolved "https://registry.yarnpkg.com/@inplayer-org/inplayer.js/-/inplayer.js-3.13.17.tgz#2312ecdf7761b5634939b1811346dc0fb0c0b00b" - integrity sha512-jj6Qcdf1fOX7QBoEnzwfdL7IhYYVKBLpGnYYqwViyp6Jd3Wded5vh6zVzAvGXjJuaNOWd3hG2fTdL6tNaogRrA== +"@inplayer-org/inplayer.js@^3.13.19": + version "3.13.19" + resolved "https://registry.yarnpkg.com/@inplayer-org/inplayer.js/-/inplayer.js-3.13.19.tgz#064069a83f6d6241067071e846a7ecf60d9f8135" + integrity sha512-KyURtkjOt2cuKzGJfxrc4xMTkvqywWh81u6MpbMmpCOOYnGBsb2z92Uop4M/bVc24gbIGzAqpTttFqruOJLR6w== dependencies: aws-iot-device-sdk "^2.2.6" axios "^0.21.2" From 514f3ca0e592f4a429983acffbb16458b9e48b7a Mon Sep 17 00:00:00 2001 From: Filip Naumovski Date: Mon, 18 Sep 2023 12:32:54 +0200 Subject: [PATCH 02/22] fix: additional profiles PR comments fixes --- public/locales/en/user.json | 3 ++ public/locales/es/user.json | 1 + src/components/Header/Header.tsx | 7 +++++ src/components/ProfileBox/AddNewProfile.tsx | 2 +- src/components/ProfileBox/ProfileBox.tsx | 8 ++++-- .../UserMenu/ProfilesMenu/ProfilesMenu.tsx | 16 +++++++---- src/components/UserMenu/UserMenu.tsx | 28 +++++++++++++------ .../__snapshots__/UserMenu.test.tsx.snap | 8 ++++-- src/containers/Layout/Layout.tsx | 4 +++ src/containers/Profiles/Form.tsx | 2 +- src/containers/Profiles/Profiles.tsx | 4 +-- 11 files changed, 60 insertions(+), 23 deletions(-) diff --git a/public/locales/en/user.json b/public/locales/en/user.json index df7fa12c1..2939bf3d9 100644 --- a/public/locales/en/user.json +++ b/public/locales/en/user.json @@ -61,6 +61,7 @@ "login": { "field_required": "This field is required" }, + "name": "Name", "nav": { "account": "Account", "add_profile": "Add new profile", @@ -123,6 +124,8 @@ "delete_description": "Permanently delete your profile along with all of your watch history and favorites.", "delete_main": "The main profile cannot be deleted because it’s linked to your account's watch history and favorites.", "description": "Profiles allow you to watch content and assemble your own personal collection of favorites.", + "done": "Done", + "edit": "Edit profile", "form_error": "Something went wrong. Please try again later.", "info": "Profile info", "kids": "Kids", diff --git a/public/locales/es/user.json b/public/locales/es/user.json index 85e7b0257..9e82d3a64 100644 --- a/public/locales/es/user.json +++ b/public/locales/es/user.json @@ -61,6 +61,7 @@ "login": { "field_required": "" }, + "name": "", "nav": { "account": "Cuenta", "add_profile": "Añade un nuevo perfil", diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index d0483a221..892e8ddbe 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -1,6 +1,7 @@ import React, { ReactFragment, useState } from 'react'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; +import type { UseMutateFunction } from 'react-query'; import styles from './Header.module.scss'; @@ -52,6 +53,8 @@ type Props = { currentProfile?: Profile; profiles?: Profile[]; profilesEnabled?: boolean; + selectProfile?: UseMutateFunction; + isSelectingProfile?: boolean; accessModel?: AccessModel; }; @@ -82,6 +85,8 @@ const Header: React.FC = ({ currentProfile, profiles, profilesEnabled, + selectProfile, + isSelectingProfile, accessModel, }) => { const { t } = useTranslation('menu'); @@ -145,6 +150,8 @@ const Header: React.FC = ({ currentProfile={currentProfile} profilesEnabled={profilesEnabled} profiles={profiles} + selectProfile={selectProfile} + isSelectingProfile={!!isSelectingProfile} /> diff --git a/src/components/ProfileBox/AddNewProfile.tsx b/src/components/ProfileBox/AddNewProfile.tsx index 1246d0964..9692d4bf3 100644 --- a/src/components/ProfileBox/AddNewProfile.tsx +++ b/src/components/ProfileBox/AddNewProfile.tsx @@ -15,7 +15,7 @@ const AddNewProfile = ({ onClick }: Props) => { const keyDownHandler = (event: React.KeyboardEvent) => (event.key === 'Enter' || event.key === ' ') && onClick(); return ( -
+
diff --git a/src/components/ProfileBox/ProfileBox.tsx b/src/components/ProfileBox/ProfileBox.tsx index 137ce67fa..ff04d8727 100644 --- a/src/components/ProfileBox/ProfileBox.tsx +++ b/src/components/ProfileBox/ProfileBox.tsx @@ -1,5 +1,6 @@ import React from 'react'; import classNames from 'classnames'; +import { useTranslation } from 'react-i18next'; import styles from './ProfileBox.module.scss'; @@ -19,14 +20,17 @@ type Props = { }; const ProfileBox = ({ name, image, editMode = false, onClick, onEdit, selected = false }: Props) => { + const { t } = useTranslation('user'); + const keyDownHandler = (event: React.KeyboardEvent) => (event.key === 'Enter' || event.key === ' ') && onClick(); + return (
-
+
{editMode && ( - + )} diff --git a/src/components/UserMenu/ProfilesMenu/ProfilesMenu.tsx b/src/components/UserMenu/ProfilesMenu/ProfilesMenu.tsx index 9f750a8b9..ffa3647aa 100644 --- a/src/components/UserMenu/ProfilesMenu/ProfilesMenu.tsx +++ b/src/components/UserMenu/ProfilesMenu/ProfilesMenu.tsx @@ -35,7 +35,9 @@ const ProfilesMenu = ({ <>
  • {switchProfilesLabel}
  • {selectingProfile ? ( - +
  • + +
  • ) : ( profiles?.map((profile) => (
  • @@ -54,11 +56,13 @@ const ProfilesMenu = ({ } label={createButtonLabel} />
  • )} -
    +
  • +
    +
  • ); diff --git a/src/components/UserMenu/UserMenu.tsx b/src/components/UserMenu/UserMenu.tsx index 3d5fd6fe8..b9a2a7bcf 100644 --- a/src/components/UserMenu/UserMenu.tsx +++ b/src/components/UserMenu/UserMenu.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import classNames from 'classnames'; +import type { UseMutateFunction } from 'react-query'; import styles from './UserMenu.module.scss'; import ProfilesMenu from './ProfilesMenu/ProfilesMenu'; @@ -12,7 +13,6 @@ import BalanceWallet from '#src/icons/BalanceWallet'; import Exit from '#src/icons/Exit'; import MenuButton from '#components/MenuButton/MenuButton'; import { logout } from '#src/stores/AccountController'; -import { useSelectProfile } from '#src/hooks/useProfiles'; import ProfileCircle from '#src/icons/ProfileCircle'; import type { AccessModel } from '#types/Config'; import type { Profile } from '#types/account'; @@ -26,14 +26,24 @@ type Props = { currentProfile?: Profile; profilesEnabled?: boolean; profiles?: Profile[]; + isSelectingProfile?: boolean; + selectProfile?: UseMutateFunction; }; -const UserMenu = ({ showPaymentsItem, small = false, onClick, accessModel, currentProfile, profilesEnabled, profiles }: Props) => { +const UserMenu = ({ + showPaymentsItem, + small = false, + onClick, + accessModel, + currentProfile, + profilesEnabled, + profiles, + isSelectingProfile, + selectProfile, +}: Props) => { const { t } = useTranslation('user'); const navigate = useNavigate(); - const selectProfile = useSelectProfile(); - const onLogout = useCallback(async () => { if (onClick) { onClick(); @@ -45,13 +55,13 @@ const UserMenu = ({ showPaymentsItem, small = false, onClick, accessModel, curre return (