From 10c66bca9527562c906072fbd9f51f7cffe54fcd Mon Sep 17 00:00:00 2001 From: magsyg Date: Sat, 7 Dec 2024 21:10:12 +0100 Subject: [PATCH] biome fix --- .../src/Components/InputFile/InputFile.tsx | 62 +++++++++---------- .../RecruitmentApplicationFormPage.tsx | 6 +- frontend/src/utils.ts | 4 +- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/frontend/src/Components/InputFile/InputFile.tsx b/frontend/src/Components/InputFile/InputFile.tsx index 7a5388dfc..f9faf56f9 100644 --- a/frontend/src/Components/InputFile/InputFile.tsx +++ b/frontend/src/Components/InputFile/InputFile.tsx @@ -3,10 +3,10 @@ import classNames from 'classnames'; import { type ChangeEvent, type ReactNode, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { KEY } from '~/i18n/constants'; +import { getFileNameFromUrl, isFileImage } from '~/utils'; +import { Link } from '../Link'; import { TimeDisplay } from '../TimeDisplay'; import styles from './InputFile.module.scss'; -import { Link } from '../Link'; -import { getFileNameFromUrl, isFileImage } from '~/utils'; export type InputFileType = 'image' | 'pdf' | 'any'; @@ -18,13 +18,12 @@ export type InputFileProps = { onSelected?: (file: File) => void; }; -export function InputFile({ fileType='any', label, existing_url, error = false, onSelected }: InputFileProps) { +export function InputFile({ fileType = 'any', label, existing_url, error = false, onSelected }: InputFileProps) { const { t } = useTranslation(); const [selectedFile, setSelectedFile] = useState(undefined); const [preview, setPreview] = useState(undefined); const [isImage, setIsImage] = useState(false); - function handleOnChange(e?: ChangeEvent) { if (e === undefined || onSelected === undefined) return; if (!e.target.files || e.target.files.length === 0) { @@ -62,7 +61,7 @@ export function InputFile({ fileType='any', label, existing_url, error = false, } return '*'; } - + const icons: Record = { image: 'mdi:image', pdf: 'mdi:file', @@ -88,37 +87,32 @@ export function InputFile({ fileType='any', label, existing_url, error = false, {t(KEY.inputfile_choose_a_file)} - { - (existing_url && !selectedFile) ? - ( - {getFileNameFromUrl(existing_url)} - ): - ( - {selectedFile?.name ?? t(KEY.inputfile_no_file_selected)} - ) - - - } + {existing_url && !selectedFile ? ( + + {getFileNameFromUrl(existing_url)} + + ) : ( + {selectedFile?.name ?? t(KEY.inputfile_no_file_selected)} + )} -
- {preview && - <> -
-

- -

-

{fileSizeMb} MB

-
- {isImage && ( -
- {preview && Preview} -
- ) - } - - } -
+
+ {preview && ( + <> +
+

+ +

+

{fileSizeMb} MB

+
+ {isImage && ( +
+ {preview && Preview} +
+ )} + + )} +
); diff --git a/frontend/src/Pages/RecruitmentApplicationFormPage/RecruitmentApplicationFormPage.tsx b/frontend/src/Pages/RecruitmentApplicationFormPage/RecruitmentApplicationFormPage.tsx index 5a49bb56c..b5d005731 100644 --- a/frontend/src/Pages/RecruitmentApplicationFormPage/RecruitmentApplicationFormPage.tsx +++ b/frontend/src/Pages/RecruitmentApplicationFormPage/RecruitmentApplicationFormPage.tsx @@ -209,7 +209,11 @@ export function RecruitmentApplicationFormPage() { >

{t(KEY.recruitment_application)}:

{' '} - + ) : (
diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts index 55a54e025..6d40cd0ef 100644 --- a/frontend/src/utils.ts +++ b/frontend/src/utils.ts @@ -152,8 +152,8 @@ export function getFullName(u: UserDto): string { } export function getFileNameFromUrl(url: string): string { - let url_split = url.split('/'); - return url_split[url_split.length-1]; + const url_split = url.split('/'); + return url_split[url_split.length - 1]; } export function isFileImage(file_name: string): boolean {