diff --git a/.vscode/settings.json b/.vscode/settings.json index dc1f9207..458a1223 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,5 @@ { - "prettier.printWidth": 250 -} \ No newline at end of file + "prettier.printWidth": 250, + "deno.enable": true, + "deno.lint": true, +} diff --git a/src/components/common/Dropdown.tsx b/src/components/common/Dropdown.tsx index 0c404772..d011759e 100644 --- a/src/components/common/Dropdown.tsx +++ b/src/components/common/Dropdown.tsx @@ -27,21 +27,21 @@ const Dropdown: Component = (Props: Props) => {
{/* Dropdown button */} + +
+ +
+ + {(subtopic) => + subtopic.subject_id === + subject.id && ( + + ) + } + +
+ + + )} + + + + +
+
+ + + + + + + +
+ +
+ + + {/* Grade Picker */} +
+ + + {/* Creates a list of checkboxes that drop down to multiple select */} +
+
gradeCheckboxes()} + > +
+ 0}> + {gradePick().map((grade) => + grades() + .filter((item) => item.id === grade) + .map((item) => ( + + {item.grade}, + + )) + )} + + + * + {t("formLabels.chooseGrade")} + +
+ + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+
+ + {/* resourceTypes Picker */} +
+ + + {/* Creates a list of checkboxes that drop down to multiple select */} +
+
resourceTypesCheckboxes()} + > +
+
+ 0}> + {resourceTypesPick().map( + (resourceType) => + resourceTypes() + .filter( + (item) => + item.id === + resourceType + ) + .map((item) => ( + + {item.type}, + + )) + )} + + + * {" "} + {t("formLabels.chooseResourceTypes")} + +
+ + + + +
+
+ +
+ +
+
+ + + + + + + +
+ +
+
+ + {/* Secular Implementation */} +
+
+
+ {t("formLabels.secular")}? +
+
+ + setSecular(!secular())} + /> +
+
+
+
+ + + + + + + +
+
+
+ + {/* Hosted Implementation */} + +
+

Hosted Resource?

+
+ + { + setIsHosted(true); + // Currently we are only allowing FREE hosted resources + setIsFree(true); + }} + /> + + + setIsHosted(false)} + /> +
+
+
+ +

Enter a comma separated list of links

+ setHostedLinks(e.target.value)} + /> +
+ + {/* Price Implementation */} +
+
+

+ * + {t("formLabels.isResourceFree")}? +

+
+ + setIsFree(true)} + /> + + setIsFree(false)} + /> +
+
+ + +
+
+

+ * + {t("formLabels.pricePost")} +

+ +
+ + formatPrice(e.target.value) + } + /> + +
+ + + + + + + +
+
+
+
+ +
+
+ +
+ +
+
+ + + + + + + +
+
+
+ +
+ +

+ {t("pageDescriptions.taxCodeLearnMore")} +

+
+
+
+
+ + +
+ {/* TODO: Mark this as required and provide Error if no files uploaded when trying to post */} + {/* TODO: Fix the text centering for Drop files here or browse files */} + (uploadFilesRef = uppy)} + onUpload={(url: string) => { + setResourceURL([...resourceURL(), url]); + }} + removeFile={(url: string) => { + setResourceURL( + resourceURL().filter((u) => u !== url) + ); + }} + setUploadFinished={(uploadFinished) => + setUploadFinished(uploadFinished) + } + /> +
+
+
+ +
+
+ + {postButton()} +
+ + + ); +}; diff --git a/src/components/posts/CreateNewPost.tsx b/src/components/posts/CreateNewPost.txt similarity index 84% rename from src/components/posts/CreateNewPost.tsx rename to src/components/posts/CreateNewPost.txt index 760efcd5..24affa60 100644 --- a/src/components/posts/CreateNewPost.tsx +++ b/src/components/posts/CreateNewPost.txt @@ -173,6 +173,7 @@ export const CreateNewPost: Component = () => { subtopic: string; subject_id: number; ariaLabel: string; + checked: boolean; }> >([]); const [subjectPick, setSubjectPick] = createSignal>([]); @@ -331,6 +332,7 @@ export const CreateNewPost: Component = () => { subtopic: subtopic.name, ariaLabel: subtopic.ariaLabel, subject_id: subtopic.subject_id, + checked: false, }, ]) ); @@ -408,6 +410,11 @@ export const CreateNewPost: Component = () => { } }); + createEffect(() => { + console.log("SubjectPick: ", subjectPick()); + console.log("SubtopicPick: ", subtopicPick()); + }); + function saveAsDraft(e: Event) { e.preventDefault(); setDraftStatus(true); @@ -559,19 +566,40 @@ export const CreateNewPost: Component = () => { subjectPick().filter((value) => value !== targetValue) ); } + setSelectedSubjectId(undefined); + //Need to add something to keep subjects and subtopics in sync } + + const subjectValid = document.getElementById("isSubjectValid"); + const subjectToolTip = document.getElementById("subjectToolTip"); + if (subjectPick().length > 0) { - document - .getElementById("isSubjectValid") - ?.classList.remove("hidden"); - document.getElementById("subjectToolTip")?.classList.add("hidden"); + subjectValid?.classList.remove("hidden"); + subjectToolTip?.classList.add("hidden"); } else if (subjectPick().length === 0) { - document.getElementById("isSubjectValid")?.classList.add("hidden"); - document - .getElementById("subjectToolTip") - ?.classList.remove("hidden"); + subjectValid?.classList.add("hidden"); + subjectToolTip?.classList.remove("hidden"); + } + + if (subjectPick().length === 0) { + setSubtopicPick([]); + setSubtopics((prev) => + prev.map((subtopic) => ({ ...subtopic, checked: false })) + ); + } else { + setSubtopics((prev) => + prev.map((subtopic) => { + if (subjectPick().indexOf(subtopic.subject_id) === -1) { + setSubtopicPick((prev) => + prev.filter((item) => item !== subtopic.id) + ); + return { ...subtopic, checked: false }; + } else { + return { ...subtopic }; + } + }) + ); } - console.log(subjectPick()); } function setSubtopicArray(e: Event) { @@ -586,7 +614,6 @@ export const CreateNewPost: Component = () => { ); } } - console.log(subtopicPick()); } function formatPrice(resourcePrice: string) { @@ -693,7 +720,10 @@ export const CreateNewPost: Component = () => { * {t("formLabels.required")} -