Skip to content

Commit

Permalink
Merge branch 'development' into 48-whatsappbutton
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMejia77 authored Oct 7, 2024
2 parents 9d0e857 + c0299d1 commit 77c9535
Show file tree
Hide file tree
Showing 65 changed files with 3,654 additions and 282 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
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
11 changes: 10 additions & 1 deletion next.config.mjs
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;
1,543 changes: 1,329 additions & 214 deletions package-lock.json

Large diffs are not rendered by default.

48 changes: 31 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,47 @@
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@types/react-star-ratings": "^2.3.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"clsx": "^2.1.1",
"keen-slider": "^6.8.6",
"next": "14.1.0",
"next-themes": "^0.2.1",
"react": "^18",
"react-dom": "^18",
"react-fast-marquee": "^1.6.4",
"react-icons": "^5.0.1",
"next": "14.2.10",
"next-themes": "^0.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-dropzone": "^14.2.3",
"react-fast-marquee": "^1.6.5",
"react-hook-form": "^7.53.0",
"react-icons": "^5.3.0",
"react-image-gallery": "^1.3.0",
"react-page-scroller": "^3.0.1",
"react-star-ratings": "^2.3.0",
"react-svg": "^16.1.33",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7"
"react-svg": "^16.1.34",
"sonner": "^1.5.0",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8",
"zustand": "^4.5.5"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react-image-gallery": "^1.2.4",
"autoprefixer": "^10.0.1",
"autoprefixer": "^10.4.20",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
"eslint-config-next": "14.2.10",
"postcss": "^8.4.45",
"tailwindcss": "^3.4.11",
"typescript": "^5.6.2"
}
}
1 change: 1 addition & 0 deletions public/icons/como-comprar/add-to-cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/como-comprar/packaging.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/como-comprar/payment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/como-comprar/received.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/como-comprar/select-article.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/como-comprar/shipping.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/buy/b6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/dashboardReviewsL.webp
Binary file not shown.
Binary file added public/images/dashboardReviewsR.webp
Binary file not shown.
30 changes: 30 additions & 0 deletions src/actions/admin.ts
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",
}
}
};
96 changes: 93 additions & 3 deletions src/actions/reviews.ts
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",
};
};
34 changes: 34 additions & 0 deletions src/app/(admin)/atc24$rw/admin/components/DeleteAlert.tsx
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>
);
};
26 changes: 26 additions & 0 deletions src/app/(admin)/atc24$rw/admin/components/FormModal.tsx
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 src/app/(admin)/atc24$rw/admin/components/ModalProvider.tsx
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 />
</>
);
};
Loading

0 comments on commit 77c9535

Please sign in to comment.