From 43cc02f371b3fff37caf168131f79fe795a53d58 Mon Sep 17 00:00:00 2001 From: Telkens Date: Tue, 27 Aug 2024 13:55:35 -0500 Subject: [PATCH] Fix width table columns --- src/actions/admin.ts | 2 +- .../atc24$rw/admin/components/FormModal.tsx | 2 +- .../atc24$rw/admin/components/ReviewForm.tsx | 4 +- .../admin/components/ReviewsTable.tsx | 38 ++++++++++--------- src/app/(admin)/atc24$rw/admin/page.tsx | 2 +- src/app/(admin)/atc24$rw/page.tsx | 2 +- src/components/ui/switch.tsx | 2 +- 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/actions/admin.ts b/src/actions/admin.ts index f2b9c97..23cc57c 100644 --- a/src/actions/admin.ts +++ b/src/actions/admin.ts @@ -14,7 +14,7 @@ export const login = async (email: string, password: string) => { const data = await response.json(); - if (data.statusCode === 401) { + if (!response.ok) { return { error: "Acceso no autorizado", }; diff --git a/src/app/(admin)/atc24$rw/admin/components/FormModal.tsx b/src/app/(admin)/atc24$rw/admin/components/FormModal.tsx index 7cb4341..700a176 100644 --- a/src/app/(admin)/atc24$rw/admin/components/FormModal.tsx +++ b/src/app/(admin)/atc24$rw/admin/components/FormModal.tsx @@ -15,7 +15,7 @@ export const FormModal = () => { return ( - + {title} diff --git a/src/app/(admin)/atc24$rw/admin/components/ReviewForm.tsx b/src/app/(admin)/atc24$rw/admin/components/ReviewForm.tsx index 3646298..020ed38 100644 --- a/src/app/(admin)/atc24$rw/admin/components/ReviewForm.tsx +++ b/src/app/(admin)/atc24$rw/admin/components/ReviewForm.tsx @@ -165,7 +165,7 @@ export const ReviewForm = ({ review }: ReviewFormProps) => { name="user" render={({ field }) => ( - Nombre del usuario + Usuario @@ -201,7 +201,7 @@ export const ReviewForm = ({ review }: ReviewFormProps) => { ) : (
-

Carga la imagen del usuario, arrastra o haz click

+

Carga la imagen del usuario, arrastra o haz click

)} diff --git a/src/app/(admin)/atc24$rw/admin/components/ReviewsTable.tsx b/src/app/(admin)/atc24$rw/admin/components/ReviewsTable.tsx index d48b7b6..ff8dce5 100644 --- a/src/app/(admin)/atc24$rw/admin/components/ReviewsTable.tsx +++ b/src/app/(admin)/atc24$rw/admin/components/ReviewsTable.tsx @@ -20,6 +20,7 @@ import { FormEvent, useTransition } from "react"; import { useRouter } from "next/navigation"; import { REVIEWS_API } from "@/lib/constants"; import { cn, createFormData } from "@/lib/utils"; +import useMobile from "@/hooks/useMobile"; interface ReviewsTableProps { reviews: Review[]; @@ -28,6 +29,7 @@ interface ReviewsTableProps { export const ReviewsTable = ({ reviews }: ReviewsTableProps) => { const router = useRouter(); const [isPending, startTransition] = useTransition(); + const { isMobile } = useMobile(); const { onOpen } = useReviewFormModal(); const handleDelele = (id: string) => { @@ -69,7 +71,7 @@ export const ReviewsTable = ({ reviews }: ReviewsTableProps) => { updateReview(formData, token) .then((data) => { if (data.success) { - toast.success(data.success); + toast.success(`Reseña ${value ? "activada" : "desactivada"} exitosamente`); } if (data.error) { toast.error(data.error); @@ -84,12 +86,12 @@ export const ReviewsTable = ({ reviews }: ReviewsTableProps) => { - Usuario + Usuario Texto - Calificación - Visibilidad - Editar - + {isMobile ? "⭐️" : "Calificación"} + Estado + Editar + Eliminar @@ -100,22 +102,22 @@ export const ReviewsTable = ({ reviews }: ReviewsTableProps) => { JSON.parse(review.active) == false ? "opacity-50" : "" )}> -
+
- {review.user} + {review.user}
- + {review.review} - {review.rating} - + {review.rating} + { disabled={isPending} /> - + onOpen(review)} - className="cursor-pointer" + className="cursor-pointer mx-auto" /> - + handleDelele(review.id)}> @@ -146,7 +148,7 @@ export const ReviewsTable = ({ reviews }: ReviewsTableProps) => { ))}
- diff --git a/src/app/(admin)/atc24$rw/admin/page.tsx b/src/app/(admin)/atc24$rw/admin/page.tsx index 1ba6891..c9843fa 100644 --- a/src/app/(admin)/atc24$rw/admin/page.tsx +++ b/src/app/(admin)/atc24$rw/admin/page.tsx @@ -5,7 +5,7 @@ const AdminPage = async () => { const reviews = await getReviews(); return ( -
+
); diff --git a/src/app/(admin)/atc24$rw/page.tsx b/src/app/(admin)/atc24$rw/page.tsx index 758b817..fcc579a 100644 --- a/src/app/(admin)/atc24$rw/page.tsx +++ b/src/app/(admin)/atc24$rw/page.tsx @@ -81,7 +81,7 @@ const LoginPage = () => { )} /> -