diff --git a/apps/webapp/src/components/connections/ConnectionTable.tsx b/apps/webapp/src/components/connections/ConnectionTable.tsx index 745f5031f..d07d66784 100644 --- a/apps/webapp/src/components/connections/ConnectionTable.tsx +++ b/apps/webapp/src/components/connections/ConnectionTable.tsx @@ -1,11 +1,11 @@ import { columns } from "./components/columns" import { DataTable } from "../shared/data-table" import { - Card, - CardContent, - CardHeader, - CardTitle, - } from "@/components/ui/card" + Card, + CardContent, + CardHeader, + CardTitle, +} from "@/components/ui/card" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; import { Button } from "../ui/button"; import { PlusCircledIcon } from "@radix-ui/react-icons"; @@ -14,18 +14,26 @@ import useConnections from "@/hooks/useConnections"; import { DataTableLoading } from "../shared/data-table-loading"; import { useState } from "react"; import AddConnectionButton from "./components/AddConnectionButton"; +import { Skeleton } from "../ui/skeleton"; export default function ConnectionTable() { const { data: connections, isLoading, error } = useConnections(); const [isGenerated, setIsGenerated] = useState(false); - if(isLoading){ + if (isLoading) { console.log("loading connections.."); } - if(error){ + if (error) { console.log("error connections.."); } + if (!connections) { + return
+ Connections not found.... + +
; + } + const linkedConnections = (filter: string) => connections.filter((connection) => connection.status == filter); const ts = connections?.map((connection) => ({ organisation: connection.id_project, // replace with actual mapping @@ -36,45 +44,45 @@ export default function ConnectionTable() { date: new Date().toISOString(), // replace with actual mapping })) - + return ( <>
- - Linked - - -

0

-
+ + Linked + + +

{linkedConnections("0").length}

+
- - Incomplete Link - - -

3

-
+ + Incomplete Link + + +

{linkedConnections("1").length}

+
- - Relink Needed - - -

1

-
+ + Relink Needed + + +

{linkedConnections("2").length}

+
- - + +
{isGenerated ? @@ -86,17 +94,17 @@ export default function ConnectionTable() {
- +
-
: - + : + } - {isLoading && } + {isLoading && } {ts && }
diff --git a/apps/webapp/src/components/dashboard/components/user-nav.tsx b/apps/webapp/src/components/dashboard/components/user-nav.tsx index 11d6d98db..064183730 100644 --- a/apps/webapp/src/components/dashboard/components/user-nav.tsx +++ b/apps/webapp/src/components/dashboard/components/user-nav.tsx @@ -13,12 +13,13 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" +import { Skeleton } from "@/components/ui/skeleton"; import useProfile from "@/hooks/useProfile"; import useProfileStore from "@/state/profileStore"; import { useEffect } from "react"; export function UserNav() { - const {data} = useProfile(); + const {data, isLoading} = useProfile(); if(!data) { console.log("loading profiles"); } @@ -50,10 +51,11 @@ import { useEffect } from "react";

- {profile && profile.first_name} + {profile ? profile.first_name : isLoading ? : "No profiles found"} +

- {profile && profile.email} + {profile ? profile.email : isLoading ? : "No mail found"}

diff --git a/apps/webapp/src/components/shared/team-switcher.tsx b/apps/webapp/src/components/shared/team-switcher.tsx index 8ff0a0c2e..c6292ff9f 100644 --- a/apps/webapp/src/components/shared/team-switcher.tsx +++ b/apps/webapp/src/components/shared/team-switcher.tsx @@ -110,10 +110,6 @@ export default function TeamSwitcher({ className }: TeamSwitcherProps) { setShowNewDialog({open: false}) }; - if(!orgs) { - return <>DHJSDHJ - } - return ( @@ -125,7 +121,7 @@ export default function TeamSwitcher({ className }: TeamSwitcherProps) { aria-label="Select a team" className={cn("w-[250px] justify-between", className)} > - {selectedProject ? selectedProject.name : "not found"} + {selectedProject ? selectedProject.name : isloadingProjects ? : "No projects found"} diff --git a/packages/api/scripts/seed.ts b/packages/api/scripts/seed.ts index 681c0e7c0..2de8bb00f 100644 --- a/packages/api/scripts/seed.ts +++ b/packages/api/scripts/seed.ts @@ -4,19 +4,26 @@ import { v4 as uuidv4 } from 'uuid'; const prisma = new PrismaClient(); async function main() { - // Seed the `organizations` table with 5 organizations - /*const organizationsData = Array.from({ length: 5 }).map((_, index) => ({ - id_organization: uuidv4(), - name: `Organization ${index + 1}`, - stripe_customer_id: `cust_${index + 1}`, - })); + const org = await prisma.organizations.create({ + data: { + id_organization: uuidv4(), + name: `Acme Inc`, + stripe_customer_id: `cust_stripe_acme_${uuidv4()}`, + }, + }); - await prisma.organizations.createMany({ - data: organizationsData, + const user = await prisma.users.create({ + data: { + id_user: uuidv4(), + email: 'audrey@aubry.io', + password_hash: 'password_hashed_her', + first_name: 'audrey', + last_name: 'aubry', + }, }); // Seed the `projects` table with 10 projects - const projectsData = organizationsData.map((org, index) => ({ + const projectsData = Array.from({ length: 3 }).map((_, index) => ({ id_project: uuidv4(), name: `Project ${index + 1}`, id_organization: org.id_organization, @@ -24,130 +31,173 @@ async function main() { await prisma.projects.createMany({ data: projectsData, - });*/ + }); - // Seed the `linked_users` table with 20 linked users - /*const linkedUsersData = Array.from({ length: 20 }).map((_, index) => ({ + // Seed the `linked_users` table with 10 linked users + const linkedUsersData = Array.from({ length: 10 }).map((_, index) => ({ id_linked_user: uuidv4(), - linked_user_origin_id: `origin_id_${index + 1}`, - alias: `Alias ${index + 1}`, + linked_user_origin_id: `acme_origin_id_${uuidv4()}`, + alias: `Acme Inc`, id_project: projectsData[index % projectsData.length].id_project, // Circularly assign projects to linked users })); - await prisma.linked_users.createMany({ + const linked_users = await prisma.linked_users.createMany({ data: linkedUsersData, }); - // Seed the `connections` table with 15 connections + const providers = [ + 'hubspot', + 'zoho', + 'zendesk', + 'slack', + 'asana', + 'shopify', + 'pipedrive', + 'freshsales', + 'freshbooks', + 'sage', + ]; + + // Seed the `connections` table with 10 connections const connectionsData = linkedUsersData.map((user, index) => ({ id_connection: uuidv4(), - status: 'active', - provider_slug: `hubspot`, + status: '2', // 2: RELINK NEEDED + provider_slug: providers[index], id_linked_user: user.id_linked_user, id_project: user.id_project, token_type: 'oauth', created_at: new Date(), })); - await prisma.connections.createMany({ + const connections = await prisma.connections.createMany({ data: connectionsData, }); - // Seed the `attributes` and `entities` table - const entitiesData = Array.from({ length: 10 }).map((_, index) => ({ - id_entity: uuidv4(), - ressource_owner_id: `resource_owner_${index + 1}`, - })); + const entitiesData = [ + { + id_entity: uuidv4(), + ressource_owner_id: 'contact', + }, + { + id_entity: uuidv4(), + ressource_owner_id: 'task', + }, + { + id_entity: uuidv4(), + ressource_owner_id: 'company', + }, + { + id_entity: uuidv4(), + ressource_owner_id: 'note', + }, + ]; await prisma.entity.createMany({ data: entitiesData, }); + const slugs = [ + { + slug: 'fav_color', + desc: 'favorite color', + origin_field: 'favorite_color', + providerSource: 'hubspot', + }, + { + slug: 'fav_coat', + desc: 'favorite coat', + origin_field: 'best_coat', + providerSource: 'zoho', + }, + { + slug: 'sales_number', + desc: 'number of sales', + origin_field: 'sales_amount', + providerSource: 'shopify', + }, + { + slug: 'pet_number', + desc: 'number of pets', + origin_field: 'pets_amount', + providerSource: 'sage', + }, + ]; + const attributesData = entitiesData.map((entity, index) => ({ id_attribute: uuidv4(), status: 'mapped', - ressource_owner_type: `type_${index + 1}`, - slug: `slug_${index + 1}`, - description: `Description for attribute ${index + 1}`, + ressource_owner_type: entity.ressource_owner_id, + slug: slugs[index].slug, + description: slugs[index].desc, data_type: `string`, - remote_id: `remote_id_${index + 1}`, - source: `source_${index + 1}`, + remote_id: slugs[index].origin_field, + source: slugs[index].providerSource, id_entity: entity.id_entity, - scope: `scope_${index + 1}`, + scope: `user`, })); await prisma.attribute.createMany({ data: attributesData, - });*/ - - // Seed the `jobs` table with 20 jobs - /*const jobsData = Array.from({ length: 20 }).map((_, index) => ({ - id_job: uuidv4(), // Generate a new UUID for each job - status: 'active', // Use whatever status is appropriate - timestamp: new Date(), - // Replace with an actual linked user ID from your `linked_users` table - id_linked_user: 'ff427999-c87b-44f8-92ec-ed75b834a0cf', - // Add other fields as required - })); - - const jobs = await prisma.jobs.createMany({ - data: jobsData, - skipDuplicates: true, // Set to true to ignore conflicts (optional) }); - */ - - /*await prisma.users.createMany({ - data: [ - { - id_user: uuidv4(), - email: 'audrey@aubry.io', - password_hash: 'password_hashed_her', - first_name: 'audrey', - last_name: 'aubry', - }, - ], - });*/ - const entitiesData = [ + + const slugs_ = [ { - id_entity: uuidv4(), - ressource_owner_id: 'contact', + slug: 'fav_cake', + desc: 'favorite cake', + origin_field: 'favorite_cake', + providerSource: 'hubspot', }, { - id_entity: uuidv4(), - ressource_owner_id: 'task', + slug: 'fav_beanie', + desc: 'favorite beanie', + origin_field: 'best_beanie', + providerSource: 'zoho', }, { - id_entity: uuidv4(), - ressource_owner_id: 'company', + slug: 'clicks_number', + desc: 'number of cliks', + origin_field: 'clicks_amount', + providerSource: 'shopify', }, { - id_entity: uuidv4(), - ressource_owner_id: 'note', + slug: 'tv_number', + desc: 'number of tv', + origin_field: 'tv_amount', + providerSource: 'sage', }, ]; - await prisma.entity.createMany({ - data: entitiesData, - }); - const attributesData = entitiesData.map((entity, index) => ({ + const attributesData_ = entitiesData.map((entity, index) => ({ id_attribute: uuidv4(), status: 'defined', - ressource_owner_type: `contact`, - slug: `slug_${index + 1}`, - description: `Description for attribute ${index + 1}`, + ressource_owner_type: entity.ressource_owner_id, + slug: slugs_[index].slug, + description: slugs_[index].desc, data_type: `string`, - remote_id: ``, - source: ``, + remote_id: slugs_[index].origin_field, + source: slugs_[index].providerSource, id_entity: entity.id_entity, scope: `user`, })); await prisma.attribute.createMany({ - data: attributesData, + data: attributesData_, }); - /* + // Seed the `jobs` table with 20 jobs - const apiKeysData = Array.from({ length: 4 }).map((_, index) => ({ + const jobsData = Array.from({ length: 10 }).map((_, index) => ({ + id_job: uuidv4(), // Generate a new UUID for each job + status: 'initialized', // Use whatever status is appropriate + timestamp: new Date(), + id_linked_user: linkedUsersData[index].id_linked_user, + })); + + const jobs = await prisma.jobs.createMany({ + data: jobsData, + skipDuplicates: true, // Set to true to ignore conflicts (optional) + }); + + /*const apiKeysData = Array.from({ length: 4 }).map((_, index) => ({ id_api_key: uuidv4(), api_key_hash: `api_key_hashed_${index}`, id_project: 'e7a741ef-6b5c-46f8-b9a1-55667f3a6c61',