diff --git a/.github/workflows/qa-deployment.yaml b/.github/workflows/qa-deployment.yaml index eff2c5a..9285e7a 100644 --- a/.github/workflows/qa-deployment.yaml +++ b/.github/workflows/qa-deployment.yaml @@ -24,4 +24,4 @@ jobs: echo '${{ secrets.QA_ENV }}' > .env ls -ltra ./deploy.sh -#Testing +#Testing \ No newline at end of file diff --git a/src/components/ConfirmActionPopup.tsx b/src/components/ConfirmActionPopup.tsx index 3431901..f0a633f 100644 --- a/src/components/ConfirmActionPopup.tsx +++ b/src/components/ConfirmActionPopup.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Dialog, DialogTitle, @@ -14,7 +14,7 @@ import { TextField, } from '@mui/material'; import CloseIcon from '@mui/icons-material/Close'; - +import {getFormFields} from '@/services/ContentService'; interface ConfirmActionPopupProps { open: boolean; onClose: () => void; @@ -29,23 +29,9 @@ const ConfirmActionPopup: React.FC = ({ actionType, }) => { const [checkedItems, setCheckedItems] = useState([]); - const [comment, setComment] = useState(''); - - const usabilityOptions = [ - 'Correct Spellings and Grammar', - 'Simple Language', - 'Content/Audio/Video quality', - 'Suitable font size for app and portal', - 'Copyright infringement (images and texts)', - ]; - - const contentDetailsOptions = [ - 'Appropriate Title', - 'Standard description of the course/resource', - 'Relevant tags and keywords', - 'Appropriate image', - ]; - + const [usabilityOptions, setUsabilityOptions] = useState([]); + const [contentDetailsOptions, setContentDetailsOptions] = useState([]); + const [comment, setComment] = useState(''); const handleCheckboxChange = (item: string) => { setCheckedItems((prev) => prev.includes(item) @@ -66,7 +52,36 @@ const ConfirmActionPopup: React.FC = ({ const allOptions = [...usabilityOptions, ...contentDetailsOptions]; const allChecked = allOptions.every((option) => checkedItems.includes(option)); - + useEffect(() => { + const fetchFields = async () => { + try { + + if(open){ + + const data = await getFormFields(); + + const contents = data?.result?.form?.data?.fields[0]?.contents; + let usabilityCheckList: any = []; + let contentDetailsCheckList: any = []; + contents.forEach((item: any) => { + if (item.name === "Usability") { + usabilityCheckList = item.checkList; + } else if (item.name === "Content details") { + contentDetailsCheckList = item.checkList; + } + }); + setUsabilityOptions(usabilityCheckList); + setContentDetailsOptions(contentDetailsCheckList); + + + } + } catch (err) { + console.error("data", err); + } finally { + } + }; + fetchFields(); + }, [open]); return ( { } }; -export const publishContent = async (identifier: any, publishChecklist?: any) => { +export const publishContent = async ( + identifier: any, + publishChecklist?: any +) => { const requestBody = { request: { content: { lastPublishedBy: userId, - publishChecklist:publishChecklist + publishChecklist: publishChecklist, }, }, }; @@ -280,7 +283,11 @@ export const publishContent = async (identifier: any, publishChecklist?: any) => } }; -export const submitComment = async (identifier: any, comment: any, rejectReasons?:any) => { +export const submitComment = async ( + identifier: any, + comment: any, + rejectReasons?: any +) => { const requestBody = { request: { content: { @@ -330,3 +337,20 @@ export const getFrameworkDetails = async (): Promise => { return error; } }; +export const getFormFields = async (): Promise => { + const apiUrl: string = `/action/data/v1/form/read`; + + try { + const response = await axios.post(apiUrl, { + request: { + action: "publish", + type: "content", + subType: "resource", + }, + }); + return response?.data; + } catch (error) { + console.error("Error in getting Framework Details", error); + return error; + } +};