-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into 48-whatsappbutton
- Loading branch information
Showing
65 changed files
with
3,654 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:20-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json . | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
EXPOSE 3000 | ||
|
||
CMD npm run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'http', | ||
hostname: 'localhost', | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
export default nextConfig; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use server"; | ||
|
||
import { REVIEWS_API } from "@/lib/constants"; | ||
|
||
export const login = async (email: string, password: string) => { | ||
try { | ||
const response = await fetch(`${REVIEWS_API}/admin-users/logIn`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ thisUser: email, pass: password }), | ||
method: "POST", | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
if (!response.ok) { | ||
return { | ||
error: "Acceso no autorizado", | ||
}; | ||
} | ||
return { | ||
token: data.access_token, | ||
}; | ||
} catch (error) { | ||
return { | ||
error: "Error al intentar iniciar sesión, intente más tarde", | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,101 @@ | ||
"use server"; | ||
|
||
export const getReviews = async () => { | ||
import { REVIEWS_API } from "@/lib/constants"; | ||
import { reviewSchema } from "@/app/(admin)/atc24$rw/admin/schema"; | ||
import { z } from "zod"; | ||
import { revalidatePath } from "next/cache"; | ||
import { Review } from "@/types"; | ||
|
||
export const getReviews = async (): Promise<Review[]> => { | ||
try { | ||
const response = await fetch("http://localhost:3005/reviews"); | ||
const response = await fetch(`${REVIEWS_API}/reviews`, { | ||
cache: "no-store" | ||
}); | ||
const { data } = await response.json(); | ||
return data; | ||
return data ?? []; | ||
} catch (_) { | ||
return []; | ||
} | ||
}; | ||
export const createReview = async (formData: FormData, token: string) => { | ||
try { | ||
const response = await fetch(`${REVIEWS_API}/reviews`, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
body: formData, | ||
}); | ||
const data = await response.json(); | ||
if (!response.ok && response.status == 401) { | ||
return { | ||
error: "Su sesión ha expirado, ingrese nuevamente", | ||
}; | ||
} | ||
if (!response.ok) { | ||
return { | ||
error: data.message, | ||
}; | ||
} | ||
revalidatePath("atc24$rw/admin"); | ||
revalidatePath("/"); | ||
return { | ||
success: "Se creó una nueva reseña", | ||
}; | ||
} catch (error) { | ||
return { | ||
error: "Error al crear la reseña", | ||
}; | ||
} | ||
}; | ||
export const deleteReview = async (id: string, token: string) => { | ||
const response = await fetch(`${REVIEWS_API}/reviews/${id}`, { | ||
method: "DELETE", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
const data = await response.json(); | ||
if (!response.ok && response.status == 401) { | ||
return { | ||
error: "Su sesión ha expirado, ingrese nuevamente", | ||
}; | ||
} | ||
if (!response.ok) { | ||
return { | ||
error: data.message, | ||
}; | ||
} | ||
revalidatePath("atc24$rw/admin"); | ||
revalidatePath("/"); | ||
return { | ||
success: "Se eliminó la reseña", | ||
}; | ||
}; | ||
export const updateReview = async (formData: FormData, token: string) => { | ||
const response = await fetch(`${REVIEWS_API}/reviews`, { | ||
method: "PATCH", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
body: formData, | ||
}); | ||
const data = await response.json(); | ||
if (!response.ok && response.status == 401) { | ||
return { | ||
error: "Su sesión ha expirado, ingrese nuevamente", | ||
}; | ||
} | ||
if (!response.ok) { | ||
return { | ||
error: data.message, | ||
}; | ||
} | ||
|
||
revalidatePath("atc24$rw/admin"); | ||
revalidatePath("/"); | ||
|
||
return { | ||
success: "Se ha actualizado la reseña", | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from "@/components/ui/alert-dialog"; | ||
|
||
interface DeleteAlertProps { | ||
children: React.ReactNode; | ||
onDelete: () => void; | ||
} | ||
|
||
export const DeleteAlert = ({ children, onDelete }: DeleteAlertProps) => { | ||
return ( | ||
<AlertDialog> | ||
<AlertDialogTrigger className="w-full flex justify-end items-center">{children}</AlertDialogTrigger> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle> | ||
¿Esta seguro de eliminar esta reseña? | ||
</AlertDialogTitle> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancelar</AlertDialogCancel> | ||
<AlertDialogAction onClick={onDelete} className="bg-primary-lm dark:text-white hover:dark:bg-primary-lm/85">Confirmar</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use client"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "@/components/ui/dialog"; | ||
import { useReviewFormModal } from "@/store/useReviewFormModal"; | ||
import { ReviewForm } from "./ReviewForm"; | ||
|
||
export const FormModal = () => { | ||
const { isOpen, onClose, defaultValues } = useReviewFormModal(); | ||
|
||
const title = !defaultValues?.id ? "Añadir reseña" : "Editar reseña"; | ||
|
||
return ( | ||
<Dialog open={isOpen} onOpenChange={onClose}> | ||
<DialogContent className="h-full md:h-auto overflow-y-auto"> | ||
<DialogHeader> | ||
<DialogTitle>{title}</DialogTitle> | ||
</DialogHeader> | ||
<ReviewForm review={defaultValues} /> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
src/app/(admin)/atc24$rw/admin/components/ModalProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
import { useEffect, useState } from "react"; | ||
import { FormModal } from "./FormModal"; | ||
|
||
export const ModalProvider = () => { | ||
const [isMounted, setIsMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsMounted(true); | ||
}, []); | ||
|
||
if (!isMounted) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<FormModal /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.