Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download tex option #30

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/components/NewItemDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import { SubheadingItem } from "@/components/resume-items/subheading-item";
import { ProjectItem } from "@/components/resume-items/project-item";
import { SkillItem } from "@/components/resume-items/skill-item";
import { PlusIcon } from "@radix-ui/react-icons";
import { templates } from "@/api/models/templates";

export const NewItemDropdown: React.FC<{
dropdownIsOpen: boolean;
setDropdownIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
}> = ({ dropdownIsOpen, setDropdownIsOpen }) => {
templateId: templates | undefined;
}> = ({ dropdownIsOpen, setDropdownIsOpen, templateId }) => {
console.log("templateId in newitemdropdown:", templateId);
return (
<DropdownMenu open={dropdownIsOpen} onOpenChange={setDropdownIsOpen}>
<DropdownMenuTrigger asChild>
Expand All @@ -33,20 +36,39 @@ export const NewItemDropdown: React.FC<{
<DropdownMenuContent>
<DropdownMenuLabel className="text-center">Item Type</DropdownMenuLabel>
<DropdownMenuSeparator />
<HeadingItem setDropdownIsOpen={setDropdownIsOpen}></HeadingItem>
<HeadingItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></HeadingItem>
<DropdownMenuSeparator />
<SubheadingItem setDropdownIsOpen={setDropdownIsOpen}></SubheadingItem>
<SubheadingItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></SubheadingItem>
<DropdownMenuSeparator></DropdownMenuSeparator>
<EducationItem setDropdownIsOpen={setDropdownIsOpen}></EducationItem>
<EducationItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></EducationItem>
<DropdownMenuSeparator />
<ExperienceItem setDropdownIsOpen={setDropdownIsOpen}></ExperienceItem>
<ExperienceItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></ExperienceItem>
<DropdownMenuSeparator />
<ExtracurricularItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></ExtracurricularItem>
<DropdownMenuSeparator />
<ProjectItem setDropdownIsOpen={setDropdownIsOpen}></ProjectItem>
<SkillItem setDropdownIsOpen={setDropdownIsOpen}></SkillItem>
<ProjectItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></ProjectItem>
<SkillItem
setDropdownIsOpen={setDropdownIsOpen}
templateId={templateId}
></SkillItem>
</DropdownMenuContent>
</DropdownMenu>
);
Expand Down
12 changes: 11 additions & 1 deletion src/components/ec-helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ import { HeadingItem } from "./resume-items/heading-item";
import { ProjectItem } from "./resume-items/project-item";
import { SubheadingItem } from "./resume-items/subheading-item";
import { SkillItem } from "./resume-items/skill-item";
import { templates } from "@/api/models/templates";

const ECHelper: React.FC<{
object: BaseItem;
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
itemId: string;
}> = ({ object, setDropdownIsOpen, itemId}) => {
templateId: templates | undefined;

}> = ({ object, setDropdownIsOpen, itemId, templateId}) => {
switch (object.type) {
case resumeItemTypes.EDUCATION:
return (
<EducationItem
setDropdownIsOpen={setDropdownIsOpen}
original={object as EducationType}
originalId={itemId}
templateId={templateId}
></EducationItem>
);

Expand All @@ -39,6 +43,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as ExperienceType}
originalId={itemId}
templateId={templateId}
></ExperienceItem>
);

Expand All @@ -48,6 +53,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as ActivitiesType}
originalId={itemId}
templateId={templateId}
></ExtracurricularItem>
);

Expand All @@ -57,6 +63,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as HeadingsType}
originalId={itemId}
templateId={templateId}
></HeadingItem>
);

Expand All @@ -66,6 +73,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as ProjectsType}
originalId={itemId}
templateId={templateId}
></ProjectItem>
);

Expand All @@ -75,6 +83,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as SectionHeadingsType}
originalId={itemId}
templateId={templateId}
></SubheadingItem>
);

Expand All @@ -84,6 +93,7 @@ const ECHelper: React.FC<{
setDropdownIsOpen={setDropdownIsOpen}
original={object as SkillsType}
originalId={itemId}
templateId={templateId}
></SkillItem>
);

Expand Down
5 changes: 5 additions & 0 deletions src/components/resume-items/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ import { useUpdateItem } from "@/hooks/mutations";
import { resumeItemTypes } from "@/api/models/resumeItemTypes";
import { DragHandleHorizontalIcon } from "@radix-ui/react-icons";
import { checkForDuplicate } from "@/api/itemInterface";
import { templates } from "@/api/models/templates";

interface ActivityItemsProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: ActivitiesType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function ExtracurricularItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: ActivityItemsProps) {
// Global context(s)
const { currentUser } = useAuth();
Expand Down Expand Up @@ -162,11 +165,13 @@ export function ExtracurricularItem({
};
if (submissionType == formSubmissionTypes.EDIT) {
try {
console.log("templateId passed into activity edit:", templateId);
// Call the mutation function with necessary parameters
mutation.mutate({
itemType: resumeItemTypes.ACTIVITY,
itemId: originalId!,
updatedFields: activityData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/education-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ import { resumeItemTypes } from "@/api/models/resumeItemTypes";
import { ReactSortable } from "react-sortablejs";
import { DragHandleHorizontalIcon } from "@radix-ui/react-icons";
import { checkForDuplicate } from "@/api/itemInterface";
import { templates } from "@/api/models/templates";

interface EducationItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: EducationType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function EducationItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: EducationItemProps) {
// Global context(s)
const { currentUser } = useAuth();
Expand Down Expand Up @@ -174,6 +177,7 @@ export function EducationItem({
itemType: resumeItemTypes.EDUCATION,
itemId: originalId!,
updatedFields: educationData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/experience-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ import { resumeItemTypes } from "@/api/models/resumeItemTypes";
import { DragHandleHorizontalIcon } from "@radix-ui/react-icons";
import { ReactSortable } from "react-sortablejs";
import { checkForDuplicate } from "@/api/itemInterface";
import { templates } from "@/api/models/templates";

interface ExperienceItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: ExperienceType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function ExperienceItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: ExperienceItemProps) {
// Global context(s)
const { currentUser } = useAuth();
Expand Down Expand Up @@ -173,6 +176,7 @@ export function ExperienceItem({
itemType: resumeItemTypes.EXPERIENCE,
itemId: originalId!,
updatedFields: experienceData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/heading-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ import { checkForDuplicate } from "@/api/itemInterface";
import { useForm } from "react-hook-form";
import * as Yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import { templates } from "@/api/models/templates";

interface HeadingItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: HeadingsType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function HeadingItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: HeadingItemProps) {
const { currentUser } = useAuth();
const [storedToken, setStoredToken] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -164,6 +167,7 @@ export function HeadingItem({
itemType: resumeItemTypes.HEADING,
itemId: originalId!,
updatedFields: headingData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/project-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ import { useUpdateItem } from "@/hooks/mutations";
import { DragHandleHorizontalIcon } from "@radix-ui/react-icons";
import { ReactSortable } from "react-sortablejs";
import { useQueryClient } from "@tanstack/react-query";
import { templates } from "@/api/models/templates";

interface ProjectItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: ProjectsType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function ProjectItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: ProjectItemProps) {
const { currentUser } = useAuth();
const [storedToken, setStoredToken] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -164,6 +167,7 @@ export function ProjectItem({
itemType: resumeItemTypes.PROJECT,
itemId: originalId!,
updatedFields: projectData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/skill-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ import * as Yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import { useForm } from "react-hook-form";
import { checkForDuplicate } from "@/api/itemInterface";
import { templates } from "@/api/models/templates";

interface SkillItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: SkillsType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function SkillItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: SkillItemProps) {
const { currentUser } = useAuth();
const [storedToken, setStoredToken] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -129,6 +132,7 @@ export function SkillItem({
itemType: resumeItemTypes.SKILL,
itemId: originalId!,
updatedFields: skillsData,
templateId,
});

setIsOpen(false);
Expand Down
4 changes: 4 additions & 0 deletions src/components/resume-items/subheading-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ import { formSubmissionTypes } from "./formSubmissionTypes";
import { resumeItemTypes } from "@/api/models/resumeItemTypes";
import { useUpdateItem } from "@/hooks/mutations";
import { checkForDuplicate } from "@/api/itemInterface";
import { templates } from "@/api/models/templates";

interface SubheadingItemProps {
setDropdownIsOpen: Dispatch<SetStateAction<boolean>>;
original?: SectionHeadingsType; // Mark as optional with '?'
originalId?: string;
templateId: templates | undefined;
}

export function SubheadingItem({
setDropdownIsOpen,
original,
originalId,
templateId,
}: SubheadingItemProps) {
const { currentUser } = useAuth();
const [storedToken, setStoredToken] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -123,6 +126,7 @@ export function SubheadingItem({
itemType: resumeItemTypes.SECTIONHEADING,
itemId: originalId!,
updatedFields: headingData,
templateId,
});

setIsOpen(false);
Expand Down
13 changes: 9 additions & 4 deletions src/hooks/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
updateItem,
} from "@/api/resumeItemInterface";
import { resumeItemTypes } from "@/api/models/resumeItemTypes";
import { templates } from "@/api/models/templates";

export const useAddActivity = (
queryClient: QueryClient,
Expand Down Expand Up @@ -163,21 +164,25 @@ export const useUpdateItem = (
mutationFn: async ({
itemType,
itemId,
templateId,
updatedFields,
}: {
itemType: resumeItemTypes;
itemId: string;
templateId: templates | undefined;
updatedFields: itemUpdatedFields;
}) => {
if (token === undefined) {
throw new Error("Token is undefined");
if (token === undefined || templateId === undefined) {
console.log("templateId is undefined");
throw new Error("Token is undefined or templateId is undefined");
}
console.log("First Layer");
console.log(updatedFields);
return await updateItem(itemType, itemId, updatedFields, token);
},
onSuccess: (_, { itemId }) => {
invalidateItem(itemId);
onSuccess: (_, { itemId, templateId }) => {
console.log("calling invalidate item:", `${itemId}${templateId}`);
invalidateItem(`${itemId}${templateId}`);
queryClient.invalidateQueries({ queryKey: ["items"] });
},
});
Expand Down
Loading
Loading