From eaf0f5688ed888f00b9634a538457d0f70df443d Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 11 Feb 2025 22:06:57 +0100 Subject: [PATCH] [FIX] add end correction --- front/src/scene/home/AddPage.tsx | 68 +++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/front/src/scene/home/AddPage.tsx b/front/src/scene/home/AddPage.tsx index 075525f..cc13929 100644 --- a/front/src/scene/home/AddPage.tsx +++ b/front/src/scene/home/AddPage.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; -import { Button, Flex, Input, Table, Text } from '@chakra-ui/react'; +import { Box, Button, Flex, Input, Table, Text } from '@chakra-ui/react'; import { LuTrash } from 'react-icons/lu'; import { MdCloudUpload } from 'react-icons/md'; @@ -20,6 +20,10 @@ import { TopBar } from '@/components/TopBar/TopBar'; import { FormSelect } from '@/components/form/FormSelect'; import { Formidable, useFormidable } from '@/components/formidable'; import { PopUpUploadProgress } from '@/components/popup/PopUpUploadProgress'; +import { + NumberInputField, + NumberInputRoot, +} from '@/components/ui/number-input'; import { useAlbumService, useOrderedAlbums } from '@/service/Album'; import { useArtistService, useOrderedArtists } from '@/service/Artist'; import { useGenderService, useOrderedGenders } from '@/service/Gender'; @@ -90,7 +94,12 @@ export const AddPage = () => { const { store: storeTrack } = useTrackService(); const { session } = useServiceContext(); - const form = useFormidable({}); + const form = useFormidable({ + configuration: { + enableModifyNotification: false, + enableReset: false, + }, + }); const updateNeedSend = () => { if (parsedElement.length === 0) { @@ -328,20 +337,22 @@ export const AddPage = () => { } setIndexUpload(index); console.log( - `Start upload of file: ${index}: ${parsedElement[index].title}` + `Start upload of file: ${index}: ${parsedElement[index].title} ==> ${JSON.stringify(parsedElement[index], null, 2)}` ); + const data = { + title: parsedElement[index].title, + file: parsedElement[index].file, + albumId: form.values['albumId'] ?? undefined, + artistId: form.values['artistId'] ?? undefined, + genderId: form.values['genderId'] ?? undefined, + trackId: parsedElement[index].trackId ?? undefined, + }; + console.log(`data= ${JSON.stringify(data, null, 2)}`); storeTrack .update( TrackResource.uploadTrack({ restConfig: session.getRestConfig(), - data: { - title: parsedElement[index].title, - file: parsedElement[index].file, - albumId: form.values['albumId'] ?? undefined, - artistId: form.values['artistId'] ?? undefined, - genderId: form.values['genderId'] ?? undefined, - trackId: parsedElement[index].trackId ?? undefined, - }, + data, callbacks: { progressUpload: progressUpload, }, @@ -358,10 +369,17 @@ export const AddPage = () => { setUploadError(JSON.stringify(error, null, 2)); }); }, - [setUploadError, setIndexUpload, storeTrack, parsedElement] + [ + setUploadError, + setIndexUpload, + storeTrack, + parsedElement, + form, + form.values, + ] ); - const sendFile = (): void => { + const sendFile = (_data): void => { console.log(`Send file requested ... ${parsedElement.length}`); setUploadError(undefined); setIsFinishedUpload(false); @@ -449,14 +467,12 @@ export const AddPage = () => { label="Gender" name="genderId" options={dataGenders} - keyInputValue="name" addNewItem={addNewGender} /> @@ -464,7 +480,6 @@ export const AddPage = () => { label="Album" name="albumId" options={dataAlbums} - keyInputValue="name" addNewItem={addNewAlbum} suggestion={suggestedAlbum} /> @@ -475,7 +490,9 @@ export const AddPage = () => { > - track ID + + track ID + Title actions @@ -484,18 +501,19 @@ export const AddPage = () => { {parsedElement.map((data) => ( - onTrackId(data, e.target.value)} + onTrackId(data, e.value)} + min={0} + max={5000} backgroundColor={ data.trackIdDetected === true ? 'darkred' : undefined } - /> + > + + {