Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Env fix db #108

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
]
},
"dependencies": {
"@changesets/cli": "^2.26.2"
"@changesets/cli": "^2.26.2",
"gitmoji-cli": "^9.0.0"
},
"private": true,
"engines": {
"node": ">=16.14.2"
}
"node": ">=16.14.2"
}
}
1 change: 1 addition & 0 deletions packages/api/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@prisma/client';
3 changes: 2 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"ci": "pnpm run lint && pnpm run build"
"ci": "pnpm run lint && pnpm run build",
"copy-types-to-shared": "cp ./exports.ts ../shared/index.ts"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
Expand Down
121 changes: 61 additions & 60 deletions packages/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,20 @@ model api_keys {
@@index([id_project], map: "fk_api_keys_projects")
}

model crm_contact_email_addresses {
id_crm_contact_email String @id(map: "pk_crm_contact_email_addresses") @db.Uuid
email_address String
email_address_type String
owner_type String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_crm_company String? @db.Uuid
id_crm_contact String? @db.Uuid
crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_16")
crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_3")

@@index([id_crm_contact], map: "crm_contactid_crm_contact_email_address")
@@index([id_crm_company], map: "fk_contact_email_adress_companyid")
}

model crm_contacts {
id_crm_contact String @id(map: "pk_crm_contacts") @db.Uuid
first_name String
last_name String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_job String @db.Uuid
id_crm_user String? @db.Uuid
crm_addresses crm_addresses[]
crm_contact_email_addresses crm_contact_email_addresses[]
crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23")
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact")
crm_notes crm_notes[]
crm_phone_numbers crm_phone_numbers[]
id_crm_contact String @id(map: "pk_crm_contacts") @db.Uuid
first_name String
last_name String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_job String @db.Uuid
id_crm_user String? @db.Uuid
crm_addresses crm_addresses[]
crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23")
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact")
crm_email_addresses crm_email_addresses[]
crm_notes crm_notes[]
crm_phone_numbers crm_phone_numbers[]

@@index([id_job], map: "crm_contact_id_job")
@@index([id_crm_user], map: "fk_crm_contact_userid")
Expand Down Expand Up @@ -185,22 +169,22 @@ model crm_addresses {
}

model crm_companies {
id_crm_company String @id(map: "pk_crm_companies") @db.Uuid
name String?
industry String?
number_of_employees BigInt?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_job String @db.Uuid
id_crm_user String? @db.Uuid
crm_addresses crm_addresses[]
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "fk_13")
crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_24")
crm_contact_email_addresses crm_contact_email_addresses[]
crm_engagements crm_engagements[]
crm_notes crm_notes[]
crm_phone_numbers crm_phone_numbers[]
crm_tasks crm_tasks[]
id_crm_company String @id(map: "pk_crm_companies") @db.Uuid
name String?
industry String?
number_of_employees BigInt?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_job String @db.Uuid
id_crm_user String? @db.Uuid
crm_addresses crm_addresses[]
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "fk_13")
crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_24")
crm_email_addresses crm_email_addresses[]
crm_engagements crm_engagements[]
crm_notes crm_notes[]
crm_phone_numbers crm_phone_numbers[]
crm_tasks crm_tasks[]

@@index([id_crm_user], map: "fk_crm_company_crm_userid")
@@index([id_job], map: "fk_crm_company_jobid")
Expand Down Expand Up @@ -235,11 +219,11 @@ model crm_deals_stages {

model crm_engagement_contacts {
id_crm_engagement_contact String @id(map: "pk_crm_engagement_contact") @db.Uuid
uuid_crm_engagement String @db.Uuid
id_crm_contact String? @db.Uuid
crm_engagements crm_engagements @relation(fields: [uuid_crm_engagement], references: [uuid_crm_engagement], onDelete: NoAction, onUpdate: NoAction, map: "fk_30")
id_crm_engagement String @db.Uuid
crm_engagements crm_engagements @relation(fields: [id_crm_engagement], references: [id_crm_engagement], onDelete: NoAction, onUpdate: NoAction, map: "fk_30")

@@index([uuid_crm_engagement], map: "fk_crm_engagement_contacts_crmengagementid")
@@index([id_crm_engagement], map: "fk_crm_engagement_contacts_crmengagementid")
@@index([id_crm_contact], map: "fk_engagement_contact_crmcontactid")
}

Expand All @@ -255,7 +239,7 @@ model crm_engagement_types {
}

model crm_engagements {
uuid_crm_engagement String @id(map: "pk_crm_engagement") @db.Uuid
id_crm_engagement String @id(map: "pk_crm_engagement") @db.Uuid
content String?
direction String?
subject String?
Expand Down Expand Up @@ -324,7 +308,7 @@ model attribute {
source String
id_entity String @db.Uuid
scope String
id_consumer String @db.Uuid
id_consumer String? @db.Uuid
entity entity @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_32")
value value[]

Expand Down Expand Up @@ -354,17 +338,34 @@ model value {

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model crm_phone_numbers {
id_crm_contacts_phone_number String @id(map: "pk_crm_contacts_phone_numbers") @db.Uuid
phone_number String
phone_type String
owner_type String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_crm_company String? @db.Uuid
id_crm_contact String? @db.Uuid
crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_17")
crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_phonenumber_crm_contactid")
id_crm_phone_number String @id(map: "pk_crm_contacts_phone_numbers") @db.Uuid
phone_number String
phone_type String
owner_type String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_crm_company String? @db.Uuid
id_crm_contact String? @db.Uuid
crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_17")
crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_phonenumber_crm_contactid")

@@index([id_crm_contact], map: "crm_contactid_crm_contact_phone_number")
@@index([id_crm_company], map: "fk_phone_number_companyid")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model crm_email_addresses {
id_crm_email String @id(map: "pk_crm_contact_email_addresses") @db.Uuid
email_address String
email_address_type String
owner_type String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_crm_company String? @db.Uuid
id_crm_contact String? @db.Uuid
crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_16")
crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_3")

@@index([id_crm_contact], map: "crm_contactid_crm_contact_email_address")
@@index([id_crm_company], map: "fk_contact_email_adress_companyid")
}
8 changes: 3 additions & 5 deletions packages/api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ContactService {
owner_type: email.owner_type ? email.owner_type : '',
created_at: new Date(),
modified_at: new Date(),
id_crm_contact_email: uuidv4(),
id_crm_email: uuidv4(), // This line is changed
email_address_type:
email.email_address_type === '' ? 'work' : email.email_address_type,
}));
Expand All @@ -60,9 +60,7 @@ export class ContactService {
owner_type: phone.owner_type ? phone.owner_type : '',
created_at: new Date(),
modified_at: new Date(),
//id_crm_company: '1', //TODO
//id_crm_contact: '1', //TODO
id_crm_contacts_phone_number: uuidv4(),
id_crm_phone_number: uuidv4(), // This line is changed
phone_type: phone.phone_type === '' ? 'work' : phone.phone_type,
}));

Expand Down Expand Up @@ -90,7 +88,7 @@ export class ContactService {
modified_at: new Date(),
first_name: first_name,
last_name: last_name,
crm_contact_email_addresses: {
crm_email_addresses: {
create: normalizedEmails,
},
crm_phone_numbers: {
Expand Down
Empty file added packages/shared/index.ts
Empty file.
23 changes: 23 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "shared",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8",
"typescript": "^5.3.2"
}
}
14 changes: 13 additions & 1 deletion packages/webapp/src/components/jobs/JobsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,28 @@ export interface Job {

export default function JobsTable() {
const { data: jobs, isLoading, error } = useJobs();

if(isLoading){
console.log("loading jobs..");
}

if(error){
console.log("error jobs..");
}

const transformedJobs = jobs?.map(job => ({
method: '', // replace with actual value
url: '', // replace with actual value
status: job.status,
direction: '', // replace with actual value
integration: '', // replace with actual value
organisation: '', // replace with actual value
date: job.timestamp.toString(), // convert Date to string
}));

return (
<>
{jobs && <DataTable data={jobs} columns={columns} />}
{transformedJobs && <DataTable data={transformedJobs} columns={columns} />}
</>
)
}
25 changes: 8 additions & 17 deletions packages/webapp/src/hooks/useJobs.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import config from '@/utils/config';
import { useQuery } from '@tanstack/react-query';
import {jobs as Jobs} from "@api/exports";


//TODO: import from shared type
export interface Job {
method: string;
url: string;
status: string;
direction: string;
integration: string;
organisation: string;
date: string;
const fetchJobs = async (): Promise<Jobs[]> => {
const response = await fetch(`${config.API_URL}/jobs`);
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
}

const useJobs = () => {
return useQuery({
queryKey: ['jobs'],
queryFn: async () => {
const response = await fetch(`${config.API_URL}/jobs`);
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
}
queryFn: fetchJobs
});
};

Expand Down
3 changes: 3 additions & 0 deletions packages/webapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"paths": {
"@/*": [
"./src/*"
],
"@api/*": [
"./../api/*"
]
},
/* Bundler mode */
Expand Down
Loading
Loading