Skip to content

Commit

Permalink
fix db-seed ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
slax57 committed Jun 28, 2024
1 parent 7fe510c commit 36d7435
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
8 changes: 3 additions & 5 deletions packages/demo/db-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ async function main() {
new Date(a.date).valueOf() - new Date(b.date).valueOf()
)
.map(note => {
const relatedContact = {
...persistedContacts.find(
contact => contact.id === note.contact_id
),
};
const relatedContact = persistedContacts.find(
contact => contact.id === note.contact_id
);
return supabase.from('contacts').update({
...relatedContact,
status: note.status,
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/dataGenerator/companies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const sizes = [1, 10, 50, 250, 500];

const regex = /\W+/;

export const generateCompanies = (db: Db): Company[] => {
export const generateCompanies = (db: Pick<Db, 'sales'>): Company[] => {
return Array.from(Array(55).keys()).map(id => {
const name = company.companyName();
return {
Expand Down
4 changes: 3 additions & 1 deletion packages/demo/src/dataGenerator/contactNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { randomDate } from './utils';

const status = ['cold', 'cold', 'cold', 'warm', 'warm', 'hot', 'in-contract'];

export const generateContactNotes = (db: Db): ContactNote[] => {
export const generateContactNotes = (
db: Pick<Db, 'contacts'>
): ContactNote[] => {
return Array.from(Array(1200).keys()).map(id => {
const contact = random.arrayElement(db.contacts);
const date = randomDate(new Date(contact.first_seen)).toISOString();
Expand Down
4 changes: 3 additions & 1 deletion packages/demo/src/dataGenerator/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const maxContacts = {
500: 50,
};

export const generateContacts = (db: Db): Contact[] => {
export const generateContacts = (
db: Pick<Db, 'companies' | 'tags'>
): Contact[] => {
const nbAvailblePictures = 223;
let numberOfContacts = 0;

Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/dataGenerator/dealNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { randomDate } from './utils';

const type = ['Email', 'Call', 'Call', 'Call', 'Call', 'Meeting', 'Reminder'];

export const generateDealNotes = (db: Db) => {
export const generateDealNotes = (db: Pick<Db, 'companies' | 'deals'>) => {
return Array.from(Array(300).keys()).map(id => {
const deal = random.arrayElement(db.deals);
const company = db.companies[deal.company_id as number];
Expand Down
4 changes: 3 additions & 1 deletion packages/demo/src/dataGenerator/deals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const stages = [
];
//const tags = ["new deal", "upsell", "SAV"];

export const generateDeals = (db: Db): Deal[] => {
export const generateDeals = (
db: Pick<Db, 'companies' | 'contacts'>
): Deal[] => {
const deals = Array.from(Array(50).keys()).map(id => {
const company = random.arrayElement(db.companies);
company.nb_deals++;
Expand Down
4 changes: 1 addition & 3 deletions packages/demo/src/dataGenerator/sales.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { name, internet } from 'faker/locale/en_US';

import { Db } from './types';

export const generateSales = (_: Db) => {
export const generateSales = () => {
const randomSales = Array.from(Array(10).keys()).map(id => {
const first_name = name.firstName();
const last_name = name.lastName();
Expand Down
4 changes: 1 addition & 3 deletions packages/demo/src/dataGenerator/tags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Db } from './types';

// --champagne-pink: #eddcd2ff;
// --linen: #fff1e6ff;
// --pale-pink: #fde2e4ff;
Expand All @@ -20,6 +18,6 @@ const tags = [
{ id: 5, name: 'vip', color: '#dbe7e4' },
];

export const generateTags = (_: Db) => {
export const generateTags = () => {
return [...tags];
};
2 changes: 1 addition & 1 deletion packages/demo/src/dataGenerator/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const type = [
'None',
];

export const generateTasks = (db: Db) => {
export const generateTasks = (db: Pick<Db, 'contacts'>) => {
return Array.from(Array(400).keys()).map(id => {
const contact = random.arrayElement(db.contacts);
return {
Expand Down

0 comments on commit 36d7435

Please sign in to comment.