From dd9be4b565c6090dcdb399bacc4d7acd531e8545 Mon Sep 17 00:00:00 2001 From: Deepanshu Mishra Date: Thu, 24 Oct 2024 01:18:45 +0530 Subject: [PATCH] add logo upload --- .../migration.sql | 2 + prisma/schema.prisma | 1 + src/actions/auth.actions.ts | 3 +- src/components/Onboarding.tsx | 149 ------------------ src/components/auth/signup.tsx | 35 ++++ src/lib/validators/auth.validator.ts | 2 + 6 files changed, 42 insertions(+), 150 deletions(-) create mode 100644 prisma/migrations/20241023193014_added_logo_field/migration.sql delete mode 100644 src/components/Onboarding.tsx diff --git a/prisma/migrations/20241023193014_added_logo_field/migration.sql b/prisma/migrations/20241023193014_added_logo_field/migration.sql new file mode 100644 index 00000000..258c08ef --- /dev/null +++ b/prisma/migrations/20241023193014_added_logo_field/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Company" ADD COLUMN "logo" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index eee59b2d..14ec3d51 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -36,6 +36,7 @@ model User { model Company { id String @id @default(cuid()) name String + logo String? website String? description String? jobs Job[] diff --git a/src/actions/auth.actions.ts b/src/actions/auth.actions.ts index 8818d7be..a5b43444 100644 --- a/src/actions/auth.actions.ts +++ b/src/actions/auth.actions.ts @@ -72,6 +72,7 @@ export const signUp = withServerActionAsyncCatcher< name: _data.companyInfo.name, website: _data.companyInfo.website || '', description: _data.companyInfo.description || '', + logo: _data.companyInfo.logo || '', userId: user.id, }, }); @@ -84,6 +85,7 @@ export const signUp = withServerActionAsyncCatcher< title: 'Company Profile', companyName: _data.companyInfo.name, companyBio: _data.companyInfo.description || '', + companyLogo: _data.companyInfo.logo || '', companyEmail: baseData.email, category: 'Company', type: 'Full_time', @@ -91,7 +93,6 @@ export const signUp = withServerActionAsyncCatcher< city: '', address: '', application: '', - companyLogo: '', skills: [], }, }); diff --git a/src/components/Onboarding.tsx b/src/components/Onboarding.tsx deleted file mode 100644 index 8f90b99c..00000000 --- a/src/components/Onboarding.tsx +++ /dev/null @@ -1,149 +0,0 @@ -'use client'; - -import { useState } from 'react'; -import { useRouter } from 'next/navigation'; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogDescription, -} from '@/components/ui/dialog'; -import { Button } from '@/components/ui/button'; -import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; -import { Label } from '@/components/ui/label'; -import { Input } from '@/components/ui/input'; -import { Textarea } from '@/components/ui/textarea'; -import { Building, Check } from 'lucide-react'; -import { useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { z } from 'zod'; - -const companySetupSchema = z.object({ - companyName: z.string().min(1, 'Company name is required'), - companyWebsite: z.string().url('Invalid URL'), - description: z.string().min(10, 'Description must be at least 10 characters'), -}); - -type CompanySetupForm = z.infer; - -export default function OnboardingComponent() { - const [isOpen, setIsOpen] = useState(true); - const [selectedRole, setSelectedRole] = useState(null); - const [showCompanySetup, setShowCompanySetup] = useState(false); - const [showConfirmation, setShowConfirmation] = useState(false); - const router = useRouter(); - - const { - register, - handleSubmit, - formState: { errors }, - } = useForm({ - resolver: zodResolver(companySetupSchema), - }); - - const handleRoleSelection = (role: string) => { - setSelectedRole(role); - if (role === 'jobSeeker') { - router.push('/home'); - } else if (role === 'hr') { - setShowCompanySetup(true); - } - setIsOpen(false); - }; - - const handleCompanySetup = async () => { - setShowCompanySetup(false); - setShowConfirmation(true); - }; - - return ( -
- - - - Choose your role - - Select a role to personalize your experience - - - -
- - -
-
- - -
-
-
-
- - - - - - Set up your company profile for {selectedRole} - - -
-
- -
- - - {errors.companyName && ( -

{errors.companyName.message}

- )} - - {errors.companyWebsite && ( -

{errors.companyWebsite.message}

- )} -