updated create businessname functionality
This commit is contained in:
parent
67534515c2
commit
b2bdaa4550
5 changed files with 76 additions and 3 deletions
|
@ -1,11 +1,29 @@
|
||||||
"use client"
|
"use client"
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
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 React, { useState } from 'react'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
|
||||||
const CreateBusiness = () => {
|
const CreateBusiness = () => {
|
||||||
const [businessName, setBusinessName] = useState();
|
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 (
|
return (
|
||||||
<div className='my-20 flex flex-col items-center gap-10 px-5'>
|
<div className='my-20 flex flex-col items-center gap-10 px-5'>
|
||||||
|
@ -17,7 +35,7 @@ const CreateBusiness = () => {
|
||||||
<label className='font-semibold text-[#31363F]'>Name:</label>
|
<label className='font-semibold text-[#31363F]'>Name:</label>
|
||||||
<Input onChange={(ev) => setBusinessName(ev.target.value)} placeholder="Your organization/team/etc. name" className='mt-1 text-sm'/>
|
<Input onChange={(ev) => setBusinessName(ev.target.value)} placeholder="Your organization/team/etc. name" className='mt-1 text-sm'/>
|
||||||
</div>
|
</div>
|
||||||
<Button className="w-full mt-[30px]" disabled={!businessName}>Create</Button>
|
<Button onClick={onCreateBusiness} disabled={!businessName} className="w-full mt-[30px]">Create</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
import { Toaster } from "sonner";
|
||||||
|
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({ subsets: ["latin"] });
|
||||||
|
|
||||||
|
@ -11,7 +12,10 @@ export const metadata = {
|
||||||
export default function RootLayout({ children }) {
|
export default function RootLayout({ children }) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body className={inter.className}>{children}</body>
|
<body className={inter.className}>
|
||||||
|
<Toaster/>
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
29
scheduler_app/components/ui/sonner.jsx
Normal file
29
scheduler_app/components/ui/sonner.jsx
Normal file
|
@ -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 (
|
||||||
|
(<Sonner
|
||||||
|
theme={theme}
|
||||||
|
className="toaster group"
|
||||||
|
toastOptions={{
|
||||||
|
classNames: {
|
||||||
|
toast:
|
||||||
|
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
||||||
|
description: "group-[.toast]:text-muted-foreground",
|
||||||
|
actionButton:
|
||||||
|
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
||||||
|
cancelButton:
|
||||||
|
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
{...props} />)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Toaster }
|
20
scheduler_app/package-lock.json
generated
20
scheduler_app/package-lock.json
generated
|
@ -15,9 +15,11 @@
|
||||||
"firebase": "^10.11.0",
|
"firebase": "^10.11.0",
|
||||||
"lucide-react": "^0.373.0",
|
"lucide-react": "^0.373.0",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18",
|
"react": "^18",
|
||||||
"react-dom": "^18",
|
"react-dom": "^18",
|
||||||
"react-icons": "^5.1.0",
|
"react-icons": "^5.1.0",
|
||||||
|
"sonner": "^1.4.41",
|
||||||
"tailwind-merge": "^2.3.0",
|
"tailwind-merge": "^2.3.0",
|
||||||
"tailwindcss-animate": "^1.0.7"
|
"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": {
|
"node_modules/next/node_modules/postcss": {
|
||||||
"version": "8.4.31",
|
"version": "8.4.31",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
||||||
|
@ -4092,6 +4103,15 @@
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"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": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
"firebase": "^10.11.0",
|
"firebase": "^10.11.0",
|
||||||
"lucide-react": "^0.373.0",
|
"lucide-react": "^0.373.0",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18",
|
"react": "^18",
|
||||||
"react-dom": "^18",
|
"react-dom": "^18",
|
||||||
"react-icons": "^5.1.0",
|
"react-icons": "^5.1.0",
|
||||||
|
"sonner": "^1.4.41",
|
||||||
"tailwind-merge": "^2.3.0",
|
"tailwind-merge": "^2.3.0",
|
||||||
"tailwindcss-animate": "^1.0.7"
|
"tailwindcss-animate": "^1.0.7"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue