diff --git a/package-lock.json b/package-lock.json index b5245eb..9e937ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@chakra-ui/react": "2.8.2", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", + "@smastrom/react-rating": "1.5.0", "@tanstack/react-query": "5.51.11", "@tanstack/react-query-devtools": "5.51.11", "atropos": "2.0.2", @@ -3853,6 +3854,15 @@ "node": ">=14.18" } }, + "node_modules/@smastrom/react-rating": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@smastrom/react-rating/-/react-rating-1.5.0.tgz", + "integrity": "sha512-7vg3NRgO0tpvEunq8BEWA8qckNSd7x3dVGqaNEfLs3Ow4ibU2EEXJtnd7Yl44xOujWIzXM5Bk2VZm2DVm065Qw==", + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + } + }, "node_modules/@tanstack/query-core": { "version": "5.51.9", "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.51.9.tgz", @@ -16332,6 +16342,12 @@ "@sentry/types": "8.19.0" } }, + "@smastrom/react-rating": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@smastrom/react-rating/-/react-rating-1.5.0.tgz", + "integrity": "sha512-7vg3NRgO0tpvEunq8BEWA8qckNSd7x3dVGqaNEfLs3Ow4ibU2EEXJtnd7Yl44xOujWIzXM5Bk2VZm2DVm065Qw==", + "requires": {} + }, "@tanstack/query-core": { "version": "5.51.9", "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.51.9.tgz", diff --git a/package.json b/package.json index 0d67b6d..f44d274 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@chakra-ui/react": "2.8.2", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", + "@smastrom/react-rating": "1.5.0", "@tanstack/react-query": "5.51.11", "@tanstack/react-query-devtools": "5.51.11", "atropos": "2.0.2", diff --git a/src/components/forms/FormEdit.tsx b/src/components/forms/FormEdit.tsx index 1a507f0..95ae4b3 100644 --- a/src/components/forms/FormEdit.tsx +++ b/src/components/forms/FormEdit.tsx @@ -39,6 +39,7 @@ import { } from '@components/forms/utils/utilsForm'; import { useMyToast } from '@hooks/useMyToast'; import { useGenerateSlug } from '@hooks/useGenerateSlug'; +import { Rating } from '@smastrom/react-rating'; const Cropper = lazy(() => import('react-cropper')); export function FormEdit({ @@ -54,6 +55,7 @@ export function FormEdit({ format, pathUrl, image, + rating, }: BookType) { const { handleSubmit, @@ -87,7 +89,9 @@ export function FormEdit({ url, public_id, }, + rating, }); + const { mutate, isPending, isSuccess, error } = useUpdateBook(books); useGenerateSlug(books.title, setBooks); // Genera el pathUrl (Slug) @@ -121,6 +125,13 @@ export function FormEdit({ handleImage(e, setCropData, onOpen); } + function handleRatingChange(newRating: number) { + setBooks((books) => ({ + ...books, + rating: newRating, + })); + } + function getCropData() { getCrop(crop, setPreviewImg, books, setBooks, onClose); } @@ -212,7 +223,7 @@ export function FormEdit({ return ( <> - + + + + + Calificación{' '} + + (Opcional) + + + + + key !== 'sourceLink') + .filter(([key]) => key !== 'sourceLink' && key !== 'rating') .every(([, value]) => value) && book.category.length > 0 ); } @@ -111,6 +113,13 @@ export function FormNewBook() { handleImage(e, setCropData, onOpen); } + function handleRatingChange(newRating: number) { + setBooks((books) => ({ + ...books, + rating: newRating, + })); + } + function getCropData() { getCrop(crop, setPreviewImg, books, setBooks, onClose); } @@ -209,7 +218,7 @@ export function FormNewBook() { p={{ base: 5, md: 10 }} rounded='lg' border='1px' - maxWidth='900px' + maxWidth='1000px' > Los campos con el{' '} @@ -294,7 +303,7 @@ export function FormNewBook() { required: 'Sinopsis es obligatorio', })} id='sinopsis' - rows={12} + rows={17} mb='5' bg={bgColorInput} name='synopsis' @@ -542,6 +551,21 @@ export function FormNewBook() { placeholder='Elija un Formato' /> + + + + Calificación{' '} + + (Opcional) + + + + +