Skip to content

Commit

Permalink
chore(generate assignment): subscribe route fix
Browse files Browse the repository at this point in the history
  • Loading branch information
then00bprogrammer committed May 2, 2024
1 parent cf60373 commit ebf1cd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/components/Assignment/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const Content = () => {
setId(id);
const req = await fetch(`/api/subscribe?id=${id}`);
const resp = await req.json();
console.log("getting markdown")
console.log(resp);
setIsPreviewAssignmentVisible(true);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/api/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default async function handler(req:any, res:any) {

try {
const data = await subscriptionPromise;
console.log(data);
res.status(200).json(data);
} catch (error) {
res.status(500).json({ error: "Assignment not generated" });
Expand Down
7 changes: 7 additions & 0 deletions client/src/providers/AssignmentProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface AssignmentContextProps {
"descriptive-type": number[];
"numerical-type": number[];
}>>;
markdown: string|null;
setMarkdown:(markdown:string)=>void;
}

const AssignmentContext = createContext<AssignmentContextProps>({
Expand Down Expand Up @@ -67,6 +69,8 @@ const AssignmentContext = createContext<AssignmentContextProps>({
"numerical-type": [0, 0],
},
setTypesOfQuestions: () => {},
markdown:null,
setMarkdown:()=>{},
});

const AssignmentProvider: React.FC<AssignmentProviderProps> = ({
Expand Down Expand Up @@ -99,6 +103,7 @@ const AssignmentProvider: React.FC<AssignmentProviderProps> = ({
"descriptive-type": [0, 0],
"numerical-type": [0, 0],
});
const [markdown,setMarkdown] = useState<string|null>(null);

const modifyTypesOfQuestions = (
type: keyof typeof typesOfQuestions,
Expand Down Expand Up @@ -136,6 +141,8 @@ const AssignmentProvider: React.FC<AssignmentProviderProps> = ({
setIsEnabledPlagriasmChecker,
typesOfQuestions,
setTypesOfQuestions,
markdown,
setMarkdown
}}
>
{children}
Expand Down

0 comments on commit ebf1cd1

Please sign in to comment.