Skip to content

Commit

Permalink
Merge pull request #24 from Aar-if/main
Browse files Browse the repository at this point in the history
Create API update
  • Loading branch information
itsvick authored Oct 10, 2024
2 parents 571f227 + ec2d130 commit 4abd3a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/components/QuestionSetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ const QuestionSetEditor: React.FC = () => {
useEffect(() => {
const fetchData = async () => {
try {
// const response = await createQuestionSet();
// const identifier = response?.result?.identifier;
console.log("DO ID created successfully:", identifier);

questionSetEditorConfig.context.identifier = identifier;

if (!isAppended && editorRef.current) {
const editorConfig = questionSetEditorConfig;
const questionsetEditorElement = document.createElement(
Expand Down
22 changes: 21 additions & 1 deletion src/pages/workspace/content/create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,34 @@ import DescriptionOutlinedIcon from "@mui/icons-material/DescriptionOutlined";
import DescriptionIcon from "@mui/icons-material/Description";
import UploadIcon from "@mui/icons-material/Upload";
import { useRouter } from "next/router";
import { createQuestionSet } from "@/services/ContentService";

const CreatePage = () => {
const theme = useTheme<any>();
const [selectedKey, setSelectedKey] = useState("create");
const router = useRouter();


const fetchData = async () => {
try {
const response = await createQuestionSet();
console.log('Question set created successfully:', response);
const identifier = response?.result?.identifier;

router.push({
pathname: `/editor`,
query: { identifier },
});

} catch (error) {
console.error('Error creating question set:', error);
}
};



const openEditor = () => {
router.push("/editor");
fetchData();
};

const cardData = [
Expand Down
3 changes: 1 addition & 2 deletions src/services/ContentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getContent = async (status: string[]) => {
};

export const createQuestionSet = async () => {
const apiURL = `action/questionset/v2/create`;
const apiURL = `/action/questionset/v2/create`;
const reqBody = {
request: {
questionset: {
Expand All @@ -77,7 +77,6 @@ export const createQuestionSet = async () => {
headers: {
"Content-Type": "application/json",
tenantId: "ef99949b-7f3a-4a5f-806a-e67e683e38f3",
Authorization: `Bearer ${authToken}`,
},
});
return response?.data;
Expand Down

0 comments on commit 4abd3a8

Please sign in to comment.