diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 1982fca97..f278bdca7 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -211,26 +211,12 @@ const ContentMapper = () => { }; // Fetch table data - const fetchData = async ({ - sortBy, - searchText, - skip, - limit, - startIndex, - stopIndex - }: TableTypes) => { + const fetchData = async ({ searchText }: TableTypes) => { fetchContentTypes(searchText); }; // Method for Load more table data - const loadMoreItems = async ({ - sortBy, - searchText, - skip, - limit, - startIndex, - stopIndex - }: TableTypes) => { + const loadMoreItems = async ({ searchText, skip, limit, startIndex, stopIndex }: TableTypes) => { try { const itemStatusMapCopy: ItemStatusMapProp = { ...itemStatusMap }; @@ -645,44 +631,38 @@ const ContentMapper = () => { // accessor: 'otherCmsField', default: false, id: 'uuid' - }, - { + } + ]; + + if (!IsEmptyStack) { + columns?.push({ + disableSortBy: true, + Header: `Contentstack: ${newMigrationData?.destination_stack?.selectedStack?.label}`, + // accessor: 'ct_field', + accessor: SelectAccessorOfColumn, + id: 'contentstack_field', + default: false + }); + } else { + columns?.push({ disableSortBy: true, Header: `Contentstack: ${ IsEmptyStack ? otherCmsTitle : OtherContentType?.label ?? '' }`, accessor: SelectAccessor, - id: 'contentstack_cms_field' - } - // { - // disableSortBy: true, - // Header: contentstackFields.title, - // id: 'contenstatck', - // //id: contentstackFields.title.replace(/\W+/g, '_').toLowerCase(), - // accessor: SelectAccessor - // } - ]; - - // if (!IsEmptyStack) { - // columns?.splice(1, 0, { - // disableSortBy: true, - // Header: `Contentstack: ${newMigrationData?.destination_stack?.selectedStack?.label}`, - // // accessor: 'ct_field', - // accessor: SelectAccessor, - // id: 'contentstack_cms_field' - // //default: false - // }); - // } + id: 'contentstack_cms_field', + default: false + }); + } const nextButtonLabel = currentIndex < contentTypes?.length - 1 ? contentTypes[currentIndex + 1]?.otherCmsTitle : ''; const prevButtonLabel = currentIndex > 0 ? contentTypes[currentIndex - 1]?.otherCmsTitle : ''; - const options = - contentTypesList && - contentTypesList.map((item) => ({ - label: item?.title - })); + const options = contentTypesList?.map((item) => ({ + label: item?.title, + value: item?.title + })); // console.log("==============", contentTypesList); diff --git a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx index ee9f6345e..69e5831f4 100644 --- a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx @@ -128,7 +128,10 @@ const LoadStacks = (props: LoadFileFormatProps) => { updateNewMigrationData(newMigrationDataObj); //call for Step Change - props.handleStepChange(props?.currentStep, true); + if (props?.handleStepChange) { + props.handleStepChange(props?.currentStep, true); + } + //.handleStepChange(props?.currentStep, true); } } }; @@ -141,8 +144,6 @@ const LoadStacks = (props: LoadFileFormatProps) => { //fetch all locales const response = await getAllLocales(newMigrationData?.destination_stack?.selectedOrg?.value); //org id will always be there - console.log('getAllLocales =============', newMigrationData, response, stackData); - // const rawMappedLocalesMapped = // validateObject(response?.data) && response?.data?.locales // ? Object.keys(data?.locales)?.map((key) => ({ diff --git a/ui/src/components/DestinationStack/index.tsx b/ui/src/components/DestinationStack/index.tsx index d234d6798..39bbbdb54 100644 --- a/ui/src/components/DestinationStack/index.tsx +++ b/ui/src/components/DestinationStack/index.tsx @@ -137,7 +137,6 @@ const DestinationStackComponent = ({ const fetchCMSData = async () => { //check if offline CMS data field is set to true, if then read data from cms data file. const data = await getCMSDataFromFile(CS_ENTRIES.DESTINATION_STACK); - console.log(':::::::::::::::::::::', data); //fetch Legacy CMS Component Data from Contentstack CMS //const data = await getEntries({ contentType: CS_ENTRIES.DESTINATION_STACK }) diff --git a/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx b/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx index e48f42cdf..7a863c849 100644 --- a/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx @@ -7,7 +7,10 @@ import { Button } from '@contentstack/venus-components'; import { isEmptyString, validateArray } from '../../../utilities/functions'; // Services -import { updateFileFormatData } from '../../../services/api/migration.service'; +import { + updateFileFormatData, + fileformatConfirmation +} from '../../../services/api/migration.service'; // Interface import { ICardType, defaultCardType } from '../../../components/Common/Card/card.interface'; @@ -56,6 +59,9 @@ const LoadFileFormat = (props: LoadFileFormatProps) => { updateFileFormatData(selectedOrganisation.value, projectId, { file_format: selectedCard?.fileformat_id }); + fileformatConfirmation(selectedOrganisation?.value, projectId, { + fileformat_confirmation: isCheckedBoxChecked + }); //call for Step Change props.handleStepChange(props.currentStep); diff --git a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx index 07af04d12..56fe4fa56 100644 --- a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx @@ -1,9 +1,9 @@ // Libraries -import { ChangeEvent, useContext, useState } from 'react'; +import { ChangeEvent, useContext, useEffect, useState } from 'react'; import { useParams } from 'react-router'; // Service -import { updateAffixData } from '../../../services/api/migration.service'; +import { updateAffixData, affixConfirmation } from '../../../services/api/migration.service'; // Utilities import { isEmptyString, isValidPrefix } from '../../../utilities/functions'; @@ -61,6 +61,9 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { //API call for saving Affix updateAffixData(selectedOrganisation.value, projectId, { affix: prefix }); + affixConfirmation(selectedOrganisation?.value, projectId, { + affix_confirmation: isCheckedBoxChecked + }); //call for Step Change props.handleStepChange(props.currentStep); @@ -87,9 +90,21 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { // Toggles checkbox selection const handleCheckBoxChange = (e: ChangeEvent) => { const { checked } = e.target; + + const newMigrationDataObj: INewMigration = { + ...newMigrationData, + legacy_cms: { + ...newMigrationData?.legacy_cms, + isRestictedKeywordCheckboxChecked: checked + } + }; + updateNewMigrationData(newMigrationDataObj); + setIsCheckedBoxChecked(checked); }; + + /**** ALL USEEffects HERE ****/ const { restricted_keyword_link = DEFAULT_URL_TYPE, restricted_keyword_checkbox_text = '' } = diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index 4bc65dcc0..f44c787ab 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -157,8 +157,12 @@ const LegacyCMSComponent = ({ legacyCMSData, projectData }: LegacyCMSComponentPr selectedFileFormat: selectedFileFormatData || defaultCardType, uploadedFile: newMigrationData?.legacy_cms?.uploadedFile, //need to add backend data once endpoint exposed. affix: legacyCMSData?.affix || newMigrationData?.legacy_cms?.affix || '', - isFileFormatCheckboxChecked: false, //need to add backend data once endpoint exposed. - isRestictedKeywordCheckboxChecked: false //need to add backend data once endpoint exposed. + isFileFormatCheckboxChecked: + legacyCMSData?.affix_confirmation || + newMigrationData?.legacy_cms?.isFileFormatCheckboxChecked, //need to add backend data once endpoint exposed. + isRestictedKeywordCheckboxChecked: + legacyCMSData?.file_format_confirmation || + newMigrationData?.legacy_cms?.isRestictedKeywordCheckboxChecked //need to add backend data once endpoint exposed. } }); diff --git a/ui/src/context/app/app.provider.tsx b/ui/src/context/app/app.provider.tsx index 31c1dad19..855669ca7 100644 --- a/ui/src/context/app/app.provider.tsx +++ b/ui/src/context/app/app.provider.tsx @@ -130,9 +130,11 @@ const AppContextProvider: FC = ({ children }) => { if (!isEmptyString(authToken)) { getUserDetails(); } + }, [authToken]); + useEffect(() => { sessionStorage.setItem('newMigration', JSON.stringify(newMigration)); - }, [authToken, newMigration]); + }, [newMigration]); const ctxObject: IAppContext = { authToken: authToken, diff --git a/ui/src/pages/MigrationEditor/index.tsx b/ui/src/pages/MigrationEditor/index.tsx index 65c48114c..eed98ffd5 100644 --- a/ui/src/pages/MigrationEditor/index.tsx +++ b/ui/src/pages/MigrationEditor/index.tsx @@ -35,7 +35,6 @@ const MigrationEditor = () => { const bodyContent = { component: }; - /******** Function to get project ********/ const fetchProject = async () => { const response = await getProject(selectedOrganisation?.value || '', params?.projectId || ''); diff --git a/ui/src/services/api/migration.service.ts b/ui/src/services/api/migration.service.ts index 03969c01f..7c9edb427 100644 --- a/ui/src/services/api/migration.service.ts +++ b/ui/src/services/api/migration.service.ts @@ -60,6 +60,30 @@ export const updateCurrentStepData = (orgId: string, projectId: string, data: an } }; +export const affixConfirmation = (orgId: string, projectId: string, data: any = {}) => { + try { + return putCall( + `${API_VERSION}/org/${orgId}/project/${projectId}/affix_confirmation`, + data, + options + ); + } catch (error) { + return error; + } +}; + +export const fileformatConfirmation = (orgId: string, projectId: string, data: any = {}) => { + try { + return putCall( + `${API_VERSION}/org/${orgId}/project/${projectId}/fileformat_confirmation`, + data, + options + ); + } catch (error) { + return error; + } +}; + export const getContentTypes = ( projectId: string, skip: number,