diff --git a/package.json b/package.json index 2bed454..4b6bbcb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@hookform/resolvers": "^3.9.0", "@radix-ui/react-avatar": "^1.1.0", + "@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-hover-card": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e7705f..7299522 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@radix-ui/react-avatar': specifier: ^1.1.0 version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1) + '@radix-ui/react-checkbox': + specifier: ^1.1.2 + version: 1.1.2(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1) '@radix-ui/react-dialog': specifier: ^1.1.2 version: 1.1.2(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1) @@ -119,6 +122,9 @@ dependencies: stripe: specifier: ^17.1.0 version: 17.2.0 + sweetalert2: + specifier: ^11.14.3 + version: 11.14.4 tailwind-merge: specifier: ^2.5.2 version: 2.5.2 @@ -151,6 +157,9 @@ devDependencies: '@types/react-dom': specifier: ^18 version: 18.3.0 + '@types/react-select-country-list': + specifier: ^2.2.3 + version: 2.2.3 eslint: specifier: ^8 version: 8.57.0 @@ -668,6 +677,33 @@ packages: react-dom: 18.3.1(react@18.3.1) dev: false + /@radix-ui/react-checkbox@1.1.2(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-/i0fl686zaJbDQLNKrkCbMyDm6FQMt4jg323k7HuqitoANm9sE23Ql8yOK3Wusk34HSLKDChhMux05FnP6KUkw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@radix-ui/primitive': 1.1.0 + '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.4)(react@18.3.1) + '@radix-ui/react-context': 1.1.1(@types/react@18.3.4)(react@18.3.1) + '@radix-ui/react-presence': 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1) + '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1) + '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.4)(react@18.3.1) + '@radix-ui/react-use-previous': 1.1.0(@types/react@18.3.4)(react@18.3.1) + '@radix-ui/react-use-size': 1.1.0(@types/react@18.3.4)(react@18.3.1) + '@types/react': 18.3.4 + '@types/react-dom': 18.3.0 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + dev: false + /@radix-ui/react-collection@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-GZsZslMJEyo1VKm5L1ZJY8tGDxZNPAoUeQUIbKeJfoi7Q4kmig5AsgLMYYuyYbfjd8fBmFORAIwYAkXMnXZgZw==} peerDependencies: @@ -1847,6 +1883,10 @@ packages: dependencies: '@types/react': 18.3.4 + /@types/react-select-country-list@2.2.3: + resolution: {integrity: sha512-nffcYOwuun+5B0EWqubK+amHpPdK9Xj20xkLYNqYrzmESd8FnpLwHsS79ClLAWA9y+icVA8gWPkbwBp1gpjSwA==} + dev: true + /@types/react@18.3.4: resolution: {integrity: sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==} dependencies: @@ -5690,6 +5730,10 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} + /sweetalert2@11.14.4: + resolution: {integrity: sha512-8QMzjxCuinwm18EK5AtYvuhP+lRMRxTWVXy8om9wGlULsXSI4TD29kyih3VYrSXMMBlD4EShFvNC7slhTC7j0w==} + dev: false + /tailwind-merge@2.5.2: resolution: {integrity: sha512-kjEBm+pvD+6eAwzJL2Bi+02/9LFLal1Gs61+QB7HvTfQQ0aXwC5LGT8PEt1gS0CWKktKe6ysPTAy3cBC5MeiIg==} dev: false diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..f6bd5cb Binary files /dev/null and b/public/favicon.ico differ diff --git a/src/app/admin/BusinessActionButtons.tsx b/src/app/admin/BusinessActionButtons.tsx new file mode 100644 index 0000000..ef213db --- /dev/null +++ b/src/app/admin/BusinessActionButtons.tsx @@ -0,0 +1,104 @@ +"use client"; + +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { Check, X } from "lucide-react"; +import { useState } from "react"; +import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; +import { rejectBusiness, approveBusiness } from "@/lib/data/applicationMutate"; +import toast from "react-hot-toast"; + +interface BusinessActionButtonsProps { + businessApplicationId: number; +} + +export function BusinessActionButtons({ businessApplicationId }: BusinessActionButtonsProps) { + const [isRejectLoading, setIsRejectLoading] = useState(false); + const [isApproveLoading, setIsApproveLoading] = useState(false); + const [isRejectOpen, setIsRejectOpen] = useState(false); + const [isApproveOpen, setIsApproveOpen] = useState(false); + + const onRejectBusiness = async () => { + try { + setIsRejectLoading(true); + const client = createSupabaseClient(); + + const { error } = await rejectBusiness(client, businessApplicationId); + if (error) throw error; + + toast.success("Rejected successfully"); + window.location.reload(); + } catch (error) { + toast.error("Failed to reject business"); + console.error("Failed to reject business:", error); + } finally { + setIsRejectLoading(false); + setIsRejectOpen(false); + } + }; + + const onApproveBusiness = async () => { + try { + setIsApproveLoading(true); + const client = createSupabaseClient(); + + const { error } = await approveBusiness(client, businessApplicationId); + if (error) throw error; + + toast.success("Approved successfully"); + window.location.reload(); + } catch (error) { + toast.error("Failed to approve business"); + console.error("Failed to approve business:", error); + } finally { + setIsApproveLoading(false); + setIsApproveOpen(false); + } + }; + + return ( +