Skip to content

Commit 8a29f66

Browse files
authored
Merge pull request #51 from UTDallasEPICS/stage
download all contacts
2 parents 7aceffe + 25b7545 commit 8a29f66

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

pages/index.vue

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.flex.gap-5
33
.flex.flex-col(class="w-1/6")
44
.flex.flex-col.py-4.font-bold
5-
button.border.border-gray-200.rounded-lg.p-2.whitespace-nowrap(@click="downloadContacts()" class="hover:bg-blue-600 hover:text-white") Download Contacts
5+
button.border.border-gray-200.rounded-lg.p-2.whitespace-nowrap(@click="downloadContacts()" class="hover:bg-blue-600 hover:text-white") Download All Contacts
66
.flex.flex-col.py-4.font-bold
77
strong Tags
88
Multiselect(
@@ -174,7 +174,7 @@ const constructQueryParams = () => {
174174
tag: tagsQueryParam,
175175
cursor: cursors.value[currentPage.value] + '',
176176
pageSize: pageSize.value + '',
177-
showRemoved: filters.value.showRemoved,
177+
showRemoved: String(filters.value.showRemoved),
178178
});
179179
console.log("startdate with isostring", filters.value.startDate);
180180
console.log("enddate with iostring", filters.value.endDate);
@@ -201,9 +201,8 @@ const fetchContacts = async () => {
201201
// NOTE FOR TAZ: this should ideally be computed coming off a useFetch
202202
onMounted(() => fetchContacts());
203203
const downloadContacts = async () => {
204-
const queryParams = constructQueryParams();
205204
// Using the `query` in the fetch URL
206-
const response = await fetch(`/api/contacts?${queryParams}`, {
205+
const response = await fetch(`/api/all-contacts`, {
207206
method: 'GET',
208207
});
209208
@@ -213,7 +212,31 @@ const downloadContacts = async () => {
213212
}
214213
215214
const contacts = await response.json();
216-
const headers = Object.keys(contacts[0]);
215+
const headers = [
216+
"lastName",
217+
"firstName",
218+
"middleName",
219+
"prefix",
220+
"suffix",
221+
"company",
222+
"professionalTitle",
223+
"address1",
224+
"city1",
225+
"state1",
226+
"zipCode1",
227+
"address1Type",
228+
"address2",
229+
"city2",
230+
"state2",
231+
"zipCode2",
232+
"address2Type",
233+
"mainPhone",
234+
"directPhone",
235+
"mobilePhone",
236+
"emailAddress",
237+
"narrative",
238+
"tag"
239+
]
217240
218241
const reduced = contacts.reduce(
219242
(acc: string, curr: any) => {

server/api/all-contacts.get.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default defineEventHandler(async (event) => {
2+
const data = await event.context.client.contact.findMany({
3+
where: {
4+
removed: false,
5+
},
6+
include: {
7+
tag: true
8+
}
9+
});
10+
return data;
11+
});

0 commit comments

Comments
 (0)