Skip to content

fix : added dialog closing after from submission in addexperience, addproject , addresume #596

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/components/user-multistep-form/add-project-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import { FaFileUpload } from 'react-icons/fa';
import Image from 'next/image';
import { X } from 'lucide-react';

export const AddProject = () => {
interface AddProjectsProp {
onClose?: () => void;
}

export const AddProject = ({ onClose }: AddProjectsProp) => {
const form = useForm<projectSchemaType>({
resolver: zodResolver(projectSchema),
defaultValues: {
Expand Down Expand Up @@ -133,6 +137,7 @@ export const AddProject = () => {
});
setPreviewImg(null);
form.reset(form.formState.defaultValues);
onClose?.();
} catch (_error) {
toast({
title: 'Something went wrong while Adding Projects',
Expand Down
7 changes: 6 additions & 1 deletion src/components/user-multistep-form/add-resume-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { uploadFileAction } from '@/actions/upload-to-cdn';
import { addUserResume } from '@/actions/user.profile.actions';
import { LoadingSpinner } from '../loading-spinner';

export const AddResume = () => {
interface AddResumeProps {
onClose?: () => void;
}

export const AddResume = ({ onClose }: AddResumeProps) => {
const resumeFileRef = useRef<HTMLInputElement>(null);
const [file, setFile] = useState<File | null>(null);
const [fileName, setFileName] = useState<string | null>(null);
Expand Down Expand Up @@ -84,6 +88,7 @@ export const AddResume = () => {
variant: 'destructive',
});
}
onClose?.();
return toast({
title: response.message,
variant: 'success',
Expand Down
7 changes: 6 additions & 1 deletion src/components/user-multistep-form/addExperience-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import { useToast } from '../ui/use-toast';
import { LoadingSpinner } from '../loading-spinner';
import { useState } from 'react';

export const AddExperience = () => {
interface AddExperienceProps {
onClose?: () => void;
}

export const AddExperience = ({ onClose }: AddExperienceProps) => {
const form = useForm<expFormSchemaType>({
resolver: zodResolver(expFormSchema),
defaultValues: {
Expand Down Expand Up @@ -65,6 +69,7 @@ export const AddExperience = () => {
variant: 'success',
});
form.reset(form.formState.defaultValues);
onClose?.();
} catch (_error) {
toast({
title: 'Something went wrong while Adding Experience',
Expand Down
5 changes: 3 additions & 2 deletions src/components/user-multistep-form/user-multistep-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const forms = [
export default function VerticalLinearStepper() {
const router = useRouter();
const [activeStep, setActiveStep] = useState(0);
const [isDialogOpen, setIsDialogOpen] = useState(false);

const handleNext = () => {
setActiveStep((prevActiveStep) => prevActiveStep + 1);
Expand Down Expand Up @@ -111,7 +112,7 @@ export default function VerticalLinearStepper() {
<StepContent>
{form.description}
<Box sx={{ mb: 2 }}>
<Dialog>
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<DialogTrigger asChild>
<Button
variant="contained"
Expand All @@ -126,7 +127,7 @@ export default function VerticalLinearStepper() {
<DialogTitle>{form.label}</DialogTitle>
</DialogHeader>
<div className="flex-grow overflow-y-auto px-6 pb-6">
<form.component />
<form.component onClose={() => setIsDialogOpen(false)} />
</div>
</DialogContent>
</Dialog>
Expand Down