A full-featured CRM built with React, shadcn/ui, and Supabase.
Add offline support
fzaninotto9f88c24d0671
diff --git a/package-lock.json b/package-lock.jsonindex 8e7368ba..1af3c2cc 100644--- a/package-lock.json+++ b/package-lock.json@@ -30,7 +30,9 @@"@radix-ui/react-tooltip": "^1.2.8","@streamparser/json-whatwg": "^0.0.22","@tailwindcss/vite": "^4.1.18",+ "@tanstack/query-async-storage-persister": "^5.90.22","@tanstack/react-query": "^5.90.16",+ "@tanstack/react-query-persist-client": "^5.90.22","@types/qs": "^6.14.0","class-variance-authority": "^0.7.1","clsx": "^2.1.1",@@ -7792,29 +7794,73 @@"vite": "^5.2.0 || ^6 || ^7"}},+ "node_modules/@tanstack/query-async-storage-persister": {+ "version": "5.90.22",+ "resolved": "https://registry.npmjs.org/@tanstack/query-async-storage-persister/-/query-async-storage-persister-5.90.22.tgz",+ "integrity": "sha512-I8Dbi79aoM2S2VqfuxTG13TkqmiDSiZ95Bi1YRXvwGVMsOnaJ99Ou1dIw53kHY3y10Vgwv3YYThw4TN/FM/N3A==",+ "license": "MIT",+ "dependencies": {+ "@tanstack/query-core": "5.90.20",+ "@tanstack/query-persist-client-core": "5.91.19"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/tannerlinsley"+ }+ },"node_modules/@tanstack/query-core": {- "version": "5.90.16",- "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.16.tgz",- "integrity": "sha512-MvtWckSVufs/ja463/K4PyJeqT+HMlJWtw6PrCpywznd2NSgO3m4KwO9RqbFqGg6iDE8vVMFWMeQI4Io3eEYww==",+ "version": "5.90.20",+ "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.20.tgz",+ "integrity": "sha512-OMD2HLpNouXEfZJWcKeVKUgQ5n+n3A2JFmBaScpNDUqSrQSjiveC7dKMe53uJUg1nDG16ttFPz2xfilz6i2uVg==","license": "MIT","funding": {"type": "github","url": "https://github.com/sponsors/tannerlinsley"}},+ "node_modules/@tanstack/query-persist-client-core": {+ "version": "5.91.19",+ "resolved": "https://registry.npmjs.org/@tanstack/query-persist-client-core/-/query-persist-client-core-5.91.19.tgz",+ "integrity": "sha512-whrASqbVq8261Ue+/ZzpHsrLDYVfRaENs4HTdLuYKxawkGWzdMfV7BmOdWl8ZF0mEBEbrQR8V6oE3R635JF2Fw==",+ "license": "MIT",+ "dependencies": {+ "@tanstack/query-core": "5.90.20"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/tannerlinsley"+ }+ },"node_modules/@tanstack/react-query": {- "version": "5.90.16",- "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.16.tgz",- "integrity": "sha512-bpMGOmV4OPmif7TNMteU/Ehf/hoC0Kf98PDc0F4BZkFrEapRMEqI/V6YS0lyzwSV6PQpY1y4xxArUIfBW5LVxQ==",+ "version": "5.90.20",+ "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.20.tgz",+ "integrity": "sha512-vXBxa+qeyveVO7OA0jX1z+DeyCA4JKnThKv411jd5SORpBKgkcVnYKCiBgECvADvniBX7tobwBmg01qq9JmMJw==",+ "license": "MIT",+ "dependencies": {+ "@tanstack/query-core": "5.90.20"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/tannerlinsley"+ },+ "peerDependencies": {+ "react": "^18 || ^19"+ }+ },+ "node_modules/@tanstack/react-query-persist-client": {+ "version": "5.90.22",+ "resolved": "https://registry.npmjs.org/@tanstack/react-query-persist-client/-/react-query-persist-client-5.90.22.tgz",+ "integrity": "sha512-BrD3Y/SsrSIDl+t/gpYvjvGHXd7m7oF+GIqktKE8LmTgt7bS1lYHd/CLkVxMPixTU53gHHVFfPNGmY7Hv4L/7g==","license": "MIT","dependencies": {- "@tanstack/query-core": "5.90.16"+ "@tanstack/query-persist-client-core": "5.91.19"},"funding": {"type": "github","url": "https://github.com/sponsors/tannerlinsley"},"peerDependencies": {+ "@tanstack/react-query": "^5.90.20","react": "^18 || ^19"}},diff --git a/package.json b/package.jsonindex e448ae00..8e755942 100644--- a/package.json+++ b/package.json@@ -43,7 +43,9 @@"@radix-ui/react-tooltip": "^1.2.8","@streamparser/json-whatwg": "^0.0.22","@tailwindcss/vite": "^4.1.18",+ "@tanstack/query-async-storage-persister": "^5.90.22","@tanstack/react-query": "^5.90.16",+ "@tanstack/react-query-persist-client": "^5.90.22","@types/qs": "^6.14.0","class-variance-authority": "^0.7.1","clsx": "^2.1.1",diff --git a/src/components/atomic-crm/dashboard/MobileDashboard.tsx b/src/components/atomic-crm/dashboard/MobileDashboard.tsxindex 816f571e..faf77a1a 100644--- a/src/components/atomic-crm/dashboard/MobileDashboard.tsx+++ b/src/components/atomic-crm/dashboard/MobileDashboard.tsx@@ -1,4 +1,5 @@-import { useGetList } from "ra-core";+import { useGetList, useTimeout } from "ra-core";+import { Skeleton } from "@/components/ui/skeleton";import type { Contact, ContactNote } from "../types";import { DashboardActivityLog } from "./DashboardActivityLog";@@ -32,6 +33,16 @@ const Wrapper = ({ children }: { children: React.ReactNode }) => {);};+const Loading = () => (+ <Wrapper>+ <Skeleton className="h-4 w-3/4 mb-4" />+ <Skeleton className="h-4 w-full mb-2" />+ <Skeleton className="h-4 w-full mb-2" />+ <Skeleton className="h-4 w-full mb-2" />+ <Skeleton className="h-4 w-full mb-2" />+ </Wrapper>+);+export const MobileDashboard = () => {const {data: dataContact,@@ -40,16 +51,16 @@ export const MobileDashboard = () => {} = useGetList<Contact>("contacts", {pagination: { page: 1, perPage: 1 },});-const { total: totalContactNotes, isPending: isPendingContactNotes } =useGetList<ContactNote>("contact_notes", {pagination: { page: 1, perPage: 1 },});+ const oneSecondHasPassed = useTimeout(1000);const isPending = isPendingContact || isPendingContactNotes;if (isPending) {- return null;+ return oneSecondHasPassed ? <Loading /> : null;}if (!totalContact) {diff --git a/src/components/atomic-crm/root/CRM.tsx b/src/components/atomic-crm/root/CRM.tsxindex 134ae0ac..4ddb5423 100644--- a/src/components/atomic-crm/root/CRM.tsx+++ b/src/components/atomic-crm/root/CRM.tsx@@ -8,6 +8,9 @@ import {} from "ra-core";import { useEffect } from "react";import { Route } from "react-router";+import { QueryClient } from "@tanstack/react-query";+import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";+import { createAsyncStoragePersister } from "@tanstack/query-async-storage-persister";import { Admin } from "@/components/admin/admin";import { ForgotPasswordPage } from "@/components/supabase/forgot-password-page";import { SetPasswordPage } from "@/components/supabase/set-password-page";@@ -194,29 +197,50 @@ const DesktopAdmin = (props: CoreAdminProps) => {};const MobileAdmin = (props: CoreAdminProps) => {+ const queryClient = new QueryClient({+ defaultOptions: {+ queries: {+ gcTime: 1000 * 60 * 60 * 24, // 24 hours+ },+ },+ });+ const asyncStoragePersister = createAsyncStoragePersister({+ storage: localStorage,+ });+return (- <Admin layout={MobileLayout} dashboard={MobileDashboard} {...props}>- <CustomRoutes noLayout>- <Route path={SignupPage.path} element={<SignupPage />} />- <Route- path={ConfirmationRequired.path}- element={<ConfirmationRequired />}- />- <Route path={SetPasswordPage.path} element={<SetPasswordPage />} />- <Route- path={ForgotPasswordPage.path}- element={<ForgotPasswordPage />}+ <PersistQueryClientProvider+ client={queryClient}+ persistOptions={{ persister: asyncStoragePersister }}+ >+ <Admin+ queryClient={queryClient}+ layout={MobileLayout}+ dashboard={MobileDashboard}+ {...props}+ >+ <CustomRoutes noLayout>+ <Route path={SignupPage.path} element={<SignupPage />} />+ <Route+ path={ConfirmationRequired.path}+ element={<ConfirmationRequired />}+ />+ <Route path={SetPasswordPage.path} element={<SetPasswordPage />} />+ <Route+ path={ForgotPasswordPage.path}+ element={<ForgotPasswordPage />}+ />+ <Route path={OAuthConsentPage.path} element={<OAuthConsentPage />} />+ </CustomRoutes>+ <Resource+ name="contacts"+ list={ContactListMobile}+ show={ContactShow}+ recordRepresentation={contacts.recordRepresentation}/>- <Route path={OAuthConsentPage.path} element={<OAuthConsentPage />} />- </CustomRoutes>- <Resource- name="contacts"- list={ContactListMobile}- show={ContactShow}- recordRepresentation={contacts.recordRepresentation}- />- <Resource name="companies" show={CompanyShow} />- <Resource name="tasks" list={MobileTasksList} />- </Admin>+ <Resource name="companies" show={CompanyShow} />+ <Resource name="tasks" list={MobileTasksList} />+ </Admin>+ </PersistQueryClientProvider>);};