Skip to content

Commit 3bf7611

Browse files
authored
Revert "Eliminar filtro de estado "complete" en query "myPurchaseOrders"" (#215)
Reverts #214 Contexto: https://joincommunityos.slack.com/archives/C06JVJ7483Y/p1722898889514009?thread_ts=1722893980.512209&cid=C06JVJ7483Y
1 parent 7efdf43 commit 3bf7611

6 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/generated/schema.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ type Ticket {
860860
requiresApproval: Boolean!
861861
startDateTime: DateTime!
862862
status: TicketTemplateStatus!
863+
tags: [String!]!
863864
visibility: TicketTemplateVisibility!
864865
}
865866

src/generated/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ export type Ticket = {
889889
requiresApproval: Scalars["Boolean"]["output"];
890890
startDateTime: Scalars["DateTime"]["output"];
891891
status: TicketTemplateStatus;
892+
tags: Array<Scalars["String"]["output"]>;
892893
visibility: TicketTemplateVisibility;
893894
};
894895

src/schema/purchaseOrder/actions.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,17 @@ export const createPaymentIntent = async ({
323323
where: (po, { eq }) => eq(po.id, purchaseOrderId),
324324
with: {
325325
user: true,
326-
tickets: {
326+
userTickets: {
327327
with: {
328-
event: {
328+
ticketTemplate: {
329329
with: {
330-
eventsToCommunities: {
330+
event: {
331331
with: {
332-
community: true,
332+
eventsToCommunities: {
333+
with: {
334+
community: true,
335+
},
336+
},
333337
},
334338
},
335339
},
@@ -339,7 +343,7 @@ export const createPaymentIntent = async ({
339343
},
340344
});
341345

342-
const eventInfo = information?.tickets[0].event;
346+
const eventInfo = information?.userTickets?.[0]?.ticketTemplate?.event;
343347

344348
if (!eventInfo) {
345349
logger.error("Event not found");

src/schema/purchaseOrder/queries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ builder.queryField("myPurchaseOrders", (t) =>
3636
await purchaseOrderFetcher.searchPaginatedPurchaseOrders({
3737
DB,
3838
search: {
39+
status: ["complete"],
3940
userIds: [USER.id],
4041
paymentPlatform: input.search?.paymentPlatform
4142
? ([input.search?.paymentPlatform] as ["stripe" | "mercadopago"])

src/schema/userTickets/mutations.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,8 @@ builder.mutationFields((t) => ({
383383
}
384384
}
385385

386-
const isApproved = ticketTemplate.isFree
387-
? ticketTemplate.requiresApproval
388-
: false;
386+
const isApproved =
387+
ticketTemplate.isFree && !ticketTemplate.requiresApproval;
389388

390389
// If no errors were thrown, we can proceed to reserve the
391390
// tickets.

src/schema/userTickets/userTicketFetcher.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const getSearchUserTicketsQuery = (
4949
wheres.push(inArray(userTicketsSchema.userId, userIds));
5050
}
5151

52-
if (eventIds) {
52+
if (eventIds && eventIds.length > 0) {
5353
const shouldFilterByUserIds = userIds && userIds.length > 0;
5454

5555
// subquery to get all the tickets associated with events
@@ -88,19 +88,19 @@ const getSearchUserTicketsQuery = (
8888
);
8989
}
9090

91-
if (approvalStatus) {
91+
if (approvalStatus && approvalStatus.length > 0) {
9292
wheres.push(inArray(userTicketsSchema.approvalStatus, approvalStatus));
9393
}
9494

95-
if (redemptionStatus) {
95+
if (redemptionStatus && redemptionStatus.length > 0) {
9696
wheres.push(inArray(userTicketsSchema.redemptionStatus, redemptionStatus));
9797
}
9898

99-
if (ticketIds) {
99+
if (ticketIds && ticketIds.length > 0) {
100100
wheres.push(inArray(userTicketsSchema.id, ticketIds));
101101
}
102102

103-
if (userTicketIds) {
103+
if (userTicketIds && userTicketIds.length > 0) {
104104
wheres.push(inArray(userTicketsSchema.id, userTicketIds));
105105
}
106106

0 commit comments

Comments
 (0)