diff --git a/scheduler_app/app/(routes)/create_business/page.js b/scheduler_app/app/(routes)/create_business/page.js index 1dfd7e3..126525f 100644 --- a/scheduler_app/app/(routes)/create_business/page.js +++ b/scheduler_app/app/(routes)/create_business/page.js @@ -1,11 +1,29 @@ "use client" import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' +import { app } from '@/config/FirebaseConfig' +import { useKindeBrowserClient } from '@kinde-oss/kinde-auth-nextjs' +import { doc, getFirestore, setDoc } from 'firebase/firestore' +import { useRouter } from 'next/navigation' import React, { useState } from 'react' +import { toast } from 'sonner' const CreateBusiness = () => { const [businessName, setBusinessName] = useState(); - + const db = getFirestore(app); + const {user} = useKindeBrowserClient(); + const router = useRouter(); + const onCreateBusiness = async () => { + await setDoc(doc(db, 'Business', user.email), { + businessName: businessName, + email: user.email, + userName: user.given_name+" " + user.family_name + }).then(res => { + console.log("Data is saved") + toast('You have successful created your name!') + router.replace('/dashboard'); + }) + } return (
@@ -17,7 +35,7 @@ const CreateBusiness = () => { setBusinessName(ev.target.value)} placeholder="Your organization/team/etc. name" className='mt-1 text-sm'/>
- + ) diff --git a/scheduler_app/app/layout.js b/scheduler_app/app/layout.js index 438e80d..2b516c0 100644 --- a/scheduler_app/app/layout.js +++ b/scheduler_app/app/layout.js @@ -1,5 +1,6 @@ import { Inter } from "next/font/google"; import "./globals.css"; +import { Toaster } from "sonner"; const inter = Inter({ subsets: ["latin"] }); @@ -11,7 +12,10 @@ export const metadata = { export default function RootLayout({ children }) { return ( - {children} + + + {children} + ); } diff --git a/scheduler_app/components/ui/sonner.jsx b/scheduler_app/components/ui/sonner.jsx new file mode 100644 index 0000000..bd51a92 --- /dev/null +++ b/scheduler_app/components/ui/sonner.jsx @@ -0,0 +1,29 @@ +"use client"; +import { useTheme } from "next-themes" +import { Toaster as Sonner } from "sonner" + +const Toaster = ({ + ...props +}) => { + const { theme = "system" } = useTheme() + + return ( + () + ); +} + +export { Toaster } diff --git a/scheduler_app/package-lock.json b/scheduler_app/package-lock.json index 6bd6596..bd5b479 100644 --- a/scheduler_app/package-lock.json +++ b/scheduler_app/package-lock.json @@ -15,9 +15,11 @@ "firebase": "^10.11.0", "lucide-react": "^0.373.0", "next": "14.2.3", + "next-themes": "^0.3.0", "react": "^18", "react-dom": "^18", "react-icons": "^5.1.0", + "sonner": "^1.4.41", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7" }, @@ -3559,6 +3561,15 @@ } } }, + "node_modules/next-themes": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.3.0.tgz", + "integrity": "sha512-/QHIrsYpd6Kfk7xakK4svpDI5mmXP0gfvCoJdGpZQ2TOrQZmsW0QxjaiLn8wbIKjtm4BTSqLoix4lxYYOnLJ/w==", + "peerDependencies": { + "react": "^16.8 || ^17 || ^18", + "react-dom": "^16.8 || ^17 || ^18" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -4092,6 +4103,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/sonner": { + "version": "1.4.41", + "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.4.41.tgz", + "integrity": "sha512-uG511ggnnsw6gcn/X+YKkWPo5ep9il9wYi3QJxHsYe7yTZ4+cOd1wuodOUmOpFuXL+/RE3R04LczdNCDygTDgQ==", + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + } + }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", diff --git a/scheduler_app/package.json b/scheduler_app/package.json index da5a10f..0d8094a 100644 --- a/scheduler_app/package.json +++ b/scheduler_app/package.json @@ -16,9 +16,11 @@ "firebase": "^10.11.0", "lucide-react": "^0.373.0", "next": "14.2.3", + "next-themes": "^0.3.0", "react": "^18", "react-dom": "^18", "react-icons": "^5.1.0", + "sonner": "^1.4.41", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7" },