Skip to content

Commit

Permalink
Next Release 1.28.0 (#611)
Browse files Browse the repository at this point in the history
* [VAS-418] feat: Align tos page with design (#579)

* Bump to version 1.26.0-1-next

* merge

* fix: PaymentNoticesDetailPage.tsx posteAuth (#577)

* Bump to version 1.26.0-2-next

* fix github.head_ref in the action

* feat: Review channel flow (#573)

* [VAS-998] feat: introducing ops review from channel

* [VAS-998] feat: Updated ops review modal management for channels

* [VAS-997] changed channels page structured and integrated new getChannels API

* [VAS-997] updated tests

* [VAS-998] feat: Updated addEdit, details and tests

* [VAS-998] feat: Updated tests, introduced common header to avoid duplicates

* [VAS-998] feat: temporary rollback test

* [VAS-998] feat: Update GetChannelAlert.test.tsx

* [VAS-998] feat: Update ci_code_review.yml

* [VAS-998] feat: Updated GetChannelAlert.test.tsx

* [VAS-997] fix after merge with VAS-998

* fix client after merge

* [VAS-997] fix: Width row station name

* [VAS-997] fix: Improve createdBy/modifiedBy station detail

* [VAS-997] fix: Handle change page channels table

* [VAS-997] feat: Add alert channels details

* [VAS-997] chore: Refactor detail button station detail

* [VAS-997] feat: Refactor ChannelDetail component & improve UI

* [VAS-997] feat: New translations

* [VAS-997] fix: Refactor & format + fix translations

* [VAS-997] feat: Delete unused component

* [VAS-997] fix: Wrapper status chip translation for operators

* [VAS-997] chore: Clean code

* fixed client

* [VAS-997] fixed unit tests

* [VAS-997] add unit tests

* [VAS-997] improve tests

* [VAS-997] improve coverage

---------

Co-authored-by: Alessio Cialini <alessio.cialini@emeal.nttdata.com>
Co-authored-by: svariant <samuele.varianti@nttdata.com>
Co-authored-by: Samuele Varianti <128470180+svariant@users.noreply.github.com>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* Bump to version 1.26.0-3-next

* [VAS-1123] feat: Remove unused Station and Channel API (#574)

* [VAS-998] feat: introducing ops review from channel

* [VAS-998] feat: Updated ops review modal management for channels

* [VAS-997] changed channels page structured and integrated new getChannels API

* [VAS-997] updated tests

* [VAS-998] feat: Updated addEdit, details and tests

* [VAS-998] feat: Updated tests, introduced common header to avoid duplicates

* [VAS-998] feat: temporary rollback test

* [VAS-998] feat: Update GetChannelAlert.test.tsx

* [VAS-998] feat: Update ci_code_review.yml

* [VAS-998] feat: Updated GetChannelAlert.test.tsx

* [VAS-997] fix after merge with VAS-998

* fix client after merge

* [VAS-1123] replace old merged API with new get Stations and Channels

* [VAS-1123] fixed tests

* [VAS-1123] fix after merge

* [VAS-1123] fix test after merge

* [VAS-1123] removed useless file and added tests

* improve coverage

* improve for coverage

---------

Co-authored-by: Alessio Cialini <alessio.cialini@emeal.nttdata.com>
Co-authored-by: Samuele Varianti <128470180+svariant@users.noreply.github.com>

* Bump to version 1.26.0-4-next

* [VAS-1104] feat: New bundle status for available but expired bundles (#580)

* [VAS-1104] feat: New bundle status for available but expired bundles

* [VAS-1104] feat: Add alert bundle expired

* [VAS-1104] chore: BE openapi

* [VAS-1104] feat: Changes after UI designer advice

* [VAS-1104] chore: Fix unit tests

* Bump to version 1.26.0-5-next

* [VAS-1103] feat: Add new field pspBusinessName to bundle details (#583)

* [VAS-1103] feat: Add new field pspBusinessName to bundle details

* Update src/locale/it.json

Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* [VAS-1103] fix: Unit tests

---------

Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* Bump to version 1.26.0-6-next

* [VAS-1095] feat: e2e PSP's & CI's actions on private bundle (#570)

* [VAS-1096] feat: Define publicBundles e2e tests

* [VAS-1096] feat: e2e validate bundle api

* [VAS-1096] feat: Implement temporary new state for ci bundles + uniform code

* [VAS-1096] feat: Conclude publicBundles e2e tests

* [VAS-1095] feat: e2e private bundles

* [VAS-1096] chore: fix unit tests

* [VAS-1096] feat: Re-enable e2e paraller workers

* [VAS-1095] fix: Click on popup

* [VAS-1095] feat: Add control on login page

* [VAS-1095] feat: Improve e2e tests

* [VAS-1095] fix: Public bundles e2e

* [VAS-1095] chore: Max number of failures e2e

* [VAS-1095] fix: e2e subkey env name

* {VAS-1095] fix: e2e Added condition

* [VAS-1095] fix: Added timeout e2e

* [VAS-1095] fix: Increase timeout

* [VAS-1095] fix: Changed timeouts

* [VAS-1095] fix: Increase timeout

* [VAS-1095] chore: Delete obsolete puppeteer int test

* [VAS-1095] fix: Improved check return homepage

* [VAS-1095] timeout

* [VAS-1095] fix: e2e change browser driver to firefox + timeout fixes

* [VAS-1095] feat: Add delete bundle api to cleanup

* [VAS-1095] chore: Add log response

* [VAS-1095] feat: Add subkey int test keyvault

* [VAS-1095] notify

* [VAS-1095] fix: e2e clean up

* [VAS-1095] special secret

* [VAS-1095] debug

* [VAS-1095] secret

* [VAS-1095] create jwt

* [VAS-1095] gitignore

* [VAS-1095] github pages

* [VAS-1095] chore: Re commit tsconfig

* [VAS-1095] fix: e2e static analysis

* [VAS-1095] chore: Sonar cpd exclusion e2e

---------

Co-authored-by: Jacopo <jacopo.carlini@gmail.com>

* Bump to version 1.26.0-7-next

* chore: Merge main into next (#585)

* build(deps-dev): Bump eslint-plugin-react from 7.30.0 to 7.34.3

Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.0 to 7.34.3.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](jsx-eslint/eslint-plugin-react@v7.30.0...v7.34.3)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1 (#565)

* build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1

Bumps [react-use-scrollspy](https://github.com/Purii/react-use-scrollspy) from 3.0.2 to 3.1.1.
- [Release notes](https://github.com/Purii/react-use-scrollspy/releases)
- [Changelog](https://github.com/Purii/react-use-scrollspy/blob/main/CHANGELOG.md)
- [Commits](Purii/react-use-scrollspy@v3.0.2...v3.1.1)

---
updated-dependencies:
- dependency-name: react-use-scrollspy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1

Bumps [react-use-scrollspy](https://github.com/Purii/react-use-scrollspy) from 3.0.2 to 3.1.1.
- [Release notes](https://github.com/Purii/react-use-scrollspy/releases)
- [Changelog](https://github.com/Purii/react-use-scrollspy/blob/main/CHANGELOG.md)
- [Commits](Purii/react-use-scrollspy@v3.0.2...v3.1.1)

---
updated-dependencies:
- dependency-name: react-use-scrollspy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* [react-use-scrollspy-3] delete branch

* [react-use-scrollspy-3] if condition delete branch

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacopo <jacopo.carlini@gmail.com>

* build(deps-dev): Bump @babel/core from 7.24.4 to 7.24.7 (#567)

Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.24.4 to 7.24.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.24.7/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* build(deps): Bump @mui/system from 5.15.15 to 5.15.20 (#566)

Bumps [@mui/system](https://github.com/mui/material-ui/tree/HEAD/packages/mui-system) from 5.15.15 to 5.15.20.
- [Release notes](https://github.com/mui/material-ui/releases)
- [Changelog](https://github.com/mui/material-ui/blob/v5.15.20/CHANGELOG.md)
- [Commits](https://github.com/mui/material-ui/commits/v5.15.20/packages/mui-system)

---
updated-dependencies:
- dependency-name: "@mui/system"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* added missing call for station in status TO_FIX_UPDATE (#581)

Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* Bump to version 1.26.1 [skip ci]

* Pin actions/checkout action to ee0669b (#582)

Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>

* fix delete branch

* Update README.md

* Update README.md

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>
Co-authored-by: gioelemella <128155546+gioelemella@users.noreply.github.com>
Co-authored-by: pagopa-github-bot <github-bot@pagopa.it>
Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com>

* Bump to version 1.26.1-1-next

* [VAS-1133] feat: Add new api key for printPaymentsNotice product (#584)

* [VAS-1133] feat: Introduce print notice api key list element

* [VAS-1133] fix: Api key products psp

* [VAS-1133] feat: Refactor api key products

* [VAS-1133] feat: Introduce flag print notice for api keys

* [VAS-1133] chore: Api key unit test coverage

* Bump to version 1.26.1-2-next

* fix: Updated AddEditCommissionBundleForm.tsx to call brokerDelegation as an institution (#587)

* Bump to version 1.26.1-3-next

* [VAS-1070] feat; Change station and channel detail view on pending update (#586)

* [VAS-1070] improved station API and removed wrapper status value from body

* [VAS-1070] integrated new station and channel detail API and removed unused ones.

* [VAS-1070] fix unit tests

* [VAS-1070] handled station and channel with pending update

* [VAS-1070] added common component for alert in station and channel detail page

* [VAS-1070] removed created by when undefined

* [VAS-1070] fix unit tests

* [VAS-1070] fix title

* [VAS-1070] rename variable

* Bump to version 1.26.3-1-next

* notify

* fix missing translate (#596)

* Bump to version 1.26.4-1-next

* fix: Bugs found before release (#597)

* fix: Bundle -> hide delete & disable invite EC buttons if bundle is expired

* fix: Newconnectivity select channels

* fix: Margin top checkbox channels edit page

* fix: Unit tests

* empty commit

* Bump to version 1.26.4-2-next

* [VAS-1146] feat: Implement new boolean "cart" for bundles (#605)

* [VAS-1146] feat: Implement new switch for cart bool in bundle add/edit page

* [VAS-1146] chore: Unit tests

* [VAS-1146] chore: Update packagejson openapi command

* empty commit

* [VAS-1146] fix: Unit tests

* [VAS-1146] feat: Swap api call getChannelsDetails with primitive version check on list elements

* [VAS-1146] feat: Improve unit test

* [VAS-1146] fix: Unit tests

* [VAS-1146] fix: Unit tests

* [VAS-1146] feat: Add cart bool to bundle details drawer

* fix unit test

* [VAS-1146] feat: Improve code

* Bump to version 1.26.4-3-next

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Samuele Varianti <128470180+svariant@users.noreply.github.com>
Co-authored-by: pagopa-github-bot <github-bot@pagopa.it>
Co-authored-by: Jacopo <jacopo.carlini@gmail.com>
Co-authored-by: Alessio Cialini <63233981+alessio-cialini@users.noreply.github.com>
Co-authored-by: Alessio Cialini <alessio.cialini@emeal.nttdata.com>
Co-authored-by: svariant <samuele.varianti@nttdata.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com>
  • Loading branch information
9 people authored Jul 15, 2024
1 parent 9b42c5d commit af2b091
Show file tree
Hide file tree
Showing 9 changed files with 840 additions and 727 deletions.
4 changes: 3 additions & 1 deletion src/locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,9 @@
"paymentOnlyDigitalStamp": "Pagamento solo marca da bollo",
"from": "Da",
"to": "A",
"all": "Tutti"
"all": "Tutti",
"cart": "Gestione carrello di pagamenti",
"cartInfo": "La gestione del carrello è possibile soltanto per i canali configurati con le primitive in versione 2"
},
"addTaxonomies": {
"subTitle": "Cerca i servici di incasso sfogliando il catalogo oppure carica una lista di codici.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const toNewFormData = (
validityDateFrom: data?.validityDateFrom ?? minDateTomorrow(),
validityDateTo: data?.validityDateTo ?? minDateTomorrow(),
pspBusinessName: selectedParty?.description ?? '',
cart: data?.cart
});

function getABIOrBIC(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable functional/no-let */
/* eslint-disable complexity */
/* eslint-disable sonarjs/cognitive-complexity */
import { MenuBook } from '@mui/icons-material';
import {InfoOutlined, MenuBook} from '@mui/icons-material';
import BookmarkAddIcon from '@mui/icons-material/BookmarkAdd';
import DateRangeIcon from '@mui/icons-material/DateRange';
import EuroIcon from '@mui/icons-material/Euro';
Expand All @@ -18,38 +18,40 @@ import {
Radio,
RadioGroup,
Select,
Switch,
TextField,
TextFieldProps,
Tooltip,
Typography,
} from '@mui/material';
import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { theme } from '@pagopa/mui-italia';
import { useErrorDispatcher, useLoading } from '@pagopa/selfcare-common-frontend';
import { FormikProps } from 'formik';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { NumericFormat } from 'react-number-format';
import { BundleRequest } from '../../../../api/generated/portal/BundleRequest';
import { Delegation } from '../../../../api/generated/portal/Delegation';
import { TypeEnum } from '../../../../api/generated/portal/PSPBundleResource';
import { PaymentTypes } from '../../../../api/generated/portal/PaymentTypes';
import { Touchpoints } from '../../../../api/generated/portal/Touchpoints';
import {DesktopDatePicker, LocalizationProvider} from '@mui/x-date-pickers';
import {AdapterDateFns} from '@mui/x-date-pickers/AdapterDateFns';
import {theme} from '@pagopa/mui-italia';
import {useErrorDispatcher, useLoading} from '@pagopa/selfcare-common-frontend';
import {FormikProps} from 'formik';
import {useEffect, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {NumericFormat} from 'react-number-format';
import {BundleRequest} from '../../../../api/generated/portal/BundleRequest';
import {Delegation} from '../../../../api/generated/portal/Delegation';
import {TypeEnum} from '../../../../api/generated/portal/PSPBundleResource';
import {PaymentTypes} from '../../../../api/generated/portal/PaymentTypes';
import {Touchpoints} from '../../../../api/generated/portal/Touchpoints';
import FormSectionTitle from '../../../../components/Form/FormSectionTitle';
import { useFlagValue } from '../../../../hooks/useFeatureFlags';
import { useOrganizationType } from "../../../../hooks/useOrganizationType";
import { useUserRole } from "../../../../hooks/useUserRole";
import { Party } from '../../../../model/Party';
import { sortPaymentType } from '../../../../model/PaymentType';
import { ConfigurationStatus } from '../../../../model/Station';
import { useAppSelector } from '../../../../redux/hooks';
import { partiesSelectors } from '../../../../redux/slices/partiesSlice';
import { getTouchpoints } from '../../../../services/bundleService';
import { getChannels } from '../../../../services/channelService';
import { getPaymentTypes } from '../../../../services/configurationService';
import { getBrokerDelegation } from '../../../../services/institutionService';
import { addCurrentBroker } from '../../../../utils/channel-utils';
import { LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, LOADING_TASK_GET_CHANNELS_IDS, } from '../../../../utils/constants';
import {useFlagValue} from '../../../../hooks/useFeatureFlags';
import {useOrganizationType} from '../../../../hooks/useOrganizationType';
import {Party} from '../../../../model/Party';
import {sortPaymentType} from '../../../../model/PaymentType';
import {ConfigurationStatus} from '../../../../model/Station';
import {useAppSelector} from '../../../../redux/hooks';
import {partiesSelectors} from '../../../../redux/slices/partiesSlice';
import {getTouchpoints} from '../../../../services/bundleService';
import {getChannels} from '../../../../services/channelService';
import {getPaymentTypes} from '../../../../services/configurationService';
import {getBrokerDelegation} from '../../../../services/institutionService';
import {addCurrentBroker} from '../../../../utils/channel-utils';
import {LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, LOADING_TASK_GET_CHANNELS_IDS,} from '../../../../utils/constants';
import {WrapperChannelResource} from '../../../../api/generated/portal/WrapperChannelResource';

type Props = {
formik: FormikProps<BundleRequest>;
Expand All @@ -59,19 +61,19 @@ type Props = {

const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
const {t} = useTranslation();
const {userIsPspDirectAdmin} = useUserRole();
const {orgInfo, orgIsPspDirect} = useOrganizationType();
const {orgIsPspDirect} = useOrganizationType();
const setLoading = useLoading(LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS);
const setLoadingChannels = useLoading(LOADING_TASK_GET_CHANNELS_IDS);
const addError = useErrorDispatcher();
const isPrivateEnabled = useFlagValue("commission-bundles-private");
const isPublicEnabled = useFlagValue("commission-bundles-public");
const isPrivateEnabled = useFlagValue('commission-bundles-private');
const isPublicEnabled = useFlagValue('commission-bundles-public');
const selectedParty = useAppSelector(partiesSelectors.selectPartySelected);

const [paymentOptions, setPaymentOptions] = useState<PaymentTypes>();
const [touchpointList, setTouchpointList] = useState<Touchpoints>();
const [brokerDelegationList, setBrokerDelegationList] = useState<Array<Delegation>>([]);
const [channelsId, setChannelsId] = useState<Array<string>>([]);
const [channels, setChannels] = useState<Array<WrapperChannelResource>>([]);
const [isChannelV2, setIsChannelV2] = useState<boolean>(false);

const inputGroupStyle = {
borderRadius: 1,
Expand All @@ -86,9 +88,10 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
getChannels({status: ConfigurationStatus.ACTIVE, brokerCode: selectedBrokerCode})
.then((data) => {
if (data?.channels && data.channels.length > 0) {
setChannelsId(data.channels.map(ch => ch.channel_code));
setChannels([...data.channels]);
handleIsChannelV2(formik.values.idChannel, [...data.channels]);
} else {
setChannelsId([]);
setChannels([]);
addError({
id: 'GET_BROKER_DELEGATIONS_DATA',
blocking: false,
Expand All @@ -104,7 +107,7 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
}
})
.catch((error) => {
setChannelsId([]);
setChannels([]);
addError({
id: 'GET_CHANNEL_IDS_DATA',
blocking: false,
Expand Down Expand Up @@ -135,15 +138,18 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
if (touchpoints) {
setTouchpointList(touchpoints);
}
let listBroker = brokerDelegation?.delegation_list ? [...brokerDelegation.delegation_list] : [];
let listBroker = brokerDelegation?.delegation_list
? [...brokerDelegation.delegation_list]
: [];
if (orgIsPspDirect) {
listBroker = addCurrentBroker(listBroker, selectedParty as Party);
}

if (listBroker.length > 0) {
setBrokerDelegationList(listBroker);
if (isEdit && idBrokerPsp) {
const brokerTaxCode = listBroker?.find(
(el) => el.broker_id === idBrokerPsp
(el) => el.broker_tax_code === idBrokerPsp
)?.broker_tax_code;
if (brokerTaxCode) {
getChannelsByBrokerCode(brokerTaxCode);
Expand Down Expand Up @@ -185,24 +191,42 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {

const shouldDisableDate = (date: Date) => date < new Date();

function handleBrokerCodesSelection(
value: string | null | undefined
) {
function handleBrokerCodesSelection(value: string | null | undefined) {
formik.setFieldValue('idChannel', '');
handleIsChannelV2();
if (value === null || value === undefined) {
formik.setFieldValue('idBrokerPsp', '');
setChannelsId([]);
setChannels([]);
} else {
const broker = brokerDelegationList?.find(
(el) => el.broker_name === value
);
formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? "");
const broker = brokerDelegationList?.find((el) => el.broker_name === value);
formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? '');
if (broker?.broker_tax_code) {
getChannelsByBrokerCode(broker?.broker_tax_code);
}
}
}

const handleIsChannelV2 = (
channelCode?: string | null,
channelList?: Array<WrapperChannelResource>
) => {
let bool = false;
if (channelCode) {
const arrayChannel = channelList ?? channels;
bool = arrayChannel.find((el) => el.channel_code === channelCode)?.primitive_version === 2;
}

setIsChannelV2(bool);
if (!bool) {
formik.setFieldValue('cart', false);
}
};

const handleChangeChannel = (value: string | null) => {
formik.handleChange('idChannel')(value ?? '');
handleIsChannelV2(value);
};

return (
<>
<Paper
Expand Down Expand Up @@ -491,7 +515,11 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
?.map((el) => el?.broker_name ?? '')
?.sort((a, b) => a.localeCompare(b))}
disabled={!(brokerDelegationList && brokerDelegationList.length > 0)}
value={brokerDelegationList?.find(el => el.broker_tax_code === formik.values.idBrokerPsp)?.broker_name ?? ""}
value={
brokerDelegationList?.find(
(el) => el.broker_tax_code === formik.values.idBrokerPsp
)?.broker_name ?? ''
}
onChange={(_, value) => {
handleBrokerCodesSelection(value);
}}
Expand All @@ -516,18 +544,9 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
<Autocomplete
disablePortal
id="idChannel"
options={
// eslint-disable-next-line functional/immutable-data
channelsId.sort((a, b) => a.localeCompare(b))
}
disabled={!(channelsId && channelsId.length > 0)}
onChange={(_event, value) => {
if (value === null) {
formik.setFieldValue('idChannel', '');
} else {
formik.handleChange('idChannel')(value);
}
}}
options={channels.map((el) => el.channel_code).sort((a, b) => a.localeCompare(b))}
disabled={!(channels && channels.length > 0)}
onChange={(_event, value) => handleChangeChannel(value)}
value={formik.values.idChannel}
fullWidth
renderInput={(params) => (
Expand All @@ -546,6 +565,32 @@ const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => {
data-testid="channels-id-test"
/>
</Grid>
<Grid item xs={6}>
<FormControlLabel
sx={{width: '100%', mt: 2}}
control={
<Switch
id={'cart'}
name="cart"
onChange={(e) => formik.setFieldValue('cart', e.target.checked)}
checked={formik.values.cart ?? false}
disabled={!isChannelV2}
data-testid="bundle-cart"
/>
}
label={
<div style={{display: 'flex', alignItems: 'center'}}>
{t('commissionBundlesPage.addEditCommissionBundle.form.cart')}
<Tooltip
title={t('commissionBundlesPage.addEditCommissionBundle.form.cartInfo')}
placement="right"
>
<InfoOutlined fontSize="small" color="primary" sx={{ml: 2}}/>
</Tooltip>
</div>
}
/>
</Grid>
</Grid>
</Box>
<Box sx={inputGroupStyle}>
Expand Down
Loading

0 comments on commit af2b091

Please sign in to comment.