Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

add simple company show

Jean-Baptiste Kaiser8d26d6a68794
diff --git a/src/components/atomic-crm/companies/CompanyAside.tsx b/src/components/atomic-crm/companies/CompanyAside.tsx
index e33cc4c8..612d4f7f 100644
--- a/src/components/atomic-crm/companies/CompanyAside.tsx
+++ b/src/components/atomic-crm/companies/CompanyAside.tsx
@@ -52,7 +52,7 @@ export const CompanyAside = ({ link = "edit" }: CompanyAsideProps) => {
);
};
-const CompanyInfo = ({ record }: { record: Company }) => {
+export const CompanyInfo = ({ record }: { record: Company }) => {
if (!record.website && !record.linkedin_url && !record.phone_number) {
return null;
}
@@ -96,7 +96,7 @@ const CompanyInfo = ({ record }: { record: Company }) => {
);
};
-const ContextInfo = ({ record }: { record: Company }) => {
+export const ContextInfo = ({ record }: { record: Company }) => {
if (!record.revenue && !record.id) {
return null;
}
@@ -127,7 +127,7 @@ const ContextInfo = ({ record }: { record: Company }) => {
);
};
-const AddressInfo = ({ record }: { record: Company }) => {
+export const AddressInfo = ({ record }: { record: Company }) => {
if (
!record.address &&
!record.city &&
@@ -148,7 +148,7 @@ const AddressInfo = ({ record }: { record: Company }) => {
);
};
-const AdditionalInfo = ({ record }: { record: Company }) => {
+export const AdditionalInfo = ({ record }: { record: Company }) => {
if (
!record.created_at &&
!record.sales_id &&
diff --git a/src/components/atomic-crm/companies/CompanyShow.tsx b/src/components/atomic-crm/companies/CompanyShow.tsx
index 5c064050..168c061f 100644
--- a/src/components/atomic-crm/companies/CompanyShow.tsx
+++ b/src/components/atomic-crm/companies/CompanyShow.tsx
@@ -26,14 +26,59 @@ import { findDealLabel } from "../deals/deal";
import { Status } from "../misc/Status";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Company, Contact, Deal } from "../types";
-import { CompanyAside } from "./CompanyAside";
+import {
+ AdditionalInfo,
+ AddressInfo,
+ CompanyAside,
+ CompanyInfo,
+ ContextInfo,
+} from "./CompanyAside";
import { CompanyAvatar } from "./CompanyAvatar";
+import { useIsMobile } from "@/hooks/use-mobile";
+import MobileHeader from "../layout/MobileHeader";
+import { MobileBackButton } from "../misc/MobileBackButton";
+import { MobileContent } from "../layout/MobileContent";
+
+export const CompanyShow = () => {
+ const isMobile = useIsMobile();
+
+ return (
+ <ShowBase>
+ {isMobile ? <CompanyShowContentMobile /> : <CompanyShowContent />}
+ </ShowBase>
+ );
+};
-export const CompanyShow = () => (
- <ShowBase>
- <CompanyShowContent />
- </ShowBase>
-);
+const CompanyShowContentMobile = () => {
+ const { record, isPending } = useShowContext<Company>();
+ if (isPending || !record) return null;
+
+ return (
+ <>
+ <MobileHeader>
+ <MobileBackButton to="/" />
+ <div className="flex flex-1">
+ <h1 className="text-xl font-semibold">Company</h1>
+ </div>
+ </MobileHeader>
+
+ <MobileContent>
+ <div className="mb-6">
+ <div className="flex items-center mb-4">
+ <CompanyAvatar />
+ <div className="mx-3 flex-1">
+ <h2 className="text-2xl font-bold">{record.name}</h2>
+ </div>
+ </div>
+ </div>
+ <CompanyInfo record={record} />
+ <AddressInfo record={record} />
+ <ContextInfo record={record} />
+ <AdditionalInfo record={record} />
+ </MobileContent>
+ </>
+ );
+};
const CompanyShowContent = () => {
const { record, isPending } = useShowContext<Company>();
diff --git a/src/components/atomic-crm/contacts/ContactShow.tsx b/src/components/atomic-crm/contacts/ContactShow.tsx
index 6d3f6ebd..39453804 100644
--- a/src/components/atomic-crm/contacts/ContactShow.tsx
+++ b/src/components/atomic-crm/contacts/ContactShow.tsx
@@ -10,6 +10,7 @@ import MobileHeader from "../layout/MobileHeader";
import { MobileContent } from "../layout/MobileContent";
import { useState } from "react";
import { Button } from "@/components/ui/button";
+import { Separator } from "@/components/ui/separator";
import { CompanyAvatar } from "../companies/CompanyAvatar";
import { NoteCreate, NotesIterator } from "../notes";
@@ -146,16 +147,25 @@ const ContactShowContentMobile = () => {
<TabsContent value="details" className="mt-4">
<div className="space-y-6">
<div>
- <h3 className="text-lg font-semibold mb-3">Personal info</h3>
- <ContactPersonalInfo />
+ <h3 className="text-lg font-semibold">Personal info</h3>
+ <Separator />
+ <div className="mt-3">
+ <ContactPersonalInfo />
+ </div>
</div>
<div>
- <h3 className="text-lg font-semibold mb-3">Background info</h3>
- <ContactBackgroundInfo />
+ <h3 className="text-lg font-semibold">Background info</h3>
+ <Separator />
+ <div className="mt-3">
+ <ContactBackgroundInfo />
+ </div>
</div>
<div>
- <h3 className="text-lg font-semibold mb-3">Tags</h3>
- <TagsListEdit />
+ <h3 className="text-lg font-semibold">Tags</h3>
+ <Separator />
+ <div className="mt-3">
+ <TagsListEdit />
+ </div>
</div>
</div>
</TabsContent>
diff --git a/src/components/atomic-crm/misc/AsideSection.tsx b/src/components/atomic-crm/misc/AsideSection.tsx
index d0cab091..db716017 100644
--- a/src/components/atomic-crm/misc/AsideSection.tsx
+++ b/src/components/atomic-crm/misc/AsideSection.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import { Separator } from "@/components/ui/separator";
import { cn } from "@/lib/utils";
+import { useIsMobile } from "@/hooks/use-mobile";
export type AsideSectionProps = {
title: string;
@@ -9,9 +10,12 @@ export type AsideSectionProps = {
};
export function AsideSection({ title, children, noGap }: AsideSectionProps) {
+ const isMobile = useIsMobile();
return (
<div className="mb-6 text-sm">
- <h3 className="font-medium pb-1">{title}</h3>
+ <h3 className={isMobile ? "text-lg font-semibold" : "font-medium pb-1"}>
+ {title}
+ </h3>
<Separator />
<div className={cn("pt-2 flex flex-col", { "gap-1": !noGap })}>
{children}
diff --git a/src/components/atomic-crm/root/CRM.tsx b/src/components/atomic-crm/root/CRM.tsx
index 3c0cb6ba..5b011035 100644
--- a/src/components/atomic-crm/root/CRM.tsx
+++ b/src/components/atomic-crm/root/CRM.tsx
@@ -47,6 +47,7 @@ import { useIsMobile } from "@/hooks/use-mobile.ts";
import { MobileTasksList } from "../tasks/MobileTasksList.tsx";
import { ContactList } from "../contacts/ContactList.tsx";
import { ContactShow } from "../contacts/ContactShow.tsx";
+import { CompanyShow } from "../companies/CompanyShow.tsx";
export type CRMProps = {
dataProvider?: DataProvider;
@@ -220,6 +221,7 @@ const MobileAdmin = (props: CoreAdminProps) => {
show={ContactShow}
recordRepresentation={contacts.recordRepresentation}
/>
+ <Resource name="companies" show={CompanyShow} />
<Resource name="tasks" list={MobileTasksList} />
</Admin>
);