From f8d26515fe26a460c060d6ecf000fc6b9b1883a1 Mon Sep 17 00:00:00 2001 From: John Murfett Date: Wed, 3 Jan 2024 13:16:49 +1100 Subject: [PATCH] Add id to invoice placeholder data and seed script --- .../final-example/app/lib/placeholder-data.js | 15 +++++++++++++++ dashboard/final-example/scripts/seed.js | 4 ++-- .../starter-example/app/lib/placeholder-data.js | 15 +++++++++++++++ dashboard/starter-example/scripts/seed.js | 4 ++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/dashboard/final-example/app/lib/placeholder-data.js b/dashboard/final-example/app/lib/placeholder-data.js index 15a41565..cbc7d91c 100644 --- a/dashboard/final-example/app/lib/placeholder-data.js +++ b/dashboard/final-example/app/lib/placeholder-data.js @@ -74,90 +74,105 @@ const customers = [ const invoices = [ { + id: '33be43f3-c1a2-43ce-b37f-2b97f2bb2e55', customer_id: customers[0].id, amount: 15795, status: 'pending', date: '2022-12-06', }, { + id: 'd3d90773-ebf1-436a-90bc-aebb01df0f27', customer_id: customers[1].id, amount: 20348, status: 'pending', date: '2022-11-14', }, { + id: 'c67a6d3b-2238-412b-ad3d-26f4dc5e4f30', customer_id: customers[4].id, amount: 3040, status: 'paid', date: '2022-10-29', }, { + id: 'a9de4874-4ee3-4938-ac13-6dd5b196ac2b', customer_id: customers[3].id, amount: 44800, status: 'paid', date: '2023-09-10', }, { + id: '29414e85-5c8d-4b8b-9cad-1b646d89c834', customer_id: customers[5].id, amount: 34577, status: 'pending', date: '2023-08-05', }, { + id: '5de85d95-60a7-4f14-bc8d-6056aaf093af', customer_id: customers[7].id, amount: 54246, status: 'pending', date: '2023-07-16', }, { + id: '31f0867a-ce85-4b59-84cd-509486e83b8c', customer_id: customers[6].id, amount: 666, status: 'pending', date: '2023-06-27', }, { + id: '1c0bd8f2-4359-47f9-a8d4-2d058b9785bb', customer_id: customers[3].id, amount: 32545, status: 'paid', date: '2023-06-09', }, { + id: '23003951-b064-45cf-aac5-58a6bd823b7b', customer_id: customers[4].id, amount: 1250, status: 'paid', date: '2023-06-17', }, { + id:'e2c8a2ff-51e4-41e9-937e-c4ac680d84e0', customer_id: customers[5].id, amount: 8546, status: 'paid', date: '2023-06-07', }, { + id: '0c067223-8be1-4d80-a0ee-7bf0dc646c22', customer_id: customers[1].id, amount: 500, status: 'paid', date: '2023-08-19', }, { + id: '45003d45-e626-4b86-92e8-26ad06cafdcb', customer_id: customers[5].id, amount: 8945, status: 'paid', date: '2023-06-03', }, { + id: '6d1d2944-c855-4d8e-b2bd-42d976bd0752', customer_id: customers[2].id, amount: 8945, status: 'paid', date: '2023-06-18', }, { + id: '8f2e576d-b7cd-457e-ab3a-141afd562fa8', customer_id: customers[0].id, amount: 8945, status: 'paid', date: '2023-10-04', }, { + id: '7fa8aee0-fc06-4f95-815a-c505505846e1', customer_id: customers[2].id, amount: 1000, status: 'paid', diff --git a/dashboard/final-example/scripts/seed.js b/dashboard/final-example/scripts/seed.js index ae462736..d40bfbb4 100644 --- a/dashboard/final-example/scripts/seed.js +++ b/dashboard/final-example/scripts/seed.js @@ -67,8 +67,8 @@ async function seedInvoices(client) { const insertedInvoices = await Promise.all( invoices.map( (invoice) => client.sql` - INSERT INTO invoices (customer_id, amount, status, date) - VALUES (${invoice.customer_id}, ${invoice.amount}, ${invoice.status}, ${invoice.date}) + INSERT INTO invoices (id, customer_id, amount, status, date) + VALUES (${invoice.id} ${invoice.customer_id}, ${invoice.amount}, ${invoice.status}, ${invoice.date}) ON CONFLICT (id) DO NOTHING; `, ), diff --git a/dashboard/starter-example/app/lib/placeholder-data.js b/dashboard/starter-example/app/lib/placeholder-data.js index 15a41565..cbc7d91c 100644 --- a/dashboard/starter-example/app/lib/placeholder-data.js +++ b/dashboard/starter-example/app/lib/placeholder-data.js @@ -74,90 +74,105 @@ const customers = [ const invoices = [ { + id: '33be43f3-c1a2-43ce-b37f-2b97f2bb2e55', customer_id: customers[0].id, amount: 15795, status: 'pending', date: '2022-12-06', }, { + id: 'd3d90773-ebf1-436a-90bc-aebb01df0f27', customer_id: customers[1].id, amount: 20348, status: 'pending', date: '2022-11-14', }, { + id: 'c67a6d3b-2238-412b-ad3d-26f4dc5e4f30', customer_id: customers[4].id, amount: 3040, status: 'paid', date: '2022-10-29', }, { + id: 'a9de4874-4ee3-4938-ac13-6dd5b196ac2b', customer_id: customers[3].id, amount: 44800, status: 'paid', date: '2023-09-10', }, { + id: '29414e85-5c8d-4b8b-9cad-1b646d89c834', customer_id: customers[5].id, amount: 34577, status: 'pending', date: '2023-08-05', }, { + id: '5de85d95-60a7-4f14-bc8d-6056aaf093af', customer_id: customers[7].id, amount: 54246, status: 'pending', date: '2023-07-16', }, { + id: '31f0867a-ce85-4b59-84cd-509486e83b8c', customer_id: customers[6].id, amount: 666, status: 'pending', date: '2023-06-27', }, { + id: '1c0bd8f2-4359-47f9-a8d4-2d058b9785bb', customer_id: customers[3].id, amount: 32545, status: 'paid', date: '2023-06-09', }, { + id: '23003951-b064-45cf-aac5-58a6bd823b7b', customer_id: customers[4].id, amount: 1250, status: 'paid', date: '2023-06-17', }, { + id:'e2c8a2ff-51e4-41e9-937e-c4ac680d84e0', customer_id: customers[5].id, amount: 8546, status: 'paid', date: '2023-06-07', }, { + id: '0c067223-8be1-4d80-a0ee-7bf0dc646c22', customer_id: customers[1].id, amount: 500, status: 'paid', date: '2023-08-19', }, { + id: '45003d45-e626-4b86-92e8-26ad06cafdcb', customer_id: customers[5].id, amount: 8945, status: 'paid', date: '2023-06-03', }, { + id: '6d1d2944-c855-4d8e-b2bd-42d976bd0752', customer_id: customers[2].id, amount: 8945, status: 'paid', date: '2023-06-18', }, { + id: '8f2e576d-b7cd-457e-ab3a-141afd562fa8', customer_id: customers[0].id, amount: 8945, status: 'paid', date: '2023-10-04', }, { + id: '7fa8aee0-fc06-4f95-815a-c505505846e1', customer_id: customers[2].id, amount: 1000, status: 'paid', diff --git a/dashboard/starter-example/scripts/seed.js b/dashboard/starter-example/scripts/seed.js index ae462736..d40bfbb4 100644 --- a/dashboard/starter-example/scripts/seed.js +++ b/dashboard/starter-example/scripts/seed.js @@ -67,8 +67,8 @@ async function seedInvoices(client) { const insertedInvoices = await Promise.all( invoices.map( (invoice) => client.sql` - INSERT INTO invoices (customer_id, amount, status, date) - VALUES (${invoice.customer_id}, ${invoice.amount}, ${invoice.status}, ${invoice.date}) + INSERT INTO invoices (id, customer_id, amount, status, date) + VALUES (${invoice.id} ${invoice.customer_id}, ${invoice.amount}, ${invoice.status}, ${invoice.date}) ON CONFLICT (id) DO NOTHING; `, ),