Skip to content

Commit

Permalink
Add import modal content interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats committed Dec 20, 2024
1 parent e7c0b6b commit fcdf964
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/client/src/pages/detail/attachments/fileDropzone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const FileDropzone = props => {
const removeFile = fileToRemove => {
setFiles(prevFiles => prevFiles.filter(file => file !== fileToRemove));
if (setFileType) {
setFileType(null);
setFileType("");
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ export interface NewBoreholeProps extends WorkgroupSelectProps {
toggleDrawer: (open: boolean) => void;
}

export interface ImportContentProps {
setSelectedFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
}

export interface ImportModalProps extends ImportContentProps {
export interface ImportModalProps {
modal: boolean;
creating: boolean;
selectedFile: Blob[] | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ImportModal = ({
}: ImportModalProps) => {
const { showAlert } = useContext(AlertContext);
const { t } = useTranslation();
const [fileType, setFileType] = useState<string | null>(null); // Track file type
const [fileType, setFileType] = useState<string>(""); // Track file type

const handleImportResponse = async (response: Response) => {
setCreating(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { useCallback } from "react";
import React, { useCallback } from "react";
import { useTranslation } from "react-i18next";
import { Box, Stack } from "@mui/material/";
import { downloadCodelistCsv } from "../../../../api/fetchApiV2.js";
import { StackHalfWidth } from "../../../../components/styledComponents.ts";
import { capitalizeFirstLetter } from "../../../../utils.ts";
import Downloadlink from "../../../detail/attachments/downloadlink.jsx";
import { FileDropzone } from "../../../detail/attachments/fileDropzone.jsx";
import { ImportContentProps } from "../commons/actionsInterfaces.js";

interface ImportModalContentProps {
setSelectedFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
setFileType: (type: string) => void;
fileType: string;
}
const ExampleHeadings = (headings: string) => {
return (
<Box
Expand All @@ -23,11 +27,7 @@ const ExampleHeadings = (headings: string) => {
);
};

const ImportModalContent = ({
setSelectedFile,
setFileType,
fileType,
}: ImportContentProps & { setFileType: (type: string) => void } & { fileType: string | null }) => {
const ImportModalContent = ({ setSelectedFile, setFileType, fileType }: ImportModalContentProps) => {
const { t } = useTranslation();

const handleCsvFileChange = useCallback(
Expand Down

0 comments on commit fcdf964

Please sign in to comment.