diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 932ed583..d7ae1430 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -60,6 +60,85 @@ import AdvanceSettings from '../AdvancePropertise'; // Styles import './index.scss'; +const dummy_obj:any = { + 'single_line_text':{ + label : 'Single Line Textbox', + options : { + 'Single Line Textbox':'single_line_text', + 'Multi Line Textbox':'multi_line_text', + 'HTML Rich text Editor':'html', + 'JSON Rich Text Editor':'json'} + }, + 'multi_line_text':{ + label : 'Multi Line Textbox', + options : { + 'HTML Rich text Editor': 'html', + 'JSON Rich Text Editor':'json'} + }, + 'json':{ + label:'JSON Rich Text Editor', + options : { + 'JSON Rich Text Editor':'json'} + }, + 'html':{ + label : 'HTML Rich text Editor', + options : { + 'HTML Rich text Editor': 'html', + 'JSON Rich Text Editor':'json'} + + }, + 'text':{ + label : 'Single Line Textbox', + options: {'Single Line Textbox':'single_line_text'} + }, + 'url': { + label: 'URL', + options:{'URL':'url'} + }, + 'file': { + label:'File', + options: {'File':'file'} + }, + 'number': { + label:'Number', + options: {'Number':'number'} + }, + 'isodate': { label :'Date', + options: {'Date':'isodate'} + }, + 'boolean': { + label: 'Boolean', + options: {'Boolean':'boolean'} + }, + 'link': { + label:'Link', + options: {'Link':'link'} + }, + 'reference':{ + label: 'Reference', + options: {'Reference':'reference'} + }, + 'dropdown': { + label:'Dropdown', + options: {'Dropdown':'dropdown'} + }, + 'radio': { + label :'Select', + options: {'Select':'select'} + }, + 'CheckBox': { + label:'Select', + options: {'Select':'checkbox'} + }, + 'global_field':{ + label : 'Global', + options: {'Global':'global_field'}}, + 'group': { + label: 'Group', + options: {'Group':'group'} + } + +} const Fields: Mapping = { 'Single Line Textbox': [ @@ -162,6 +241,7 @@ const ContentMapper = () => { const [contentTypeSchema, setContentTypeSchema] = useState([]); const [showFilter, setShowFilter] = useState(false); const [filteredContentTypes, setFilteredContentTypes] = useState([]) + const [count, setCount] = useState(0); /** ALL HOOKS Here */ const { projectId = '' } = useParams(); @@ -244,6 +324,7 @@ const ContentMapper = () => { const { data } = await getContentTypes(projectId || '', 0, 5000, searchContentType || ''); //org id will always present setContentTypes(data?.contentTypes); + setCount(data?.contentTypes?.length); setFilteredContentTypes(data?.contentTypes); setSelectedContentType(data?.contentTypes?.[0]); setTotalCounts(data?.contentTypes?.[0]?.fieldMapping?.length); @@ -480,21 +561,36 @@ const ContentMapper = () => { }); }; const SelectAccessor = (data: FieldMapType) => { - const OptionsForRow = Fields[data?.backupFieldType as keyof Mapping]; - - const option = Array.isArray(OptionsForRow) - ? OptionsForRow.map((option) => ({ label: option, value: option })) - : [{ label: OptionsForRow, value: OptionsForRow }]; + + //const OptionsForRow = Fields[data?.backupFieldType as keyof Mapping]; + const OptionsForRow = dummy_obj?.[data?.backupFieldType]?.options ; + const initialOption = { + label: dummy_obj?.[data?.ContentstackFieldType]?.label, + value: dummy_obj?.[data?.ContentstackFieldType]?.label, + }; + let option:any; + if (Array.isArray(OptionsForRow)) { + option = OptionsForRow.map((option) => ({ + label: option, + value: option, + })); + } else if (typeof OptionsForRow === 'object') { + option = Object.entries(OptionsForRow).map(([label, value]) => ({ + label, + value, + })); + }else{ + option = [{ label: OptionsForRow, value: OptionsForRow }] + } const fieldLabel = data?.ContentstackFieldType === 'url' || data?.ContentstackFieldType === 'group' ? data?.ContentstackFieldType : option?.[0]?.label - return (