From 675383c156e86fc982bfab7ed8edd284451330d1 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 8 Feb 2024 15:23:34 -0600 Subject: [PATCH 01/22] Basic Prisma Change; Needs follow up --- prisma/schema.prisma | 3 ++- server/api/create_transfer.post.ts | 0 types.d.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 server/api/create_transfer.post.ts diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b340f00e..7cbf1a81 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -52,7 +52,8 @@ model DonationPayout { model Page { cuid String @id @default(cuid()) - page_name String + first_name String + last_name String day_of_birth String? day_of_passing String? visitation_date String? diff --git a/server/api/create_transfer.post.ts b/server/api/create_transfer.post.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/types.d.ts b/types.d.ts index 54a42c33..b210fdcc 100644 --- a/types.d.ts +++ b/types.d.ts @@ -29,7 +29,8 @@ import { DonationPayout } from "@prisma/client" // TODO: import types from prisma, export them with relations added export type Page = { - page_name: string, + first_name: string, + last_name: string, cuid: string, userCuid: string, familyCuid: string, From 592f3a93d609869103549cf731ff4cd9742be3b0 Mon Sep 17 00:00:00 2001 From: Samuel Ma <126997597+FegelSamuel@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:29:22 -0600 Subject: [PATCH 02/22] EditPageID converted --- pages/EditPage/[EditPageId].vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pages/EditPage/[EditPageId].vue b/pages/EditPage/[EditPageId].vue index 74c91dfc..7a030d37 100644 --- a/pages/EditPage/[EditPageId].vue +++ b/pages/EditPage/[EditPageId].vue @@ -33,7 +33,8 @@ const cvuser2 = useCookie('cvuser') const data = ref({ cuid: "", userCuid: "", - page_name: "", + first_name: "", + last_name: "", day_of_birth: "", day_of_passing:"", visitation_date: "", @@ -229,9 +230,13 @@ CVContainer .information.bg-gray-300.rounded-md.mx-9.my-2.text-center(class="sm:text-start") CVLegend Personal Information .py-4.grid(class="sm:grid-cols-3") - CVLabel Page Name + CVLabel First Name .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") - CVInput(v-model='data.page_name' placeholder="required" required) + CVInput(v-model='data.first_name' placeholder="required" required) + .py-4.grid(class="sm:grid-cols-3") + CVLabel Last Name + .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") + CVInput(v-model='data.last_name' placeholder="required" required) .py-4.grid(class="sm:grid-cols-3" v-if="isAdvocate") CVLabel Family .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") From f5898e7021ea91f1cdfbe55ee51a3929b2dcdd25 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Tue, 20 Feb 2024 16:15:38 -0600 Subject: [PATCH 03/22] SQL migrated --- .../migration.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql diff --git a/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql b/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql new file mode 100644 index 00000000..78cc5874 --- /dev/null +++ b/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - You are about to drop the column `page_name` on the `pages` table. All the data in the column will be lost. + - Added the required column `first_name` to the `pages` table without a default value. This is not possible if the table is not empty. + - Added the required column `last_name` to the `pages` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "page_name", +ADD COLUMN "first_name" TEXT NOT NULL, +ADD COLUMN "last_name" TEXT NOT NULL; From 94519e2442a2805ef290ceb5b209324524bdbfd8 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Tue, 20 Feb 2024 16:16:06 -0600 Subject: [PATCH 04/22] schema and prisma changes --- pages/FamilyReports.vue | 2 +- pages/FamilyTransactionList.vue | 4 +- pages/Page/[id].vue | 2 +- pages/PageList/[id].vue | 4 +- pages/Search.vue | 2 +- prisma/schema.prisma | 93 ++++++++++++++++----------------- 6 files changed, 52 insertions(+), 55 deletions(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index 58d50fb0..b51aa999 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -22,7 +22,7 @@ div tbody(v-for="family in families") tr(v-for="(page,i) in family.Pages" :class="{'bg-gray-200': (i+1) % 2}") - td(style="text-align: center;") {{ page.page_name }} + td(style="text-align: center;") {{ page.first_name + " " + page.last_name}} td(style="text-align: center;") {{ family.AdvocateResponsible.first_name + " " + family.AdvocateResponsible.last_name }} td(style="text-align: center;") {{ page.duration }} td(style="text-align: center;") {{ page.donation_status }} diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index d732ceef..0bf2d3c1 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -107,7 +107,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") leave-to-class='opacity-0' ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) - ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.page_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} + ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.first_name + " " + page.last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? currentPage.page_name : 'Select Page' }} .flex.gap-5.justify-around @@ -151,7 +151,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.first_name + " " + item?.last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised-item.amount_distributed) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index 5472c1bc..c4457338 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -116,7 +116,7 @@ const DisplayReply = async (reply: Reply) => { // the header overlay with image and name .mt-2.min-h-24.text-white.uppercase.w-full(style="background-image: url('https://carsonsvillage.org/wp-content/uploads/2018/11/iStock-862083112-BW.jpg');") .h-full.py-8.self-center.w-full.text-center.flex.flex-col(style="background-color: rgba(50, 119, 136, .8)") - p.my-auto.font-bold.text-4xl {{ pageDataDB.page_name }} + p.my-auto.font-bold.text-4xl {{ pageDataDB.first_name + " " + pageDataDB.last_name }} .flex.flex-col.gap-5.px-4.mx-auto.mt-8(class="w-3/4 sm:px-16") img.mx-auto(v-if="profileImageLink" class="w-[122px] h-[122px] rounded-[8px]" :src="`${profileImageLink}`") diff --git a/pages/PageList/[id].vue b/pages/PageList/[id].vue index 2143434e..1792457d 100644 --- a/pages/PageList/[id].vue +++ b/pages/PageList/[id].vue @@ -186,7 +186,7 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.first_name + " " + item.last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td @@ -209,7 +209,7 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.first_name + " " + item.last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td diff --git a/pages/Search.vue b/pages/Search.vue index 8b35943a..6de10037 100644 --- a/pages/Search.vue +++ b/pages/Search.vue @@ -73,7 +73,7 @@ onMounted(() => { tbody tr(v-for="(page, i) in pages" :class="{'bg-gray-200': (i+1) % 2}") td(style="text-align: center") - NuxtLink(:to="`/Page/${page.cuid}`") {{ page.page_name}} + NuxtLink(:to="`/Page/${page.cuid}`") {{ page.first_name + " " + page.last_name }} td(style="text-align: center") {{ donationFormat(page.donation_goal) }} td(style="text-align: center") {{ dateFormat(page.deadline) }} .ml-9.mb-9.py-7.flex.flex-wrap.gap-2.place-content-center diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7cbf1a81..c026cab4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -9,18 +9,17 @@ datasource db { } model User { - cuid String @id @default(cuid()) - email String @unique - user_role String @default("family") // advocate, admin - first_name String @default("") - middle_name String @default("") - last_name String @default("") - phone String @default("") - - AdvocateFamily Family[] @relation("advocate_family") - Family Family? @relation(name: "family_member", fields: [familyCuid], references: [cuid]) + cuid String @id @default(cuid()) + email String @unique + user_role String @default("family") + first_name String @default("") + middle_name String @default("") + last_name String @default("") + phone String @default("") familyCuid String? + AdvocateFamily Family[] @relation("advocate_family") Pages Page[] + Family Family? @relation("family_member", fields: [familyCuid], references: [cuid]) @@map("user_accounts") } @@ -29,14 +28,14 @@ model Family { cuid String @id @default(cuid()) family_name String stripe_account_id String? - FamilyMembers User[] @relation("family_member") created_at String @default("") updated_at String @default("") - Pages Page[] - FamilyDonations PageDonation[] - FamilyDonationPayouts DonationPayout[] advocateCuid String @map("advocate_cuid") - AdvocateResponsible User? @relation("advocate_family", fields: [advocateCuid], references: [cuid]) + FamilyDonationPayouts DonationPayout[] + AdvocateResponsible User @relation("advocate_family", fields: [advocateCuid], references: [cuid]) + FamilyDonations PageDonation[] + Pages Page[] + FamilyMembers User[] @relation("family_member") } model DonationPayout { @@ -46,43 +45,41 @@ model DonationPayout { transaction_id String @unique amount Int @default(0) distributionDate String - Family Family @relation(fields: [familyCuid], references: cuid) - Page Page @relation(fields: [pageCuid], references: cuid) + Family Family @relation(fields: [familyCuid], references: [cuid]) + Page Page @relation(fields: [pageCuid], references: [cuid]) } model Page { - cuid String @id @default(cuid()) - first_name String - last_name String + cuid String @id @default(cuid()) day_of_birth String? day_of_passing String? visitation_date String? visitation_location String visitation_description String - - funeral_date String? - funeral_location String - funeral_description String - - obituary String - donation_goal Int @default(0) - amount_raised Int @default(0) - deadline String - userCuid String @map("user_cuid") - PageDonations PageDonation[] - DonationPayouts DonationPayout[] - User User @relation(fields: [userCuid], references: cuid) - Images Image[] - amount_distributed Int @default(0) - profileImageCuid String @map("profile_image_cuid") - Family Family? @relation(fields: [familyCuid], references: cuid) - familyCuid String? @map("family_cuid") - status String @default("active") - donation_status String @default("in progress") - duration String @default("0 days") - start_date String @default("") - goal_met_date String @default("") - Reply Reply[] + funeral_date String? + funeral_location String + funeral_description String + obituary String + donation_goal Int @default(0) + amount_raised Int @default(0) + deadline String + userCuid String @map("user_cuid") + amount_distributed Int @default(0) + profileImageCuid String @map("profile_image_cuid") + familyCuid String? @map("family_cuid") + status String @default("active") + donation_status String @default("in progress") + duration String @default("0 days") + start_date String @default("") + goal_met_date String @default("") + first_name String + last_name String + DonationPayouts DonationPayout[] + Reply Reply[] + Images Image[] + PageDonations PageDonation[] + Family Family? @relation(fields: [familyCuid], references: [cuid]) + User User @relation(fields: [userCuid], references: [cuid]) @@map("pages") } @@ -97,9 +94,9 @@ model PageDonation { isAnonymous Boolean @default(false) success Boolean @default(false) transaction_id String @unique - amount Int //In cents - Family Family @relation(fields: [familyCuid], references: cuid) - Page Page @relation(fields: [pageCuid], references: cuid) + amount Int + Family Family @relation(fields: [familyCuid], references: [cuid]) + Page Page @relation(fields: [pageCuid], references: [cuid]) @@map("page_donations") } @@ -110,7 +107,7 @@ model Reply { familyCuid String @map("family_cuid") reply String @default("") name String? @default("") - Page Page @relation(fields: [pageCuid], references: cuid) + Page Page @relation(fields: [pageCuid], references: [cuid]) } model Image { From 9c07cfd98f5fe68ee49e325bdca2793574075efd Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 22 Feb 2024 13:51:40 -0600 Subject: [PATCH 05/22] Looks okay to me, unsure of what else to fix. Need to ask Ofek about one more thing though --- pages/FamilyReports.vue | 2 +- pages/FamilyTransactionList.vue | 2 +- pages/Page/[id].vue | 8 ++++---- server/api/complete_session.get.ts | 3 ++- server/api/create_session.post.ts | 5 +++-- server/api/pages.get.ts | 1 + 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index b51aa999..ee003cf4 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -80,7 +80,7 @@ div // converts array of family pages and their advocate responsible for the family into a csv function convertToCSV(arr : Partial) { - const listOfTags = ["page_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] + const listOfTags = ["first_name", "last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] // removes every column not in list of tags Object.keys(arr[0] || "").forEach((element: string) => { const currentArr = ref>([]) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 0bf2d3c1..4f9acd7e 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -176,7 +176,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.transaction_id }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.first_name + " " + item.Page.first_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount) }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index c4457338..a55cb30c 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -66,12 +66,12 @@ const create_checkout_session = async () => { }; const shareFacebook = () => { - const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.page_name}&u=${window.location.href}` + const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&u=${window.location.href}` window.open(facebookShareLink) } -const shareXFormalyKnownAsTwitter = () => { - const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.page_name}&url=${window.location.href}` +const shareXFormerlyKnownAsTwitter = () => { + const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&url=${window.location.href}` window.open(xShareLink) } @@ -194,7 +194,7 @@ const DisplayReply = async (reply: Reply) => { button(@click="shareFacebook") img(src="/facebook-fa.png" style="width:30px; height:33px;") .col - button(@click="shareXFormalyKnownAsTwitter") + button(@click="shareXFormerlyKnownAsTwitter") img(src="/twitter_fa.png" style="width:30px; height:29px;") .col button(@click="shareMail") diff --git a/server/api/complete_session.get.ts b/server/api/complete_session.get.ts index f497e897..e8a39fa9 100644 --- a/server/api/complete_session.get.ts +++ b/server/api/complete_session.get.ts @@ -23,7 +23,8 @@ export default defineEventHandler(async event => { include: { Page: { select: { - page_name: true, + first_name: true, + last_name: true, amount_raised: true, donation_goal: true, deadline: true, diff --git a/server/api/create_session.post.ts b/server/api/create_session.post.ts index 215510e9..3adbcbc9 100644 --- a/server/api/create_session.post.ts +++ b/server/api/create_session.post.ts @@ -39,7 +39,7 @@ export default defineEventHandler(async event => { currency: 'usd', unit_amount: body.amount_raised, product_data: { - name: `Donation to ${page?.page_name}`, + name: `Donation to ${page?.first_name} ${page?.last_name}`, }, }, quantity: 1 @@ -50,7 +50,8 @@ export default defineEventHandler(async event => { amount: body.amount_raised, target_user_id: userCuid, target_family_id: familyCuid, - target_page_name: page?.page_name as string, + target_first_name: page?.first_name as string, + target_last_name: page?.last_name as string, target_page_cuid: page?.cuid as string, comments: donorComments, }, diff --git a/server/api/pages.get.ts b/server/api/pages.get.ts index e467d020..b9a3a9de 100644 --- a/server/api/pages.get.ts +++ b/server/api/pages.get.ts @@ -29,6 +29,7 @@ const runtime = useRuntimeConfig() console.log(page_number) // Pagination via taking the absolute page number with 12 records per page + // TODO: Figure this out const [count, pagesResult] = await prisma.$transaction([ prisma.page.count({ where: { page_name: { contains: searchQuery as string, From 403e90d8b30c0dfd89fa01457ce0e6e10854fda0 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 22 Feb 2024 15:46:51 -0600 Subject: [PATCH 06/22] corrected from Ofek --- pages/FamilyTransactionList.vue | 2 +- server/api/pages.get.ts | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 4f9acd7e..22d25ce1 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -108,7 +108,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.first_name + " " + page.last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} - ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? currentPage.page_name : 'Select Page' }} + ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.first_name || currentPage.last_name) : 'Select Page' }} .flex.gap-5.justify-around //these next two divs could theoretically be their own component with props diff --git a/server/api/pages.get.ts b/server/api/pages.get.ts index b9a3a9de..6bc0057f 100644 --- a/server/api/pages.get.ts +++ b/server/api/pages.get.ts @@ -29,18 +29,36 @@ const runtime = useRuntimeConfig() console.log(page_number) // Pagination via taking the absolute page number with 12 records per page - // TODO: Figure this out + // Transaction is a Database thing + // You can get away with doing multiple operations at once. + // count gets the amount of pages with the same name + // const [count, pagesResult] = await prisma.$transaction([ - prisma.page.count({ where: { page_name: { + prisma.page.count({ where: { + OR: [ { + first_name: { contains: searchQuery as string, mode: 'insensitive', - } }}), + } }, + { last_name: { + contains: searchQuery as string, + mode: 'insensitive', + }}] }}), prisma.page.findMany({ where: { - page_name: { - contains: searchQuery as string, - mode: 'insensitive', - } + OR: [ { + first_name: { + contains: searchQuery as string, + mode: 'insensitive', + } + }, + { + last_name: { + contains: searchQuery as string, + mode: 'insensitive', + } + } + ] }, skip: page_number as number * 12, take: 12, From 3db86c8f9360089d7230853e328eef5096fb26e3 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Fri, 23 Feb 2024 09:14:40 -0600 Subject: [PATCH 07/22] initial schema and types change --- .../20240223151306_page_qualifer_name/migration.sql | 10 ++++++++++ .../migrations/20240223151402_page_name/migration.sql | 10 ++++++++++ prisma/schema.prisma | 4 ++-- types.d.ts | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20240223151306_page_qualifer_name/migration.sql create mode 100644 prisma/migrations/20240223151402_page_name/migration.sql diff --git a/prisma/migrations/20240223151306_page_qualifer_name/migration.sql b/prisma/migrations/20240223151306_page_qualifer_name/migration.sql new file mode 100644 index 00000000..d69e5445 --- /dev/null +++ b/prisma/migrations/20240223151306_page_qualifer_name/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `first_name` on the `pages` table. All the data in the column will be lost. + - Added the required column `page_first_name` to the `pages` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "first_name", +ADD COLUMN "page_first_name" TEXT NOT NULL; diff --git a/prisma/migrations/20240223151402_page_name/migration.sql b/prisma/migrations/20240223151402_page_name/migration.sql new file mode 100644 index 00000000..a3a2b24e --- /dev/null +++ b/prisma/migrations/20240223151402_page_name/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `last_name` on the `pages` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "last_name", +ADD COLUMN "page_last_name" TEXT NOT NULL DEFAULT '', +ALTER COLUMN "page_first_name" SET DEFAULT ''; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c026cab4..4cebfaab 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -72,8 +72,8 @@ model Page { duration String @default("0 days") start_date String @default("") goal_met_date String @default("") - first_name String - last_name String + page_first_name String @default("") + page_last_name String @default("") DonationPayouts DonationPayout[] Reply Reply[] Images Image[] diff --git a/types.d.ts b/types.d.ts index b210fdcc..63564780 100644 --- a/types.d.ts +++ b/types.d.ts @@ -29,7 +29,7 @@ import { DonationPayout } from "@prisma/client" // TODO: import types from prisma, export them with relations added export type Page = { - first_name: string, + page_first_name: string, last_name: string, cuid: string, userCuid: string, From 58acf75e6c2283f29e8e591d449cae23b3c33796 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Fri, 23 Feb 2024 09:23:29 -0600 Subject: [PATCH 08/22] first_name --- pages/EditPage/[EditPageId].vue | 4 ++-- pages/FamilyReports.vue | 2 +- pages/FamilyTransactionList.vue | 8 ++++---- pages/Page/[id].vue | 2 +- pages/PageList/[id].vue | 4 ++-- pages/Search.vue | 2 +- server/api/complete_session.get.ts | 4 ++-- server/api/create_session.post.ts | 6 +++--- server/api/pages.get.ts | 8 ++++---- types.d.ts | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pages/EditPage/[EditPageId].vue b/pages/EditPage/[EditPageId].vue index 7a030d37..5cbf072c 100644 --- a/pages/EditPage/[EditPageId].vue +++ b/pages/EditPage/[EditPageId].vue @@ -33,8 +33,8 @@ const cvuser2 = useCookie('cvuser') const data = ref({ cuid: "", userCuid: "", - first_name: "", - last_name: "", + page_first_name: "", + page_last_name: "", day_of_birth: "", day_of_passing:"", visitation_date: "", diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index ee003cf4..375e3f7d 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -80,7 +80,7 @@ div // converts array of family pages and their advocate responsible for the family into a csv function convertToCSV(arr : Partial) { - const listOfTags = ["first_name", "last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] + const listOfTags = ["page_first_name", "page_last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] // removes every column not in list of tags Object.keys(arr[0] || "").forEach((element: string) => { const currentArr = ref>([]) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 22d25ce1..fff36426 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -107,8 +107,8 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") leave-to-class='opacity-0' ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) - ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.first_name + " " + page.last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} - ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.first_name || currentPage.last_name) : 'Select Page' }} + ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.page_first_name + " " + page.page_last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} + ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.page_first_name || currentPage.last_name) : 'Select Page' }} .flex.gap-5.justify-around //these next two divs could theoretically be their own component with props @@ -151,7 +151,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.first_name + " " + item?.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_first_name + " " + item?.last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised-item.amount_distributed) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} @@ -176,7 +176,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.transaction_id }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.first_name + " " + item.Page.first_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_first_name + " " + item.Page.page_first_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount) }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index a55cb30c..e1e278fe 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -116,7 +116,7 @@ const DisplayReply = async (reply: Reply) => { // the header overlay with image and name .mt-2.min-h-24.text-white.uppercase.w-full(style="background-image: url('https://carsonsvillage.org/wp-content/uploads/2018/11/iStock-862083112-BW.jpg');") .h-full.py-8.self-center.w-full.text-center.flex.flex-col(style="background-color: rgba(50, 119, 136, .8)") - p.my-auto.font-bold.text-4xl {{ pageDataDB.first_name + " " + pageDataDB.last_name }} + p.my-auto.font-bold.text-4xl {{ pageDataDB.page_first_name + " " + pageDataDB.page_last_name }} .flex.flex-col.gap-5.px-4.mx-auto.mt-8(class="w-3/4 sm:px-16") img.mx-auto(v-if="profileImageLink" class="w-[122px] h-[122px] rounded-[8px]" :src="`${profileImageLink}`") diff --git a/pages/PageList/[id].vue b/pages/PageList/[id].vue index 1792457d..b962b0e8 100644 --- a/pages/PageList/[id].vue +++ b/pages/PageList/[id].vue @@ -186,7 +186,7 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.first_name + " " + item.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_first_name + " " + item.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td @@ -209,7 +209,7 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.first_name + " " + item.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_first_name + " " + item.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td diff --git a/pages/Search.vue b/pages/Search.vue index 6de10037..6f17e5f9 100644 --- a/pages/Search.vue +++ b/pages/Search.vue @@ -73,7 +73,7 @@ onMounted(() => { tbody tr(v-for="(page, i) in pages" :class="{'bg-gray-200': (i+1) % 2}") td(style="text-align: center") - NuxtLink(:to="`/Page/${page.cuid}`") {{ page.first_name + " " + page.last_name }} + NuxtLink(:to="`/Page/${page.cuid}`") {{ page.page_first_name + " " + page.page_last_name }} td(style="text-align: center") {{ donationFormat(page.donation_goal) }} td(style="text-align: center") {{ dateFormat(page.deadline) }} .ml-9.mb-9.py-7.flex.flex-wrap.gap-2.place-content-center diff --git a/server/api/complete_session.get.ts b/server/api/complete_session.get.ts index e8a39fa9..644a9169 100644 --- a/server/api/complete_session.get.ts +++ b/server/api/complete_session.get.ts @@ -23,8 +23,8 @@ export default defineEventHandler(async event => { include: { Page: { select: { - first_name: true, - last_name: true, + page_first_name: true, + page_last_name: true, amount_raised: true, donation_goal: true, deadline: true, diff --git a/server/api/create_session.post.ts b/server/api/create_session.post.ts index 3adbcbc9..3a9d5d21 100644 --- a/server/api/create_session.post.ts +++ b/server/api/create_session.post.ts @@ -39,7 +39,7 @@ export default defineEventHandler(async event => { currency: 'usd', unit_amount: body.amount_raised, product_data: { - name: `Donation to ${page?.first_name} ${page?.last_name}`, + name: `Donation to ${page?.page_first_name} ${page?.page_last_name}`, }, }, quantity: 1 @@ -50,8 +50,8 @@ export default defineEventHandler(async event => { amount: body.amount_raised, target_user_id: userCuid, target_family_id: familyCuid, - target_first_name: page?.first_name as string, - target_last_name: page?.last_name as string, + target_first_name: page?.page_first_name as string, + target_last_name: page?.page_last_name as string, target_page_cuid: page?.cuid as string, comments: donorComments, }, diff --git a/server/api/pages.get.ts b/server/api/pages.get.ts index 6bc0057f..e05b39b8 100644 --- a/server/api/pages.get.ts +++ b/server/api/pages.get.ts @@ -36,24 +36,24 @@ const runtime = useRuntimeConfig() const [count, pagesResult] = await prisma.$transaction([ prisma.page.count({ where: { OR: [ { - first_name: { + page_first_name: { contains: searchQuery as string, mode: 'insensitive', } }, - { last_name: { + { page_last_name: { contains: searchQuery as string, mode: 'insensitive', }}] }}), prisma.page.findMany({ where: { OR: [ { - first_name: { + page_first_name: { contains: searchQuery as string, mode: 'insensitive', } }, { - last_name: { + page_last_name: { contains: searchQuery as string, mode: 'insensitive', } diff --git a/types.d.ts b/types.d.ts index 63564780..da0f7e53 100644 --- a/types.d.ts +++ b/types.d.ts @@ -30,7 +30,7 @@ import { DonationPayout } from "@prisma/client" // TODO: import types from prisma, export them with relations added export type Page = { page_first_name: string, - last_name: string, + page_last_name: string, cuid: string, userCuid: string, familyCuid: string, From 280a170a585a743d10051fd9b3fbd64b9c04ba09 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Sun, 25 Feb 2024 13:15:02 -0600 Subject: [PATCH 09/22] more commits --- pages/EditPage/[EditPageId].vue | 4 ++-- pages/FamilyReports.vue | 2 +- pages/Page/[id].vue | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/EditPage/[EditPageId].vue b/pages/EditPage/[EditPageId].vue index 5cbf072c..16341ac8 100644 --- a/pages/EditPage/[EditPageId].vue +++ b/pages/EditPage/[EditPageId].vue @@ -232,11 +232,11 @@ CVContainer .py-4.grid(class="sm:grid-cols-3") CVLabel First Name .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") - CVInput(v-model='data.first_name' placeholder="required" required) + CVInput(v-model='data.page_first_name' placeholder="required" required) .py-4.grid(class="sm:grid-cols-3") CVLabel Last Name .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") - CVInput(v-model='data.last_name' placeholder="required" required) + CVInput(v-model='data.page_last_name' placeholder="required" required) .py-4.grid(class="sm:grid-cols-3" v-if="isAdvocate") CVLabel Family .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index 375e3f7d..8478dc37 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -22,7 +22,7 @@ div tbody(v-for="family in families") tr(v-for="(page,i) in family.Pages" :class="{'bg-gray-200': (i+1) % 2}") - td(style="text-align: center;") {{ page.first_name + " " + page.last_name}} + td(style="text-align: center;") {{ page.page_first_name + " " + page.page_last_name}} td(style="text-align: center;") {{ family.AdvocateResponsible.first_name + " " + family.AdvocateResponsible.last_name }} td(style="text-align: center;") {{ page.duration }} td(style="text-align: center;") {{ page.donation_status }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index e1e278fe..83ff26c0 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -71,7 +71,7 @@ const shareFacebook = () => { } const shareXFormerlyKnownAsTwitter = () => { - const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&url=${window.location.href}` + const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.page_first_name}${pageDataDB.value?.page_last_name}&url=${window.location.href}` window.open(xShareLink) } From f0a0ff225283183d99ba8c9bb55fe76628f7fe8b Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Wed, 28 Feb 2024 17:45:21 -0600 Subject: [PATCH 10/22] page fix --- pages/FamilyTransactionList.vue | 6 +++--- pages/Page/[id].vue | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index fff36426..9c253779 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -108,7 +108,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.page_first_name + " " + page.page_last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} - ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.page_first_name || currentPage.last_name) : 'Select Page' }} + ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.page_first_name || currentPage.page_last_name) : 'Select Page' }} .flex.gap-5.justify-around //these next two divs could theoretically be their own component with props @@ -151,7 +151,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_first_name + " " + item?.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_first_name + " " + item?.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised-item.amount_distributed) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} @@ -176,7 +176,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.transaction_id }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_first_name + " " + item.Page.page_first_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_first_name + " " + item.Page.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount) }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index 83ff26c0..946ba03a 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -66,7 +66,7 @@ const create_checkout_session = async () => { }; const shareFacebook = () => { - const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&u=${window.location.href}` + const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.page_first_name}${pageDataDB.value?.page_last_name}&u=${window.location.href}` window.open(facebookShareLink) } From 881902e231e23f334938341e4eee62d7df486a9f Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 8 Feb 2024 15:23:34 -0600 Subject: [PATCH 11/22] Basic Prisma Change; Needs follow up --- prisma/schema.prisma | 3 ++- server/api/create_transfer.post.ts | 0 types.d.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 server/api/create_transfer.post.ts diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b340f00e..7cbf1a81 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -52,7 +52,8 @@ model DonationPayout { model Page { cuid String @id @default(cuid()) - page_name String + first_name String + last_name String day_of_birth String? day_of_passing String? visitation_date String? diff --git a/server/api/create_transfer.post.ts b/server/api/create_transfer.post.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/types.d.ts b/types.d.ts index 54a42c33..b210fdcc 100644 --- a/types.d.ts +++ b/types.d.ts @@ -29,7 +29,8 @@ import { DonationPayout } from "@prisma/client" // TODO: import types from prisma, export them with relations added export type Page = { - page_name: string, + first_name: string, + last_name: string, cuid: string, userCuid: string, familyCuid: string, From 65b64f3772a36c97df037d310b0246e129848a7d Mon Sep 17 00:00:00 2001 From: Samuel Ma <126997597+FegelSamuel@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:29:22 -0600 Subject: [PATCH 12/22] EditPageID converted --- pages/EditPage/[EditPageId].vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pages/EditPage/[EditPageId].vue b/pages/EditPage/[EditPageId].vue index 74c91dfc..7a030d37 100644 --- a/pages/EditPage/[EditPageId].vue +++ b/pages/EditPage/[EditPageId].vue @@ -33,7 +33,8 @@ const cvuser2 = useCookie('cvuser') const data = ref({ cuid: "", userCuid: "", - page_name: "", + first_name: "", + last_name: "", day_of_birth: "", day_of_passing:"", visitation_date: "", @@ -229,9 +230,13 @@ CVContainer .information.bg-gray-300.rounded-md.mx-9.my-2.text-center(class="sm:text-start") CVLegend Personal Information .py-4.grid(class="sm:grid-cols-3") - CVLabel Page Name + CVLabel First Name .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") - CVInput(v-model='data.page_name' placeholder="required" required) + CVInput(v-model='data.first_name' placeholder="required" required) + .py-4.grid(class="sm:grid-cols-3") + CVLabel Last Name + .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") + CVInput(v-model='data.last_name' placeholder="required" required) .py-4.grid(class="sm:grid-cols-3" v-if="isAdvocate") CVLabel Family .col-md-8.mx-9(class="sm:col-span-2 sm:mr-11") From 0325d0e0faea3076b0be1b28da9b5985d616bd43 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Tue, 20 Feb 2024 16:15:38 -0600 Subject: [PATCH 13/22] SQL migrated --- .../migration.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql diff --git a/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql b/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql new file mode 100644 index 00000000..78cc5874 --- /dev/null +++ b/prisma/migrations/20240220175128_page_name_first_name_last_name/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - You are about to drop the column `page_name` on the `pages` table. All the data in the column will be lost. + - Added the required column `first_name` to the `pages` table without a default value. This is not possible if the table is not empty. + - Added the required column `last_name` to the `pages` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "page_name", +ADD COLUMN "first_name" TEXT NOT NULL, +ADD COLUMN "last_name" TEXT NOT NULL; From c5e3fe90c06592a874fbd8f3ebc6f7b441bfeec6 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Tue, 20 Feb 2024 16:16:06 -0600 Subject: [PATCH 14/22] schema and prisma changes --- pages/FamilyReports.vue | 2 +- pages/FamilyTransactionList.vue | 4 +- pages/Page/[id].vue | 2 +- pages/PageList/[id].vue | 6 ++- pages/Search.vue | 2 +- prisma/schema.prisma | 93 ++++++++++++++++----------------- 6 files changed, 54 insertions(+), 55 deletions(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index 7b30d25a..e411368f 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -23,7 +23,7 @@ div tbody(v-for="family in families") tr(v-for="(page,i) in family.Pages" :class="{'bg-gray-200': (i+1) % 2}") - td(style="text-align: center;") {{ page.page_name }} + td(style="text-align: center;") {{ page.first_name + " " + page.last_name}} td(style="text-align: center;") {{ family.AdvocateResponsible.first_name + " " + family.AdvocateResponsible.last_name }} td(style="text-align: center;") {{ page.duration }} td(style="text-align: center;") {{ page.donation_status }} diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 4632f594..2a364bdb 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -107,7 +107,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") leave-to-class='opacity-0' ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) - ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.page_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} + ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.first_name + " " + page.last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? currentPage.page_name : 'Select Page' }} .flex.gap-5.justify-around @@ -150,7 +150,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.first_name + " " + item?.last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised-item.amount_distributed) }} .ml-9.mb-9.py-7.flex.flex-wrap.gap-2.place-content-center diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index 5472c1bc..c4457338 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -116,7 +116,7 @@ const DisplayReply = async (reply: Reply) => { // the header overlay with image and name .mt-2.min-h-24.text-white.uppercase.w-full(style="background-image: url('https://carsonsvillage.org/wp-content/uploads/2018/11/iStock-862083112-BW.jpg');") .h-full.py-8.self-center.w-full.text-center.flex.flex-col(style="background-color: rgba(50, 119, 136, .8)") - p.my-auto.font-bold.text-4xl {{ pageDataDB.page_name }} + p.my-auto.font-bold.text-4xl {{ pageDataDB.first_name + " " + pageDataDB.last_name }} .flex.flex-col.gap-5.px-4.mx-auto.mt-8(class="w-3/4 sm:px-16") img.mx-auto(v-if="profileImageLink" class="w-[122px] h-[122px] rounded-[8px]" :src="`${profileImageLink}`") diff --git a/pages/PageList/[id].vue b/pages/PageList/[id].vue index 35e8b2ff..e209cace 100644 --- a/pages/PageList/[id].vue +++ b/pages/PageList/[id].vue @@ -185,7 +185,8 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.first_name + " " + item.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td LinkButton(class="sm:my-2" style="--tw-bg-opacity: 1; background-color: rgb(110 171 191 / var(--tw-bg-opacity)); white-space: nowrap; display: flex; flex-direction: row; padding: 14px 24px; gap: 10px;" :to="`/EditPage/${item.cuid}`") Edit @@ -206,7 +207,8 @@ await getDataPageList() :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ item.page_first_name + " " + item.page_last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center;" v-if="isAdmin") {{ item.userCuid }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center;") {{ dateFormat(item.deadline) }} td LinkButton(class="sm:my-2" style="--tw-bg-opacity: 1; background-color: rgb(110 171 191 / var(--tw-bg-opacity)); white-space: nowrap; display: flex; flex-direction: row; padding: 14px 24px; gap: 10px;" :to="`/EditPage/${item.cuid}`") Edit diff --git a/pages/Search.vue b/pages/Search.vue index 8b35943a..6de10037 100644 --- a/pages/Search.vue +++ b/pages/Search.vue @@ -73,7 +73,7 @@ onMounted(() => { tbody tr(v-for="(page, i) in pages" :class="{'bg-gray-200': (i+1) % 2}") td(style="text-align: center") - NuxtLink(:to="`/Page/${page.cuid}`") {{ page.page_name}} + NuxtLink(:to="`/Page/${page.cuid}`") {{ page.first_name + " " + page.last_name }} td(style="text-align: center") {{ donationFormat(page.donation_goal) }} td(style="text-align: center") {{ dateFormat(page.deadline) }} .ml-9.mb-9.py-7.flex.flex-wrap.gap-2.place-content-center diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7cbf1a81..c026cab4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -9,18 +9,17 @@ datasource db { } model User { - cuid String @id @default(cuid()) - email String @unique - user_role String @default("family") // advocate, admin - first_name String @default("") - middle_name String @default("") - last_name String @default("") - phone String @default("") - - AdvocateFamily Family[] @relation("advocate_family") - Family Family? @relation(name: "family_member", fields: [familyCuid], references: [cuid]) + cuid String @id @default(cuid()) + email String @unique + user_role String @default("family") + first_name String @default("") + middle_name String @default("") + last_name String @default("") + phone String @default("") familyCuid String? + AdvocateFamily Family[] @relation("advocate_family") Pages Page[] + Family Family? @relation("family_member", fields: [familyCuid], references: [cuid]) @@map("user_accounts") } @@ -29,14 +28,14 @@ model Family { cuid String @id @default(cuid()) family_name String stripe_account_id String? - FamilyMembers User[] @relation("family_member") created_at String @default("") updated_at String @default("") - Pages Page[] - FamilyDonations PageDonation[] - FamilyDonationPayouts DonationPayout[] advocateCuid String @map("advocate_cuid") - AdvocateResponsible User? @relation("advocate_family", fields: [advocateCuid], references: [cuid]) + FamilyDonationPayouts DonationPayout[] + AdvocateResponsible User @relation("advocate_family", fields: [advocateCuid], references: [cuid]) + FamilyDonations PageDonation[] + Pages Page[] + FamilyMembers User[] @relation("family_member") } model DonationPayout { @@ -46,43 +45,41 @@ model DonationPayout { transaction_id String @unique amount Int @default(0) distributionDate String - Family Family @relation(fields: [familyCuid], references: cuid) - Page Page @relation(fields: [pageCuid], references: cuid) + Family Family @relation(fields: [familyCuid], references: [cuid]) + Page Page @relation(fields: [pageCuid], references: [cuid]) } model Page { - cuid String @id @default(cuid()) - first_name String - last_name String + cuid String @id @default(cuid()) day_of_birth String? day_of_passing String? visitation_date String? visitation_location String visitation_description String - - funeral_date String? - funeral_location String - funeral_description String - - obituary String - donation_goal Int @default(0) - amount_raised Int @default(0) - deadline String - userCuid String @map("user_cuid") - PageDonations PageDonation[] - DonationPayouts DonationPayout[] - User User @relation(fields: [userCuid], references: cuid) - Images Image[] - amount_distributed Int @default(0) - profileImageCuid String @map("profile_image_cuid") - Family Family? @relation(fields: [familyCuid], references: cuid) - familyCuid String? @map("family_cuid") - status String @default("active") - donation_status String @default("in progress") - duration String @default("0 days") - start_date String @default("") - goal_met_date String @default("") - Reply Reply[] + funeral_date String? + funeral_location String + funeral_description String + obituary String + donation_goal Int @default(0) + amount_raised Int @default(0) + deadline String + userCuid String @map("user_cuid") + amount_distributed Int @default(0) + profileImageCuid String @map("profile_image_cuid") + familyCuid String? @map("family_cuid") + status String @default("active") + donation_status String @default("in progress") + duration String @default("0 days") + start_date String @default("") + goal_met_date String @default("") + first_name String + last_name String + DonationPayouts DonationPayout[] + Reply Reply[] + Images Image[] + PageDonations PageDonation[] + Family Family? @relation(fields: [familyCuid], references: [cuid]) + User User @relation(fields: [userCuid], references: [cuid]) @@map("pages") } @@ -97,9 +94,9 @@ model PageDonation { isAnonymous Boolean @default(false) success Boolean @default(false) transaction_id String @unique - amount Int //In cents - Family Family @relation(fields: [familyCuid], references: cuid) - Page Page @relation(fields: [pageCuid], references: cuid) + amount Int + Family Family @relation(fields: [familyCuid], references: [cuid]) + Page Page @relation(fields: [pageCuid], references: [cuid]) @@map("page_donations") } @@ -110,7 +107,7 @@ model Reply { familyCuid String @map("family_cuid") reply String @default("") name String? @default("") - Page Page @relation(fields: [pageCuid], references: cuid) + Page Page @relation(fields: [pageCuid], references: [cuid]) } model Image { From 9f521518239cc5e9bdec14d1eaf437473ff8eef4 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 22 Feb 2024 13:51:40 -0600 Subject: [PATCH 15/22] Looks okay to me, unsure of what else to fix. Need to ask Ofek about one more thing though --- pages/FamilyReports.vue | 2 +- pages/FamilyTransactionList.vue | 5 +++++ pages/Page/[id].vue | 8 ++++---- server/api/complete_session.get.ts | 3 ++- server/api/create_session.post.ts | 5 +++-- server/api/pages.get.ts | 1 + 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index e411368f..9b009ce6 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -81,7 +81,7 @@ div // converts array of family pages and their advocate responsible for the family into a csv function convertToCSV(arr : Partial) { - const listOfTags = ["page_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] + const listOfTags = ["first_name", "last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] // removes every column not in list of tags Object.keys(arr[0] || "").forEach((element: string) => { const currentArr = ref>([]) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 2a364bdb..6481c733 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -172,7 +172,12 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :class="{'bg-gray-200': (i+1) % 2}" ) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.transaction_id }} +<<<<<<< HEAD td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_name }} +======= + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.first_name + " " + item.Page.first_name }} +>>>>>>> 9c07cfd (Looks okay to me, unsure of what else to fix. Need to ask Ofek about one more thing though) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount) }} diff --git a/pages/Page/[id].vue b/pages/Page/[id].vue index c4457338..a55cb30c 100644 --- a/pages/Page/[id].vue +++ b/pages/Page/[id].vue @@ -66,12 +66,12 @@ const create_checkout_session = async () => { }; const shareFacebook = () => { - const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.page_name}&u=${window.location.href}` + const facebookShareLink = `https://www.facebook.com/sharer/sharer.php?caption=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&u=${window.location.href}` window.open(facebookShareLink) } -const shareXFormalyKnownAsTwitter = () => { - const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.page_name}&url=${window.location.href}` +const shareXFormerlyKnownAsTwitter = () => { + const xShareLink = `https://twitter.com/intent/tweet?text=${pageDataDB.value?.first_name}${pageDataDB.value?.last_name}&url=${window.location.href}` window.open(xShareLink) } @@ -194,7 +194,7 @@ const DisplayReply = async (reply: Reply) => { button(@click="shareFacebook") img(src="/facebook-fa.png" style="width:30px; height:33px;") .col - button(@click="shareXFormalyKnownAsTwitter") + button(@click="shareXFormerlyKnownAsTwitter") img(src="/twitter_fa.png" style="width:30px; height:29px;") .col button(@click="shareMail") diff --git a/server/api/complete_session.get.ts b/server/api/complete_session.get.ts index f497e897..e8a39fa9 100644 --- a/server/api/complete_session.get.ts +++ b/server/api/complete_session.get.ts @@ -23,7 +23,8 @@ export default defineEventHandler(async event => { include: { Page: { select: { - page_name: true, + first_name: true, + last_name: true, amount_raised: true, donation_goal: true, deadline: true, diff --git a/server/api/create_session.post.ts b/server/api/create_session.post.ts index 215510e9..3adbcbc9 100644 --- a/server/api/create_session.post.ts +++ b/server/api/create_session.post.ts @@ -39,7 +39,7 @@ export default defineEventHandler(async event => { currency: 'usd', unit_amount: body.amount_raised, product_data: { - name: `Donation to ${page?.page_name}`, + name: `Donation to ${page?.first_name} ${page?.last_name}`, }, }, quantity: 1 @@ -50,7 +50,8 @@ export default defineEventHandler(async event => { amount: body.amount_raised, target_user_id: userCuid, target_family_id: familyCuid, - target_page_name: page?.page_name as string, + target_first_name: page?.first_name as string, + target_last_name: page?.last_name as string, target_page_cuid: page?.cuid as string, comments: donorComments, }, diff --git a/server/api/pages.get.ts b/server/api/pages.get.ts index e467d020..b9a3a9de 100644 --- a/server/api/pages.get.ts +++ b/server/api/pages.get.ts @@ -29,6 +29,7 @@ const runtime = useRuntimeConfig() console.log(page_number) // Pagination via taking the absolute page number with 12 records per page + // TODO: Figure this out const [count, pagesResult] = await prisma.$transaction([ prisma.page.count({ where: { page_name: { contains: searchQuery as string, From 50fe7f1f5595664d892785caacfe1b88b2a48304 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Thu, 22 Feb 2024 15:46:51 -0600 Subject: [PATCH 16/22] corrected from Ofek --- pages/FamilyTransactionList.vue | 2 +- server/api/pages.get.ts | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 6481c733..f8ac445d 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -108,7 +108,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.first_name + " " + page.last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} - ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? currentPage.page_name : 'Select Page' }} + ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.first_name || currentPage.last_name) : 'Select Page' }} .flex.gap-5.justify-around //these next two divs could theoretically be their own component with props diff --git a/server/api/pages.get.ts b/server/api/pages.get.ts index b9a3a9de..6bc0057f 100644 --- a/server/api/pages.get.ts +++ b/server/api/pages.get.ts @@ -29,18 +29,36 @@ const runtime = useRuntimeConfig() console.log(page_number) // Pagination via taking the absolute page number with 12 records per page - // TODO: Figure this out + // Transaction is a Database thing + // You can get away with doing multiple operations at once. + // count gets the amount of pages with the same name + // const [count, pagesResult] = await prisma.$transaction([ - prisma.page.count({ where: { page_name: { + prisma.page.count({ where: { + OR: [ { + first_name: { contains: searchQuery as string, mode: 'insensitive', - } }}), + } }, + { last_name: { + contains: searchQuery as string, + mode: 'insensitive', + }}] }}), prisma.page.findMany({ where: { - page_name: { - contains: searchQuery as string, - mode: 'insensitive', - } + OR: [ { + first_name: { + contains: searchQuery as string, + mode: 'insensitive', + } + }, + { + last_name: { + contains: searchQuery as string, + mode: 'insensitive', + } + } + ] }, skip: page_number as number * 12, take: 12, From 980d3297c80f0c504373dc5d216b4b419bede0e9 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Fri, 23 Feb 2024 09:14:40 -0600 Subject: [PATCH 17/22] initial schema and types change --- .../20240223151306_page_qualifer_name/migration.sql | 10 ++++++++++ .../migrations/20240223151402_page_name/migration.sql | 10 ++++++++++ prisma/schema.prisma | 4 ++-- types.d.ts | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20240223151306_page_qualifer_name/migration.sql create mode 100644 prisma/migrations/20240223151402_page_name/migration.sql diff --git a/prisma/migrations/20240223151306_page_qualifer_name/migration.sql b/prisma/migrations/20240223151306_page_qualifer_name/migration.sql new file mode 100644 index 00000000..d69e5445 --- /dev/null +++ b/prisma/migrations/20240223151306_page_qualifer_name/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `first_name` on the `pages` table. All the data in the column will be lost. + - Added the required column `page_first_name` to the `pages` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "first_name", +ADD COLUMN "page_first_name" TEXT NOT NULL; diff --git a/prisma/migrations/20240223151402_page_name/migration.sql b/prisma/migrations/20240223151402_page_name/migration.sql new file mode 100644 index 00000000..a3a2b24e --- /dev/null +++ b/prisma/migrations/20240223151402_page_name/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `last_name` on the `pages` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "pages" DROP COLUMN "last_name", +ADD COLUMN "page_last_name" TEXT NOT NULL DEFAULT '', +ALTER COLUMN "page_first_name" SET DEFAULT ''; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c026cab4..4cebfaab 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -72,8 +72,8 @@ model Page { duration String @default("0 days") start_date String @default("") goal_met_date String @default("") - first_name String - last_name String + page_first_name String @default("") + page_last_name String @default("") DonationPayouts DonationPayout[] Reply Reply[] Images Image[] diff --git a/types.d.ts b/types.d.ts index b210fdcc..63564780 100644 --- a/types.d.ts +++ b/types.d.ts @@ -29,7 +29,7 @@ import { DonationPayout } from "@prisma/client" // TODO: import types from prisma, export them with relations added export type Page = { - first_name: string, + page_first_name: string, last_name: string, cuid: string, userCuid: string, From 335385766805bb4e0fbd0fe98cc29fbb2a5211e1 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Wed, 28 Feb 2024 17:45:21 -0600 Subject: [PATCH 18/22] page fix --- pages/FamilyTransactionList.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pages/FamilyTransactionList.vue b/pages/FamilyTransactionList.vue index 1161621a..827bf04f 100644 --- a/pages/FamilyTransactionList.vue +++ b/pages/FamilyTransactionList.vue @@ -108,7 +108,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) ListboxOptions(as='div' class='w-full absolute z-10 mt-10 bg-white shadow-lg max-h-60 rounded-md px-2 py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm' ) ListboxOption(as='div' v-for="page in familyData.raw_data" :key="page.cuid" :value="page.cuid" class="px-2 border border-grey-500 py-1 my-1") {{ page.page_first_name + " " + page.page_last_name }} | {{ donationFormat(page?.amount_raised - page?.amount_distributed) }} - ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.page_first_name || currentPage.last_name) : 'Select Page' }} + ListboxButton(class='text-left bg-white relative rounded-md pl-2 pr-10 py-2 sm:text-sm w-96') {{ currentPageCuid ? (currentPage.page_first_name || currentPage.page_last_name) : 'Select Page' }} .flex.gap-5.justify-around //these next two divs could theoretically be their own component with props @@ -150,7 +150,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") :key="i" :class="{'bg-gray-200': (i+1) % 2}" ) - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_first_name + " " + item?.last_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item?.page_first_name + " " + item?.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised) }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount_raised-item.amount_distributed) }} .ml-9.mb-9.py-7.flex.flex-wrap.gap-2.place-content-center @@ -173,8 +173,7 @@ const isAdvocate = computed(() => cvuser.value?.user_role == "advocate") ) td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.transaction_id }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.cuid }} - - td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_first_name + " " + item.Page.page_first_name }} + td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ item.Page.page_first_name + " " + item.Page.page_last_name }} td.font-poppins.text-gray-dark.font-bold(style="text-align: center") {{ donationFormat(item.amount) }} From 93a443098449f1bf2691bf205ddc5bea1266d4b2 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Mon, 4 Mar 2024 18:00:46 -0600 Subject: [PATCH 19/22] tazfix --- pages/FamilyReports.vue | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index ec922c63..db3bd62e 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -81,37 +81,8 @@ div // converts array of family pages and their advocate responsible for the family into a csv function convertToCSV(arr : Partial) { - const listOfTags = ["page_first_name", "page_last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] - // removes every column not in list of tags - Object.keys(arr[0] || "").forEach((element: string) => { - const currentArr = ref>([]) - if(!listOfTags.includes(element)) { - arr.forEach((d: any) => { - const { [element]: removedSeries , ...newObject } = d - currentArr.value.push(newObject) - }); - arr = currentArr.value - } - }) - - //adds owed Percent - type pageReport = Partial & { owedPercent: number | undefined } - const currentArr = ref([]) - arr.forEach((d) => { - const owed = (d?.amount_raised as number) - (d?.amount_distributed as number) - const goal = (d?.donation_goal as number) - const owedPercent: number | undefined = goal != 0 ? ((100 * owed) / goal) : 0 - - currentArr.value.push({...d, ['owedPercent']: owedPercent | 0} ) - }); - - - const array = [listOfTags].concat(currentArr.value as unknown as string[]) - - // creates CSV - return array.map(it => { - return Object.values(it).toString() - }).join('\n') + const headers = ["page_first_name", "page_last_name", "donation_goal", "amount_raised", "deadline", "amount_distributed", "donation_status", "duration", "start_date", "goal_met_date", "first_name", "middle_name", "last_name", "Amount Owed / Goal Percentage" ] + return arr.reduce((acc: any[], page: any) => [...acc, headers.reduce((acc: string[], header: string) => [...acc, page[header]], []).join(",")], []).join("\n") } // loads family report data from the families database table and joins and creates a download link for the file From 617b7bff3a2b337bcdf6d2a3e273f2e661e70cb9 Mon Sep 17 00:00:00 2001 From: Samuel Ma Date: Wed, 6 Mar 2024 13:30:04 -0600 Subject: [PATCH 20/22] [HOTFIX] HTML Problem --- pages/FamilyReports.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/FamilyReports.vue b/pages/FamilyReports.vue index db3bd62e..2aa0e6ba 100644 --- a/pages/FamilyReports.vue +++ b/pages/FamilyReports.vue @@ -1,7 +1,7 @@