diff --git a/src/app/[locale]/projects/add/page.tsx b/src/app/[locale]/projects/add/page.tsx index 107e467e..3330224d 100644 --- a/src/app/[locale]/projects/add/page.tsx +++ b/src/app/[locale]/projects/add/page.tsx @@ -31,6 +31,10 @@ export default function AddProjects() { id: '', fullName: '' }) + const [externalUrls, setExternalUrls] = useState([{ + key: '', + value:'' + }]) const [projectPayload, setProjectPayload] = useState({ name: '', description: '', @@ -41,6 +45,7 @@ export default function AddProjects() { domain: '', leadArchitect: '', defaultVendorId: '', + externalUrls: null, state: 'ACTIVE', phaseOutSince: '', moderators: null, @@ -54,6 +59,15 @@ export default function AddProjects() { theme: 'colored', }) + const setExternalUrlsData = (externalUrls: Map) => { + const obj = Object.fromEntries(externalUrls) + setProjectPayload({ + ...projectPayload, + externalUrls: obj, + }) + } + + const createProject = async () => { const response = await ApiUtils.POST('projects', projectPayload, @@ -128,6 +142,9 @@ export default function AddProjects() { diff --git a/src/components/ProjectAddSummary/Summary.tsx b/src/components/ProjectAddSummary/Summary.tsx index bed7ae46..2efa3d0b 100644 --- a/src/components/ProjectAddSummary/Summary.tsx +++ b/src/components/ProjectAddSummary/Summary.tsx @@ -18,16 +18,28 @@ import ProjectPayload from "@/object-types/CreateProjectPayload" import { COMMON_NAMESPACE } from '@/object-types/Constants' import { useTranslations } from "next-intl" import Vendor from '@/object-types/Vendor' +import { AddtionalDataType } from '@/object-types/AddtionalDataType' interface Props{ token: string vendor: Vendor setVendor: React.Dispatch> + externalUrls: Input[] + setExternalUrls: React.Dispatch> + setExternalUrlsData: AddtionalDataType projectPayload: ProjectPayload setProjectPayload: React.Dispatch> } -export default function Summary({token, vendor, setVendor, projectPayload, setProjectPayload}: Props) { +export default function Summary({token, + vendor, + setVendor, + externalUrls, + setExternalUrls, + setExternalUrlsData, + projectPayload, + setProjectPayload + }: Props) { const t = useTranslations(COMMON_NAMESPACE) @@ -45,6 +57,9 @@ export default function Summary({token, vendor, setVendor, projectPayload, setPr diff --git a/src/components/ProjectAddSummary/component/AddKeyValue.tsx b/src/components/ProjectAddSummary/component/AddKeyValue.tsx index 21f1371a..02f68a74 100644 --- a/src/components/ProjectAddSummary/component/AddKeyValue.tsx +++ b/src/components/ProjectAddSummary/component/AddKeyValue.tsx @@ -20,7 +20,9 @@ import { COMMON_NAMESPACE } from '@/object-types/Constants' interface Props { header: string keyName: string - setData?: AddtionalDataType + data?: Input[] + setData?: React.Dispatch> + setObject?: AddtionalDataType } interface Input { @@ -37,13 +39,13 @@ export default function AddKeyValueComponent(props: Props) { const { name, value } = e.target const list: Input[] = [...inputList] list[index][name as keyof Input] = value - setInputList(list) - if(props.setData) { + props.setData(list) + if(props.setObject) { const map = new Map() list.forEach((item) => { map.set(item.key, item.value) }) - props.setData(map) + props.setObject(map) } } @@ -87,7 +89,7 @@ export default function AddKeyValueComponent(props: Props) { className='form-control' placeholder={t(`Enter ${props.keyName.toLowerCase()} value`)} required - aria-describedby={t(`${props.keyName.toLowerCase()} value`)} + aria-describedby={`${props.keyName.toLowerCase()} value`} />
diff --git a/src/object-types/CreateProjectPayload.ts b/src/object-types/CreateProjectPayload.ts index e67b15b6..fab2c313 100644 --- a/src/object-types/CreateProjectPayload.ts +++ b/src/object-types/CreateProjectPayload.ts @@ -10,16 +10,17 @@ export default interface ProjectPayload { name: string - description: string - version: string + description?: string + version?: string visibility: string projectType: string - tag: string - domain: string - leadArchitect: string - defaultVendorId: string - state: string - phaseOutSince: string - moderators: string[] - contributors: string[] + tag?: string + domain?: string + leadArchitect?: string + defaultVendorId?: string + externalUrls?: object + state?: string + phaseOutSince?: string + moderators?: string[] + contributors?: string[] }