Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivanshPlays committed Nov 19, 2024
1 parent c7d13ad commit 5ac4686
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 166 deletions.
128 changes: 0 additions & 128 deletions app/(Customer)/user/page.tsx

This file was deleted.

25 changes: 12 additions & 13 deletions app/api/webhook/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import prismadb from "@/lib/prismadb";
import { NextResponse } from "next/server";
import { validateWebhookSignature } from "razorpay/dist/utils/razorpay-utils";
// import crypto from "crypto";
Expand Down Expand Up @@ -77,18 +76,18 @@ export async function POST(req: Request) {
}

// Update the order in the database
await prismadb.order.update({
where: {
RZP_OID: entity.order_id,
},
data: {
name,
contact,
email,
address,
isPaid: true,
},
});
// await prismadb.order.update({
// where: {
// RZP_OID: entity.order_id,
// },
// data: {
// name,
// contact,
// email,
// address,
// isPaid: true,
// },
// });

// console.log("Order update successful:", res);
return NextResponse.json(
Expand Down
35 changes: 18 additions & 17 deletions components/chatbot/chatbot.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { useState } from "react";
import ChatBot from "react-simple-chatbot";


const Chatbot = () => {
const [userMessage, setUserMessage] = useState("");
const [userMessage, setUserMessage] = useState<string>("");

const handleMessage = (msg) => {
const handleMessage = (msg: string) => {
setUserMessage(msg); // Update user message on each interaction
};

const flow = [
// , { ChatBotProps, Step }
const flow= [
{
id: "1",
message: "Welcome to **EzyShop**, your one-stop shop for everything you need! What is your name?",
trigger: "2", // Proceed to step 2 after the question
trigger: "2",
},
{
id: "2",
user: true, // Wait for user input (name)
trigger: "3", // Proceed to step 3 once the user responds
user: true, // Correctly capturing user input without a message
trigger: "3",
},
{
id: "3",
message: "Hi {previousValue}, nice to meet you! How can I assist you today?",
trigger: "4", // Proceed to step 4 after greeting
trigger: "4",
},
{
id: "4",
message: "Please choose an option below to proceed:",
trigger: "5", // Provide options to the user
trigger: "5",
},
{
id: "5",
Expand All @@ -37,11 +38,11 @@ const Chatbot = () => {
{ value: "Explore vendor details", label: "Explore vendors", trigger: "16" },
],
},
// ------------------- Request a product flow -------------------
// Request a product flow
{
id: "6",
message: "Great! What type of product would you like to request from a vendor?",
trigger: "7", // Go to step 7 to choose the product
trigger: "7",
},
{
id: "7",
Expand All @@ -60,13 +61,13 @@ const Chatbot = () => {
{
id: "10",
message: "Your request has been forwarded! A vendor will contact you shortly. Is there anything else I can help you with?",
trigger: "5", // Give another set of options or end the chat
trigger: "5",
},
// ------------------- Browse Categories flow -------------------
// Browse Categories flow
{
id: "8",
message: "Here are some categories you can explore:",
trigger: "11", // Proceed to category options
trigger: "11",
},
{
id: "11",
Expand All @@ -82,7 +83,7 @@ const Chatbot = () => {
message: "Here are some popular {previousValue} products:\n\n - Smart TV (₹30,000)\n - Bluetooth Headphones (₹3,500)\n - Gaming Laptop (₹70,000)\n\nWould you like to explore more, request a product, or view other categories?",
trigger: "5",
},
// ------------------- Explore Vendor Flow -------------------
// Explore Vendor Flow
{
id: "16",
message: "Here are some top vendors on EzyShop:",
Expand All @@ -101,11 +102,11 @@ const Chatbot = () => {
message: "{previousValue} specializes in {previousValue.split(' ')[1]} products. Here are some of their offerings:\n - Smartwatch (₹5,000)\n - Wireless Earbuds (₹2,000)\n - 4K TV (₹45,000)\n\nRating: 4.8/5\nWould you like to request a product or explore other vendors?",
trigger: "5",
},
// ------------------- Thank you message -------------------
// Thank you message
{
id: "14",
message: "Thank you for using EzyShop! Enjoy your shopping experience!",
end: true, // End the chat
end: true,
},
];

Expand Down
3 changes: 3 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
images: {
remotePatterns: [
{
Expand All @@ -11,6 +12,8 @@ const nextConfig = {
],
domains: ['avatars.githubusercontent.com'],
},


// async headers() {
// return [
// {
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"next-themes": "^0.3.0",
"nodemailer": "^6.9.15",
"query-string": "^9.1.1",
"razorpay": "^2.9.5",
"react": "^18.3.1",
"react-confetti": "^6.1.0",
"react-dom": "^18.3.1",
Expand Down
19 changes: 11 additions & 8 deletions types/react-simple-chatbot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ declare module 'react-simple-chatbot' {
import * as React from 'react';

interface Step {
id: string;
message: string;
trigger: string;
user?: boolean;
end?: boolean;
delay?: number;
options?: { value: string; label: string; trigger: string }[];
asMessage?: boolean;
id: string; // A unique identifier for each step
message?: string; // Message to be displayed to the user
trigger?: string; // The ID of the next step to trigger
user?: boolean; // If true, allows user input at this step
options?: Array<{
value: string; // The value that is used when an option is selected
label: string; // The text shown for the option
trigger: string; // The step ID to go to after this option is selected
}>;
end?: boolean; // If true, ends the chat at this step
}


interface ChatBotProps {
steps: Step[];
Expand Down

0 comments on commit 5ac4686

Please sign in to comment.