From 617ea05a09021f7209c4f47217ae1abc264e55a5 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Dec 2024 11:58:31 +0530 Subject: [PATCH 1/2] Issue feat PS-2899: integrate form fields for publish and reject confirmation popup checklist --- src/components/ConfirmActionPopup.tsx | 55 +- src/pages/api/mocked-response.ts | 911 ++++++++++++++------------ src/pages/api/proxy.ts | 6 +- src/services/ContentService.ts | 30 +- 4 files changed, 556 insertions(+), 446 deletions(-) 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; + } +}; From ac31e345f1f44487bc375bd2f7e194d784b842ef Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Dec 2024 12:15:23 +0530 Subject: [PATCH 2/2] update pr --- .env | 1 + .github/workflows/qa-deployment.yaml | 4 ++-- src/utils/app.config.ts | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 3a4c03e..981c209 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ NEXT_PUBLIC_TENANT_ID="" # Tenant Id of User NEXT_PUBLIC_CLOUD_STORAGE_URL="" # Use environment variable for S3 Cloud Storage URL - should have / at the end. NEXT_PUBLIC_CHANNEL_ID="" # Channel Id of knowlg-inQuiry setup NEXT_PUBLIC_FRAMEWORK_ID="" # Framework Id of knowlg-inQuiry setup +NEXT_PUBLIC_CONTENT_FRAMEWORK_ID="" # Learning Framework Id for Content Creation NEXT_PUBLIC_TELEMETRY_URL="" #telemetry service path AWS_ACCESS_KEY_ID="" # For AWS S3 large file chunks upload AWS_ACCESS_SECRET_KEY="" # For AWS S3 large file chunks upload diff --git a/.github/workflows/qa-deployment.yaml b/.github/workflows/qa-deployment.yaml index baea75b..9285e7a 100644 --- a/.github/workflows/qa-deployment.yaml +++ b/.github/workflows/qa-deployment.yaml @@ -2,7 +2,7 @@ name: Deploy to Tekdi-QA-Server on: push: branches: - - release-1.0.0 + - release-1.1.0 jobs: deploy: runs-on: ubuntu-latest @@ -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/utils/app.config.ts b/src/utils/app.config.ts index 8876abf..407b422 100644 --- a/src/utils/app.config.ts +++ b/src/utils/app.config.ts @@ -36,6 +36,11 @@ if (!FRAMEWORK_ID) { console.warn('NEXT_PUBLIC_FRAMEWORK_ID is not set in the environment variables.'); } +export const CONTENT_FRAMEWORK_ID = process.env.NEXT_PUBLIC_CONTENT_FRAMEWORK_ID || ""; +if (!CONTENT_FRAMEWORK_ID) { + console.warn('NEXT_PUBLIC_CONTENT_FRAMEWORK_ID is not set in the environment variables.'); +} + export const CLOUD_STORAGE_URL = process.env.NEXT_PUBLIC_CLOUD_STORAGE_URL || ""; if (!CLOUD_STORAGE_URL) { console.warn('NEXT_PUBLIC_CLOUD_STORAGE_URL is not set in the environment variables.');