Skip to content

Commit

Permalink
fix: fix unexpected 500
Browse files Browse the repository at this point in the history
  • Loading branch information
chowjustin committed Nov 12, 2024
1 parent 277c677 commit 451f962
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/app/dashboard/tambah/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import TextArea from "@/components/form/TextArea";
import "@react-pdf-viewer/core/lib/styles/index.css";
import { Worker, Viewer, SpecialZoomLevel } from "@react-pdf-viewer/core";
import { useEffect, useRef, useState } from "react";
import useFileStore from "@/app/stores/useFileStore";

type SignUpRequest = {
recipient: string;
Expand Down Expand Up @@ -223,27 +222,14 @@ export default function TambahAjuan() {
SignUpMutation(formData);
};

const { isFileDeleted, setIsFileDeleted } = useFileStore();

const [fileUrl, setFileUrl] = useState<string>("");

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
const handleFileUpload = (files: any) => {
if (files.length > 0) {
setFileUrl(files[0].preview);
setIsFileDeleted(false);
} else {
setFileUrl("");
setIsFileDeleted(true);
}
};

useEffect(() => {
if (isFileDeleted) {
setFileUrl("");
}
}, [isFileDeleted]);

return (
<section className="p-6">
<div className="relative w-full h-full rounded-[15px] min-h-[64px] overflow-hidden">
Expand Down
6 changes: 3 additions & 3 deletions src/components/form/UploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ImagePreviewCard from "@/components/image/ImagePreviewCard";
import Typography from "@/components/Typography";
import clsxm from "@/lib/clsxm";
import { FileWithPreview } from "@/types/form/dropzone";
import useFileStore from "@/app/stores/useFileStore";
// import useFileStore from "@/app/stores/useFileStore";

export type DropzoneInputProps = {
id: string;
Expand Down Expand Up @@ -97,13 +97,13 @@ export default function UploadFile({
[clearErrors, maxFiles, maxSize, setError, setValue, id],
);

const { setIsFileDeleted } = useFileStore();
// const { setIsFileDeleted } = useFileStore();

const onDelete = (index: number) => {
const updatedFiles = files.filter((_, i) => i !== index);
setFiles(updatedFiles);
setValue(id, updatedFiles);
setIsFileDeleted(true);
// setIsFileDeleted(true);
};

React.useEffect(() => {
Expand Down

0 comments on commit 451f962

Please sign in to comment.