diff --git a/src/app/dashboard/businesses/[id]/edit/page.tsx b/src/app/dashboard/businesses/[id]/edit/page.tsx index 77f75bc..9ba59b9 100644 --- a/src/app/dashboard/businesses/[id]/edit/page.tsx +++ b/src/app/dashboard/businesses/[id]/edit/page.tsx @@ -1,24 +1,12 @@ "use client"; -import Link from "next/link"; import { useParams } from "next/navigation"; import { BusinessForm } from "~/components/forms/business-form"; -import { PageHeader } from "~/components/layout/page-header"; export default function EditBusinessPage() { const params = useParams(); const businessId = Array.isArray(params?.id) ? params.id[0] : params?.id; if (!businessId) return null; - return ( -
- - - -
- ); + return ; } diff --git a/src/app/dashboard/businesses/[id]/page.tsx b/src/app/dashboard/businesses/[id]/page.tsx index 7f9051c..65bc84b 100644 --- a/src/app/dashboard/businesses/[id]/page.tsx +++ b/src/app/dashboard/businesses/[id]/page.tsx @@ -4,6 +4,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; import { Button } from "~/components/ui/button"; import { Badge } from "~/components/ui/badge"; import { PageHeader } from "~/components/layout/page-header"; +import { Separator } from "~/components/ui/separator"; import Link from "next/link"; import { Edit, @@ -15,6 +16,7 @@ import { DollarSign, Globe, Hash, + ArrowLeft, } from "lucide-react"; interface BusinessDetailPageProps { @@ -41,72 +43,91 @@ export default async function BusinessDetailPage({ }; return ( -
-
- - - +
+ + + + -
- {/* Business Information Card */} -
- - - - - Business Information - - - - {/* Basic Info */} -
+
+ {/* Business Information Card */} +
+ + + +
+ +
+ Business Information +
+
+ + {/* Contact Information */} +
+

+ Contact Information +

+
{business.email && (
-
- +
+
-

Email

-

{business.email}

+

+ Email +

+

+ {business.email} +

)} {business.phone && (
-
- +
+
-

Phone

-

{business.phone}

+

+ Phone +

+

+ {business.phone} +

)} {business.website && (
-
- +
+
-

+

Website

{business.website} @@ -116,152 +137,169 @@ export default async function BusinessDetailPage({ {business.taxId && (
-
- +
+
-

Tax ID

-

{business.taxId}

+

+ Tax ID +

+

+ {business.taxId} +

)}
+
- {/* Address */} - {(business.addressLine1 ?? business.city ?? business.state) && ( -
-
-
- -
-
-

- Address -

-
-
-
- {business.addressLine1 &&

{business.addressLine1}

} - {business.addressLine2 &&

{business.addressLine2}

} - {(business.city ?? - business.state ?? - business.postalCode) && ( -

- {[business.city, business.state, business.postalCode] - .filter(Boolean) - .join(", ")} -

- )} - {business.country &&

{business.country}

} -
-
- )} - - {/* Business Since */} -
-
- -
+ {/* Address */} + {(business.addressLine1 ?? business.city ?? business.state) && ( + <> +
-

- Business Added -

-

- {formatDate(business.createdAt)} -

+

+ Business Address +

+
+
+ +
+
+ {business.addressLine1 && ( +

+ {business.addressLine1} +

+ )} + {business.addressLine2 && ( +

+ {business.addressLine2} +

+ )} + {(business.city ?? + business.state ?? + business.postalCode) && ( +

+ {[ + business.city, + business.state, + business.postalCode, + ] + .filter(Boolean) + .join(", ")} +

+ )} + {business.country && ( +

{business.country}

+ )} +
+
-
+ + )} - {/* Default Business Badge */} - {business.isDefault && ( + + + {/* Business Metadata */} +
+

Business Details

+
-
- +
+
-

Status

- Default Business +

+ Business Added +

+

+ {formatDate(business.createdAt)} +

- )} - - -
- {/* Settings & Actions Card */} -
- - - - - Business Settings - - - -
-

Default Business

-

- {business.isDefault ? ( - Yes - ) : ( - No - )} -

-
- -
-

- Quick Actions -

-
- - - - - - -
-
-
-
- - {/* Information Card */} - - - - About This Business - - - -
-

- This business profile is used for generating invoices and - represents your company information to clients. -

+ {/* Default Business Badge */} {business.isDefault && ( -

- This is your default business and will be automatically - selected when creating new invoices. -

+
+
+ +
+
+

+ Status +

+ + Default Business + +
+
)}
-
-
-
+
+ + +
+ + {/* Settings & Actions Card */} +
+ + + +
+ +
+ Quick Actions +
+
+ +
+ + +
+
+
+ + {/* Information Card */} + + + About This Business + + +
+

+ This business profile is used for generating invoices and + represents your company information to clients. +

+ {business.isDefault && ( +

+ This is your default business and will be automatically + selected when creating new invoices. +

+ )} +
+
+
diff --git a/src/app/dashboard/businesses/_components/businesses-data-table.tsx b/src/app/dashboard/businesses/_components/businesses-data-table.tsx index 5bd32ce..59a1f56 100644 --- a/src/app/dashboard/businesses/_components/businesses-data-table.tsx +++ b/src/app/dashboard/businesses/_components/businesses-data-table.tsx @@ -53,11 +53,8 @@ const formatAddress = (business: Business) => { return parts.join(", ") || "—"; }; -export function BusinessesDataTable({ - businesses: initialBusinesses, -}: BusinessesDataTableProps) { +export function BusinessesDataTable({ businesses }: BusinessesDataTableProps) { const router = useRouter(); - const [businesses, setBusinesses] = useState(initialBusinesses); const [businessToDelete, setBusinessToDelete] = useState( null, ); @@ -67,7 +64,6 @@ export function BusinessesDataTable({ const deleteBusinessMutation = api.businesses.delete.useMutation({ onSuccess: () => { toast.success("Business deleted successfully"); - setBusinesses(businesses.filter((b) => b.id !== businessToDelete?.id)); setBusinessToDelete(null); void utils.businesses.getAll.invalidate(); }, @@ -95,8 +91,8 @@ export function BusinessesDataTable({ const business = row.original; return (
-
- +
+

{business.name}

@@ -186,10 +182,10 @@ export function BusinessesDataTable({ return (
- + -
- - handleTaxIdChange(e.target.value)} - placeholder={PLACEHOLDERS.taxId} - className={`${errors.taxId ? "border-destructive" : ""}`} - disabled={isSubmitting} - maxLength={10} - /> - {errors.taxId && ( -

{errors.taxId}

- )} + + {/* Main Form Container - styled like data table */} +
+ {/* Basic Information */} + + +
+
+ +
+
+ Basic Information +

+ Enter your business details +

+
- -
- - handleInputChange("email", e.target.value)} - placeholder={PLACEHOLDERS.email} - className={`${errors.email ? "border-destructive" : ""}`} - disabled={isSubmitting} - /> - {errors.email && ( -

{errors.email}

- )} -
- -
- - handlePhoneChange(e.target.value)} - placeholder={PLACEHOLDERS.phone} - className={`${errors.phone ? "border-destructive" : ""}`} - disabled={isSubmitting} - /> - {errors.phone && ( -

{errors.phone}

- )} -
-
- -
- - handleInputChange("website", e.target.value)} - placeholder={PLACEHOLDERS.website} - className={`${errors.website ? "border-destructive" : ""}`} - disabled={isSubmitting} - /> - {errors.website && ( -

{errors.website}

- )} -
- - - - {/* Address */} - - -
-
- - + +
+
+ + + handleInputChange("name", e.target.value) + } + placeholder={PLACEHOLDERS.name} + className={`${errors.name ? "border-destructive" : ""}`} + disabled={isSubmitting} /> - - -
-
- Business Address -

- Your business location -

-
-
- - - - - + {errors.name && ( +

{errors.name}

+ )} +
- {/* Settings */} - - -
-
- +
+ + handleTaxIdChange(e.target.value)} + placeholder={PLACEHOLDERS.taxId} + className={`${errors.taxId ? "border-destructive" : ""}`} + disabled={isSubmitting} + maxLength={10} + /> + {errors.taxId && ( +

{errors.taxId}

+ )} +
+ +
+ + + handleInputChange("email", e.target.value) + } + placeholder={PLACEHOLDERS.email} + className={`${errors.email ? "border-destructive" : ""}`} + disabled={isSubmitting} + /> + {errors.email && ( +

{errors.email}

+ )} +
+ +
+ + handlePhoneChange(e.target.value)} + placeholder={PLACEHOLDERS.phone} + className={`${errors.phone ? "border-destructive" : ""}`} + disabled={isSubmitting} + /> + {errors.phone && ( +

{errors.phone}

+ )} +
-
- Settings -

- Configure business preferences -

-
-
-
- -
-
-
- - -
- +
+
+ + {/* Settings */} + + +
+
+ +
+
+ Settings +

+ Configure business preferences +

+
+
+
+ +
+
+ +

+ Set this as your default business for new invoices +

+
+ + handleInputChange("isDefault", checked) + } + disabled={isSubmitting} + /> +
+
+
+
+ +
-
+ ); }