Skip to content

Commit

Permalink
fix rdi errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Mar 4, 2024
1 parent 8085386 commit fc38a01
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/core/DropzoneField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function DropzoneField({

const { getRootProps, getInputProps, acceptedFiles } = useDropzone({
disabled: loading,
accept:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' as unknown as Accept,
//@ts-ignore
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
onDrop,
});
const acceptedFilename =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
Box,
Button,
DialogContent,
DialogTitle,
Expand Down Expand Up @@ -110,9 +111,13 @@ export function RegistrationDataImportCreateDialog(): React.ReactElement {
</DialogTitleWrapper>
<DialogContent>
<FormControl variant="outlined">
<StyledInputLabel>{t('Import From')}</StyledInputLabel>
<StyledInputLabel size="small" htmlFor="import-type-select">
{t('Import From')}
</StyledInputLabel>
<ComboBox
id="import-type-select"
value={importType}
size="small"
defaultValue=""
variant="outlined"
label=""
Expand All @@ -130,7 +135,7 @@ export function RegistrationDataImportCreateDialog(): React.ReactElement {
</MenuItem>
</ComboBox>
</FormControl>
{importTypeForm}
<Box mt={2}>{importTypeForm}</Box>
</DialogContent>
<StyledDialogFooter data-cy="dialog-actions-container">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export function KoboProjectSelect(): React.ReactElement {
return (
<>
<FormControl variant="outlined">
<StyledInputLabel>{t('Select Project')}</StyledInputLabel>
<StyledInputLabel size="small">{t('Select Project')}</StyledInputLabel>
<ComboBox
{...field}
variant="outlined"
size="small"
label={t('Kobo Project')}
disabled={loading}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { CircularProgress } from '@mui/material';
import { Box, CircularProgress } from '@mui/material';
import { Field, FormikProvider, useFormik } from 'formik';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -105,9 +105,9 @@ export function CreateImportFromXlsxForm({
}, [xlsxImportData]);

return (
<div>
<FormikProvider value={formik}>
<DropzoneField loading={saveXlsxLoading} />
<FormikProvider value={formik}>
<DropzoneField loading={saveXlsxLoading} />
<Box mt={2}>
<Field
name="name"
fullWidth
Expand All @@ -116,18 +116,18 @@ export function CreateImportFromXlsxForm({
variant="outlined"
component={FormikTextField}
/>
<ScreenBeneficiaryField />
{saveXlsxLoading ? (
<CircularProgressContainer>
<CircularProgress />
</CircularProgressContainer>
) : (
<XlsxImportDataRepresentation
xlsxImportData={xlsxImportData}
loading={saveXlsxLoading}
/>
)}
</FormikProvider>
</div>
</Box>
<ScreenBeneficiaryField />
{saveXlsxLoading ? (
<CircularProgressContainer>
<CircularProgress />
</CircularProgressContainer>
) : (
<XlsxImportDataRepresentation
xlsxImportData={xlsxImportData}
loading={saveXlsxLoading}
/>
)}
</FormikProvider>
);
}
11 changes: 8 additions & 3 deletions frontend/src/components/rdi/create/xlsx/DropzoneField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
import { Accept, useDropzone } from 'react-dropzone';
import { useDropzone } from 'react-dropzone';
import styled from 'styled-components';
import { useField } from 'formik';
import { useSnackbar } from '@hooks/useSnackBar';
Expand Down Expand Up @@ -31,6 +31,11 @@ export function DropzoneField({ loading }): React.ReactElement {
const { showMessage } = useSnackbar();
const onDrop = useCallback(
(acceptedFiles) => {
// Log the MIME types of the accepted files
acceptedFiles.forEach((file) => {
console.log(file.type);
});

if (acceptedFiles.length !== 1) {
return;
}
Expand All @@ -50,8 +55,8 @@ export function DropzoneField({ loading }): React.ReactElement {
);
const { getRootProps, getInputProps, acceptedFiles } = useDropzone({
disabled: loading,
accept:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' as unknown as Accept,
//@ts-ignore
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
onDrop,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const BigValue = styled.div`

const Error = styled.p`
color: ${({ theme }: { theme: MiśTheme }) => theme.hctPalette.red};
font-size: 12px;
`;
interface RegistrationDetailsProps {
registration: RegistrationDetailedFragment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import get from 'lodash/get';
import { Box, TextField } from '@mui/material';
import Autocomplete from '@mui/lab/Autocomplete';
import { useEffect, useState } from 'react';
Expand Down

0 comments on commit fc38a01

Please sign in to comment.