diff --git a/app/api/gql/gql.ts b/app/api/gql/gql.ts index eb4693d..541bf6a 100644 --- a/app/api/gql/gql.ts +++ b/app/api/gql/gql.ts @@ -13,9 +13,9 @@ import type { TypedDocumentNode as DocumentNode } from "@graphql-typed-document- * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - "query FetchExampleEvents {\n events {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n}": + "query FetchExampleEvents($input: PaginatedInputEventsSearchInput!) {\n searchEvents(input: $input) {\n data {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n }\n}": types.FetchExampleEventsDocument, - "query myTickets($input: PaginatedInputMyTicketsSearchValues!) {\n myTickets(input: $input) {\n data {\n approvalStatus\n id\n paymentStatus\n redemptionStatus\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}": + "query myTickets($input: PaginatedInputEventsSearchInput!, $userTicketSearchInput: EventsTicketsSearchInput) {\n searchEvents(input: $input) {\n data {\n id\n name\n description\n startDateTime\n community {\n id\n name\n }\n status\n usersTickets(input: $userTicketSearchInput) {\n id\n approvalStatus\n paymentStatus\n redemptionStatus\n ticketTemplate {\n description\n id\n }\n }\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}": types.MyTicketsDocument, "mutation createPurchaseOrder($input: TicketClaimInput!) {\n claimUserTicket(input: $input) {\n __typename\n ... on PurchaseOrder {\n __typename\n id\n currency {\n id\n }\n finalPrice\n paymentLink\n status\n tickets {\n id\n approvalStatus\n redemptionStatus\n paymentStatus\n }\n }\n ... on RedeemUserTicketError {\n __typename\n error\n errorMessage\n }\n }\n}": types.CreatePurchaseOrderDocument, @@ -43,14 +43,14 @@ export function graphql(source: string): unknown; * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql( - source: "query FetchExampleEvents {\n events {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n}", -): (typeof documents)["query FetchExampleEvents {\n events {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n}"]; + source: "query FetchExampleEvents($input: PaginatedInputEventsSearchInput!) {\n searchEvents(input: $input) {\n data {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n }\n}", +): (typeof documents)["query FetchExampleEvents($input: PaginatedInputEventsSearchInput!) {\n searchEvents(input: $input) {\n data {\n id\n description\n community {\n id\n name\n }\n tags {\n id\n name\n description\n }\n }\n }\n}"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql( - source: "query myTickets($input: PaginatedInputMyTicketsSearchValues!) {\n myTickets(input: $input) {\n data {\n approvalStatus\n id\n paymentStatus\n redemptionStatus\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}", -): (typeof documents)["query myTickets($input: PaginatedInputMyTicketsSearchValues!) {\n myTickets(input: $input) {\n data {\n approvalStatus\n id\n paymentStatus\n redemptionStatus\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}"]; + source: "query myTickets($input: PaginatedInputEventsSearchInput!, $userTicketSearchInput: EventsTicketsSearchInput) {\n searchEvents(input: $input) {\n data {\n id\n name\n description\n startDateTime\n community {\n id\n name\n }\n status\n usersTickets(input: $userTicketSearchInput) {\n id\n approvalStatus\n paymentStatus\n redemptionStatus\n ticketTemplate {\n description\n id\n }\n }\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}", +): (typeof documents)["query myTickets($input: PaginatedInputEventsSearchInput!, $userTicketSearchInput: EventsTicketsSearchInput) {\n searchEvents(input: $input) {\n data {\n id\n name\n description\n startDateTime\n community {\n id\n name\n }\n status\n usersTickets(input: $userTicketSearchInput) {\n id\n approvalStatus\n paymentStatus\n redemptionStatus\n ticketTemplate {\n description\n id\n }\n }\n }\n pagination {\n currentPage\n pageSize\n totalPages\n totalRecords\n }\n }\n}"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/app/api/gql/graphql.ts b/app/api/gql/graphql.ts index bf2978d..3a6214c 100644 --- a/app/api/gql/graphql.ts +++ b/app/api/gql/graphql.ts @@ -55,28 +55,28 @@ export enum CommnunityStatus { /** Representation of a Community */ export type Community = { - banner: Maybe; - description: Maybe; + banner?: Maybe; + description?: Maybe; events: Array; id: Scalars["String"]["output"]; - logo: Maybe; - name: Maybe; + logo?: Maybe; + name?: Maybe; status: CommnunityStatus; users: Array; }; /** Representation of a workEmail */ export type Company = { - description: Maybe; + description?: Maybe; domain: Scalars["String"]["output"]; hasBeenUpdated: Scalars["Boolean"]["output"]; id: Scalars["String"]["output"]; - logo: Maybe; - name: Maybe; + logo?: Maybe; + name?: Maybe; salarySubmissions: Scalars["Int"]["output"]; /** Not available to users */ - status: Maybe; - website: Maybe; + status?: Maybe; + website?: Maybe; }; export enum CompanyStatus { @@ -100,13 +100,13 @@ export type CreateCommunityInput = { }; export type CreateCompanyInput = { - description: InputMaybe; + description?: InputMaybe; /** The email domain of the company (What we'll use to match the company to the user on account-creation) */ domain: Scalars["String"]["input"]; - logo: InputMaybe; - name: InputMaybe; - status: InputMaybe; - website: InputMaybe; + logo?: InputMaybe; + name?: InputMaybe; + status?: InputMaybe; + website?: InputMaybe; }; export type CreateSalaryInput = { @@ -137,16 +137,16 @@ export type EnqueueGoogleAlbumImportInput = { /** Representation of an Event (Events and Users, is what tickets are linked to) */ export type Event = { - address: Maybe; - community: Maybe; - description: Maybe; - endDateTime: Maybe; + address?: Maybe; + community?: Maybe; + description?: Maybe; + endDateTime?: Maybe; id: Scalars["String"]["output"]; images: Array; - latitude: Maybe; - longitude: Maybe; - maxAttendees: Maybe; - meetingURL: Maybe; + latitude?: Maybe; + longitude?: Maybe; + maxAttendees?: Maybe; + meetingURL?: Maybe; name: Scalars["String"]["output"]; startDateTime: Scalars["DateTime"]["output"]; status: EventStatus; @@ -161,39 +161,39 @@ export type Event = { /** Representation of an Event (Events and Users, is what tickets are linked to) */ export type EventUsersTicketsArgs = { - input: InputMaybe; + input?: InputMaybe; }; export type EventCreateInput = { - address: InputMaybe; + address?: InputMaybe; communityId: Scalars["String"]["input"]; description: Scalars["String"]["input"]; - endDateTime: InputMaybe; - latitude: InputMaybe; - longitude: InputMaybe; + endDateTime?: InputMaybe; + latitude?: InputMaybe; + longitude?: InputMaybe; maxAttendees: Scalars["Int"]["input"]; - meetingURL: InputMaybe; + meetingURL?: InputMaybe; name: Scalars["String"]["input"]; startDateTime: Scalars["DateTime"]["input"]; - status: InputMaybe; - timeZone: InputMaybe; - visibility: InputMaybe; + status?: InputMaybe; + timeZone?: InputMaybe; + visibility?: InputMaybe; }; export type EventEditInput = { - address: InputMaybe; - description: InputMaybe; - endDateTime: InputMaybe; + address?: InputMaybe; + description?: InputMaybe; + endDateTime?: InputMaybe; eventId: Scalars["String"]["input"]; - latitude: InputMaybe; - longitude: InputMaybe; - maxAttendees: InputMaybe; - meetingURL: InputMaybe; - name: InputMaybe; - startDateTime: InputMaybe; - status: InputMaybe; - timeZone: InputMaybe; - visibility: InputMaybe; + latitude?: InputMaybe; + longitude?: InputMaybe; + maxAttendees?: InputMaybe; + meetingURL?: InputMaybe; + name?: InputMaybe; + startDateTime?: InputMaybe; + status?: InputMaybe; + timeZone?: InputMaybe; + visibility?: InputMaybe; }; /** Search for tags */ @@ -213,19 +213,20 @@ export enum EventVisibility { } export type EventsSearchInput = { - id: InputMaybe; - name: InputMaybe; - startDateTimeFrom: InputMaybe; - startDateTimeTo: InputMaybe; - status: InputMaybe; - visibility: InputMaybe; + id?: InputMaybe; + name?: InputMaybe; + startDateTimeFrom?: InputMaybe; + startDateTimeTo?: InputMaybe; + status?: InputMaybe; + userHasTickets?: InputMaybe; + visibility?: InputMaybe; }; export type EventsTicketsSearchInput = { - approvalStatus: InputMaybe; - id: InputMaybe; - paymentStatus: InputMaybe; - redemptionStatus: InputMaybe; + approvalStatus?: InputMaybe; + id?: InputMaybe; + paymentStatus?: InputMaybe; + redemptionStatus?: InputMaybe; }; export enum Gender { @@ -376,15 +377,26 @@ export type MutationValidateWorkEmailArgs = { }; export type MyTicketsSearchValues = { - approvalStatus: InputMaybe; - eventId: InputMaybe; - paymentStatus: InputMaybe; - redemptionStatus: InputMaybe; + approvalStatus?: InputMaybe; + eventId?: InputMaybe; + paymentStatus?: InputMaybe; + redemptionStatus?: InputMaybe; +}; + +/** Type used for querying the paginated leaves and it's paginated meta data */ +export type PaginatedEvent = { + data: Array; + pagination: Pagination; +}; + +export type PaginatedInputEventsSearchInput = { + pagination?: PaginationSearchInputParams; + search?: InputMaybe; }; export type PaginatedInputMyTicketsSearchValues = { - pagination: PaginationSearchInputParams; - search: InputMaybe; + pagination?: PaginationSearchInputParams; + search?: InputMaybe; }; /** Type used for querying the paginated leaves and it's paginated meta data */ @@ -432,16 +444,16 @@ export type PublicFinanceEntryRef = { id: Scalars["String"]["output"]; platform: Scalars["String"]["output"]; transactionAmount: Scalars["Float"]["output"]; - transactionDate: Maybe; + transactionDate?: Maybe; }; /** Representation of a Purchase Order */ export type PurchaseOrder = { - currency: Maybe; - finalPrice: Maybe; + currency?: Maybe; + finalPrice?: Maybe; id: Scalars["ID"]["output"]; - paymentLink: Maybe; - status: Maybe; + paymentLink?: Maybe; + status?: Maybe; tickets: Array; }; @@ -460,17 +472,15 @@ export type Query = { /** Get a list of communities. Filter by name, id, or status */ communities: Array; /** Get a community by id */ - community: Maybe; + community?: Maybe; /** Get all available companies */ companies: Array; /** Get all available companies */ company: Company; /** Get an event by id */ - event: Maybe; + event?: Maybe; /** Get a list of images, that are attached to an event */ eventImages: Array; - /** Get a list of events. Filter by name, id, status or date */ - events: Array; /** Get the current user */ me: User; /** Get a list of tickets for the current user */ @@ -479,6 +489,8 @@ export type Query = { salaries: Array; /** Search a consolidated payment logs, by date, aggregated by platform and currency_id */ searchConsolidatedPaymentLogs: Array; + /** Get a list of events. Filter by name, id, status or date */ + searchEvents: PaginatedEvent; /** Search on the payment logs by date, and returns a list of payment logs */ searchPaymentLogs: Array; status: Scalars["String"]["output"]; @@ -499,9 +511,9 @@ export type Query = { }; export type QueryCommunitiesArgs = { - id: InputMaybe; - name: InputMaybe; - status: InputMaybe; + id?: InputMaybe; + name?: InputMaybe; + status?: InputMaybe; }; export type QueryCommunityArgs = { @@ -509,7 +521,7 @@ export type QueryCommunityArgs = { }; export type QueryCompaniesArgs = { - input: InputMaybe; + input?: InputMaybe; }; export type QueryCompanyArgs = { @@ -524,10 +536,6 @@ export type QueryEventImagesArgs = { input: EventImageSearch; }; -export type QueryEventsArgs = { - input: InputMaybe; -}; - export type QueryMyTicketsArgs = { input: PaginatedInputMyTicketsSearchValues; }; @@ -536,16 +544,20 @@ export type QuerySearchConsolidatedPaymentLogsArgs = { input: SearchPaymentLogsInput; }; +export type QuerySearchEventsArgs = { + input: PaginatedInputEventsSearchInput; +}; + export type QuerySearchPaymentLogsArgs = { input: SearchPaymentLogsInput; }; export type QueryStatusArgs = { - name: InputMaybe; + name?: InputMaybe; }; export type QueryTagsArgs = { - input: InputMaybe; + input?: InputMaybe; }; export type QueryUserSearchArgs = { @@ -573,8 +585,8 @@ export type Salary = { company: Company; countryCode: Scalars["String"]["output"]; currencyCode: Scalars["String"]["output"]; - gender: Maybe; - genderOtherText: Maybe; + gender?: Maybe; + genderOtherText?: Maybe; id: Scalars["String"]["output"]; typeOfEmployment: TypeOfEmployment; workMetodology: WorkMetodology; @@ -594,14 +606,14 @@ export type SanityAssetRef = { }; export type SearchCompaniesInput = { - companyName: InputMaybe; - description: InputMaybe; - domain: InputMaybe; - website: InputMaybe; + companyName?: InputMaybe; + description?: InputMaybe; + domain?: InputMaybe; + website?: InputMaybe; }; export type SearchPaymentLogsInput = { - endDate: InputMaybe; + endDate?: InputMaybe; startDate: Scalars["DateTime"]["input"]; }; @@ -617,22 +629,22 @@ export enum ServiceErrors { /** Representation of a tag. Tags can be associated to many things. An event, a community, etc. */ export type Tag = { - description: Maybe; + description?: Maybe; id: Scalars["String"]["output"]; - name: Maybe; + name?: Maybe; slug: Scalars["String"]["output"]; }; export type TagSearchInput = { - description: InputMaybe; - id: InputMaybe; - name: InputMaybe; + description?: InputMaybe; + id?: InputMaybe; + name?: InputMaybe; }; /** Representation of a ticket */ export type Ticket = { - description: Maybe; - endDateTime: Maybe; + description?: Maybe; + endDateTime?: Maybe; event: Event; id: Scalars["ID"]["output"]; /** Whether or not the ticket is free */ @@ -640,9 +652,9 @@ export type Ticket = { /** Whether or not the ticket has an unlimited quantity. This is reserved for things loike online events. */ isUnlimited: Scalars["Boolean"]["output"]; name: Scalars["String"]["output"]; - prices: Maybe>; + prices?: Maybe>; /** The number of tickets available for this ticket type */ - quantity: Maybe; + quantity?: Maybe; requiresApproval: Scalars["Boolean"]["output"]; startDateTime: Scalars["DateTime"]["output"]; status: TicketTemplateStatus; @@ -659,43 +671,43 @@ export enum TicketApprovalStatus { export type TicketClaimInput = { /** If this field is passed, a purchase order payment link will be generated right away */ - generatePaymentLink: InputMaybe; + generatePaymentLink?: InputMaybe; /** A unique key to prevent duplicate requests, it's optional to send, but it's recommended to send it to prevent duplicate requests. If not sent, it will be created by the server. */ - idempotencyUUIDKey: InputMaybe; + idempotencyUUIDKey?: InputMaybe; purchaseOrder: Array; }; export type TicketCreateInput = { - description: InputMaybe; - endDateTime: InputMaybe; + description?: InputMaybe; + endDateTime?: InputMaybe; eventId: Scalars["String"]["input"]; /** If the ticket is free, the price submitted will be ignored. */ isFree: Scalars["Boolean"]["input"]; name: Scalars["String"]["input"]; - prices: InputMaybe>; - quantity: InputMaybe; - requiresApproval: InputMaybe; + prices?: InputMaybe>; + quantity?: InputMaybe; + requiresApproval?: InputMaybe; startDateTime: Scalars["DateTime"]["input"]; - status: InputMaybe; + status?: InputMaybe; /** If provided, quantity must not be passed. This is for things like online events where there is no limit to the amount of tickets that can be sold. */ unlimitedTickets: Scalars["Boolean"]["input"]; - visibility: InputMaybe; + visibility?: InputMaybe; }; export type TicketEditInput = { - description: InputMaybe; - endDateTime: InputMaybe; - eventId: InputMaybe; - name: InputMaybe; - prices: InputMaybe; - quantity: InputMaybe; - requiresApproval: InputMaybe; - startDateTime: InputMaybe; - status: InputMaybe; + description?: InputMaybe; + endDateTime?: InputMaybe; + eventId?: InputMaybe; + name?: InputMaybe; + prices?: InputMaybe; + quantity?: InputMaybe; + requiresApproval?: InputMaybe; + startDateTime?: InputMaybe; + status?: InputMaybe; ticketId: Scalars["String"]["input"]; /** If provided, quantity must not be passed. This is for things like online events where there is no limit to the amount of tickets that can be sold. */ - unlimitedTickets: InputMaybe; - visibility: InputMaybe; + unlimitedTickets?: InputMaybe; + visibility?: InputMaybe; }; export enum TicketPaymentStatus { @@ -728,43 +740,43 @@ export enum TypeOfEmployment { export type UpdateCommunityInput = { communityId: Scalars["String"]["input"]; - description: InputMaybe; - name: InputMaybe; - slug: InputMaybe; - status: InputMaybe; + description?: InputMaybe; + name?: InputMaybe; + slug?: InputMaybe; + status?: InputMaybe; }; export type UpdateCompanyInput = { companyId: Scalars["String"]["input"]; - description: InputMaybe; - domain: InputMaybe; - logo: InputMaybe; - name: InputMaybe; - website: InputMaybe; + description?: InputMaybe; + domain?: InputMaybe; + logo?: InputMaybe; + name?: InputMaybe; + website?: InputMaybe; }; export type UpdateSalaryInput = { - amount: InputMaybe; + amount?: InputMaybe; confirmationToken: Scalars["String"]["input"]; - countryCode: InputMaybe; - currencyCode: InputMaybe; - gender: InputMaybe; - genderOtherText: InputMaybe; + countryCode?: InputMaybe; + currencyCode?: InputMaybe; + gender?: InputMaybe; + genderOtherText?: InputMaybe; salaryId: Scalars["String"]["input"]; - typeOfEmployment: InputMaybe; - workMetodology: InputMaybe; - workSeniorityAndRoleId: InputMaybe; - yearsOfExperience: InputMaybe; + typeOfEmployment?: InputMaybe; + workMetodology?: InputMaybe; + workSeniorityAndRoleId?: InputMaybe; + yearsOfExperience?: InputMaybe; }; /** Representation of a user */ export type User = { - bio: Maybe; + bio?: Maybe; communities: Array; id: Scalars["String"]["output"]; - isSuperAdmin: Maybe; - lastName: Maybe; - name: Maybe; + isSuperAdmin?: Maybe; + lastName?: Maybe; + name?: Maybe; username: Scalars["String"]["output"]; }; @@ -773,7 +785,7 @@ export type UserTicket = { approvalStatus: TicketApprovalStatus; id: Scalars["ID"]["output"]; paymentStatus: TicketPaymentStatus; - purchaseOrder: Maybe; + purchaseOrder?: Maybe; redemptionStatus: TicketRedemptionStatus; ticketTemplate: Ticket; }; @@ -785,8 +797,8 @@ export enum ValidPaymentMethods { /** Representation of a work email associated to the current user */ export type ValidatedWorkEmail = { - company: Maybe; - confirmationDate: Maybe; + company?: Maybe; + confirmationDate?: Maybe; id: Scalars["String"]["output"]; isValidated: Scalars["Boolean"]["output"]; status: EmailStatus; @@ -807,7 +819,7 @@ export enum WorkMetodology { /** Representation of a work role */ export type WorkRole = { - description: Maybe; + description?: Maybe; id: Scalars["String"]["output"]; name: Scalars["String"]["output"]; seniorities: Array; @@ -819,7 +831,7 @@ export type WorkRoleSenioritiesInput = { /** Representation of a work seniority */ export type WorkSeniority = { - description: Maybe; + description?: Maybe; id: Scalars["String"]["output"]; name: Scalars["String"]["output"]; }; @@ -831,43 +843,57 @@ export type UpdateUserRoleInCommunityInput = { }; export type UserEditInput = { - bio: InputMaybe; + bio?: InputMaybe; id: Scalars["String"]["input"]; - lastName: InputMaybe; - name: InputMaybe; - username: InputMaybe; + lastName?: InputMaybe; + name?: InputMaybe; + username?: InputMaybe; }; export type UserSearchInput = { - tags: InputMaybe>; + tags?: InputMaybe>; }; -export type FetchExampleEventsQueryVariables = Exact<{ [key: string]: never }>; +export type FetchExampleEventsQueryVariables = Exact<{ + input: PaginatedInputEventsSearchInput; +}>; export type FetchExampleEventsQuery = { - events: Array<{ - id: string; - description: string | null; - community: { id: string; name: string | null } | null; - tags: Array<{ + searchEvents: { + data: Array<{ id: string; - name: string | null; - description: string | null; + description?: string | null; + community?: { id: string; name?: string | null } | null; + tags: Array<{ + id: string; + name?: string | null; + description?: string | null; + }>; }>; - }>; + }; }; export type MyTicketsQueryVariables = Exact<{ - input: PaginatedInputMyTicketsSearchValues; + input: PaginatedInputEventsSearchInput; + userTicketSearchInput?: InputMaybe; }>; export type MyTicketsQuery = { - myTickets: { + searchEvents: { data: Array<{ - approvalStatus: TicketApprovalStatus; id: string; - paymentStatus: TicketPaymentStatus; - redemptionStatus: TicketRedemptionStatus; + name: string; + description?: string | null; + startDateTime: string; + status: EventStatus; + community?: { id: string; name?: string | null } | null; + usersTickets: Array<{ + id: string; + approvalStatus: TicketApprovalStatus; + paymentStatus: TicketPaymentStatus; + redemptionStatus: TicketRedemptionStatus; + ticketTemplate: { description?: string | null; id: string }; + }>; }>; pagination: { currentPage: number; @@ -887,10 +913,10 @@ export type CreatePurchaseOrderMutation = { | { __typename: "PurchaseOrder"; id: string; - finalPrice: number | null; - paymentLink: string | null; - status: PurchaseOrderStatusEnum | null; - currency: { id: string } | null; + finalPrice?: number | null; + paymentLink?: string | null; + status?: PurchaseOrderStatusEnum | null; + currency?: { id: string } | null; tickets: Array<{ id: string; approvalStatus: TicketApprovalStatus; @@ -908,13 +934,13 @@ export type CreatePurchaseOrderMutation = { export type EventTicketFragmentFragment = { id: string; name: string; - description: string | null; - quantity: number | null; + description?: string | null; + quantity?: number | null; isFree: boolean; startDateTime: string; status: TicketTemplateStatus; isUnlimited: boolean; - prices: Array<{ + prices?: Array<{ id: string; amount: number; currency: { currency: string; id: string }; @@ -926,17 +952,17 @@ export type GetEventAndTicketsQueryVariables = Exact<{ }>; export type GetEventAndTicketsQuery = { - event: { + event?: { id: string; name: string; - address: string | null; - description: string | null; - maxAttendees: number | null; + address?: string | null; + description?: string | null; + maxAttendees?: number | null; startDateTime: string; - endDateTime: string | null; + endDateTime?: string | null; status: EventStatus; - community: { name: string | null } | null; - users: Array<{ id: string; name: string | null }>; + community?: { name?: string | null } | null; + users: Array<{ id: string; name?: string | null }>; tickets: Array<{ " $fragmentRefs"?: { EventTicketFragmentFragment: EventTicketFragmentFragment; @@ -1003,40 +1029,90 @@ export const FetchExampleEventsDocument = { kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchExampleEvents" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "input" }, + }, + type: { + kind: "NonNullType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "PaginatedInputEventsSearchInput" }, + }, + }, + }, + ], selectionSet: { kind: "SelectionSet", selections: [ { kind: "Field", - name: { kind: "Name", value: "events" }, + name: { kind: "Name", value: "searchEvents" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "input" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "input" }, + }, + }, + ], selectionSet: { kind: "SelectionSet", selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "description" } }, { kind: "Field", - name: { kind: "Name", value: "community" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "name" } }, - ], - }, - }, - { - kind: "Field", - name: { kind: "Name", value: "tags" }, + name: { kind: "Name", value: "data" }, selectionSet: { kind: "SelectionSet", selections: [ { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "name" } }, { kind: "Field", name: { kind: "Name", value: "description" }, }, + { + kind: "Field", + name: { kind: "Name", value: "community" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + ], + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "tags" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "description" }, + }, + ], + }, + }, ], }, }, @@ -1069,20 +1145,28 @@ export const MyTicketsDocument = { kind: "NonNullType", type: { kind: "NamedType", - name: { - kind: "Name", - value: "PaginatedInputMyTicketsSearchValues", - }, + name: { kind: "Name", value: "PaginatedInputEventsSearchInput" }, }, }, }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "userTicketSearchInput" }, + }, + type: { + kind: "NamedType", + name: { kind: "Name", value: "EventsTicketsSearchInput" }, + }, + }, ], selectionSet: { kind: "SelectionSet", selections: [ { kind: "Field", - name: { kind: "Name", value: "myTickets" }, + name: { kind: "Name", value: "searchEvents" }, arguments: [ { kind: "Argument", @@ -1102,18 +1186,94 @@ export const MyTicketsDocument = { selectionSet: { kind: "SelectionSet", selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { kind: "Field", name: { kind: "Name", value: "name" } }, { kind: "Field", - name: { kind: "Name", value: "approvalStatus" }, + name: { kind: "Name", value: "description" }, }, - { kind: "Field", name: { kind: "Name", value: "id" } }, { kind: "Field", - name: { kind: "Name", value: "paymentStatus" }, + name: { kind: "Name", value: "startDateTime" }, }, { kind: "Field", - name: { kind: "Name", value: "redemptionStatus" }, + name: { kind: "Name", value: "community" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + ], + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "status" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "usersTickets" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "input" }, + value: { + kind: "Variable", + name: { + kind: "Name", + value: "userTicketSearchInput", + }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "approvalStatus" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "paymentStatus" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "redemptionStatus" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "ticketTemplate" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + ], + }, + }, + ], + }, }, ], }, diff --git a/app/api/gql/schema.gql b/app/api/gql/schema.gql index 1fa0c52..ed2d68a 100644 --- a/app/api/gql/schema.gql +++ b/app/api/gql/schema.gql @@ -208,6 +208,7 @@ input EventsSearchInput { startDateTimeFrom: DateTime startDateTimeTo: DateTime status: EventStatus + userHasTickets: Boolean visibility: EventVisibility } @@ -350,6 +351,19 @@ input MyTicketsSearchValues { redemptionStatus: TicketRedemptionStatus } +""" +Type used for querying the paginated leaves and it's paginated meta data +""" +type PaginatedEvent { + data: [Event!]! + pagination: Pagination! +} + +input PaginatedInputEventsSearchInput { + pagination: PaginationSearchInputParams! = { page: 0, pageSize: 20 } + search: EventsSearchInput +} + input PaginatedInputMyTicketsSearchValues { pagination: PaginationSearchInputParams! = { page: 0, pageSize: 20 } search: MyTicketsSearchValues @@ -470,11 +484,6 @@ type Query { """ eventImages(input: EventImageSearch!): [SanityAssetRef!]! - """ - Get a list of events. Filter by name, id, status or date - """ - events(input: EventsSearchInput): [Event!]! - """ Get the current user """ @@ -497,6 +506,11 @@ type Query { input: SearchPaymentLogsInput! ): [ConsolidatedPaymentLogEntry!]! + """ + Get a list of events. Filter by name, id, status or date + """ + searchEvents(input: PaginatedInputEventsSearchInput!): PaginatedEvent! + """ Search on the payment logs by date, and returns a list of payment logs """ diff --git a/app/components/LandingPageEvents/graphql/FetchExampleEvents.generated.tsx b/app/components/LandingPageEvents/graphql/FetchExampleEvents.generated.tsx index a8113cb..af707df 100644 --- a/app/components/LandingPageEvents/graphql/FetchExampleEvents.generated.tsx +++ b/app/components/LandingPageEvents/graphql/FetchExampleEvents.generated.tsx @@ -9,42 +9,47 @@ import { gql } from "graphql-tag"; import * as Apollo from "@apollo/client"; const defaultOptions = {} as const; export type FetchExampleEventsQueryVariables = Types.Exact<{ - [key: string]: never; + input: Types.PaginatedInputEventsSearchInput; }>; export type FetchExampleEventsQuery = { __typename?: "Query"; - events: Array<{ - __typename?: "Event"; - id: string; - description?: string | null; - community?: { - __typename?: "Community"; + searchEvents: { + __typename?: "PaginatedEvent"; + data: Array<{ + __typename?: "Event"; id: string; - name?: string | null; - } | null; - tags: Array<{ - __typename?: "Tag"; - id: string; - name?: string | null; description?: string | null; + community?: { + __typename?: "Community"; + id: string; + name?: string | null; + } | null; + tags: Array<{ + __typename?: "Tag"; + id: string; + name?: string | null; + description?: string | null; + }>; }>; - }>; + }; }; export const FetchExampleEventsDocument = gql` - query FetchExampleEvents { - events { - id - description - community { - id - name - } - tags { + query FetchExampleEvents($input: PaginatedInputEventsSearchInput!) { + searchEvents(input: $input) { + data { id - name description + community { + id + name + } + tags { + id + name + description + } } } } @@ -62,14 +67,19 @@ export const FetchExampleEventsDocument = gql` * @example * const { data, loading, error } = useFetchExampleEventsQuery({ * variables: { + * input: // value for 'input' * }, * }); */ export function useFetchExampleEventsQuery( - baseOptions?: Apollo.QueryHookOptions< + baseOptions: Apollo.QueryHookOptions< FetchExampleEventsQuery, FetchExampleEventsQueryVariables - >, + > & + ( + | { variables: FetchExampleEventsQueryVariables; skip?: boolean } + | { skip: boolean } + ), ) { const options = { ...defaultOptions, ...baseOptions }; return Apollo.useQuery< diff --git a/app/components/LandingPageEvents/graphql/FetchExampleEvents.gql b/app/components/LandingPageEvents/graphql/FetchExampleEvents.gql index c2be70e..7c486ef 100644 --- a/app/components/LandingPageEvents/graphql/FetchExampleEvents.gql +++ b/app/components/LandingPageEvents/graphql/FetchExampleEvents.gql @@ -1,15 +1,17 @@ -query FetchExampleEvents { - events { - id - description - community { +query FetchExampleEvents($input: PaginatedInputEventsSearchInput!) { + searchEvents(input: $input) { + data { id - name - } - tags { - id - name description + community { + id + name + } + tags { + id + name + description + } } } } diff --git a/app/components/LandingPageEvents/index.tsx b/app/components/LandingPageEvents/index.tsx deleted file mode 100644 index 7b7eaf9..0000000 --- a/app/components/LandingPageEvents/index.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { useFetchExampleEventsQuery } from "./graphql/FetchExampleEvents.generated"; - -export const LandingPageEvents = () => { - const events = useFetchExampleEventsQuery(); - - return ( - <> - {events.data?.events.map((event) =>
{event.id}
)} - - ); -}; diff --git a/app/components/MyTickets/MyTicketsList.tsx b/app/components/MyTickets/MyTicketsList.tsx new file mode 100644 index 0000000..5c10e60 --- /dev/null +++ b/app/components/MyTickets/MyTicketsList.tsx @@ -0,0 +1,56 @@ +import { formatDistanceToNow, subDays, format } from "date-fns"; + +import { useMyTicketsSuspenseQuery } from "~/components/MyTickets/graphql/myTickets.generated"; +import { Card, CardTitle } from "~/components/ui/card"; + +export const MyTicketsList = () => { + const { data } = useMyTicketsSuspenseQuery({ + variables: { + input: { + search: { + userHasTickets: true, + id: null, + name: null, + startDateTimeFrom: null, + startDateTimeTo: null, + status: null, + visibility: null, + }, + pagination: { + page: 0, + pageSize: 10, + }, + }, + }, + }); + + return ( +
+ {data.searchEvents.data.map((event) => { + const parsedDate = new Date(event.startDateTime as string); + const isOverAWeekFromNow = parsedDate > subDays(new Date(), 7); + const relativeDate = formatDistanceToNow(parsedDate, { + addSuffix: true, + }); + const formattedDate = format(parsedDate, "cccc - d 'de' MMMM, yyyy"); + const date = isOverAWeekFromNow ? formattedDate : relativeDate; + + const formattedTime = format(parsedDate, "hh:mm aaa"); + + return ( + +
+ {date} + {formattedTime} +
+ {event.name} +
{event.usersTickets.length} tickets
+
+ ); + })} +
+ ); +}; diff --git a/app/components/MyTickets/MyTicketsLoadingSkeleton.tsx b/app/components/MyTickets/MyTicketsLoadingSkeleton.tsx new file mode 100644 index 0000000..1b2d0dc --- /dev/null +++ b/app/components/MyTickets/MyTicketsLoadingSkeleton.tsx @@ -0,0 +1,3 @@ +export const MyTicketsLoadingSkeleton = () => { + return
...loading
; +}; diff --git a/app/components/MyTickets/graphql/myTickets.generated.tsx b/app/components/MyTickets/graphql/myTickets.generated.tsx index 8db11bf..30af105 100644 --- a/app/components/MyTickets/graphql/myTickets.generated.tsx +++ b/app/components/MyTickets/graphql/myTickets.generated.tsx @@ -9,19 +9,38 @@ import { gql } from "graphql-tag"; import * as Apollo from "@apollo/client"; const defaultOptions = {} as const; export type MyTicketsQueryVariables = Types.Exact<{ - input: Types.PaginatedInputMyTicketsSearchValues; + input: Types.PaginatedInputEventsSearchInput; + userTicketSearchInput?: Types.InputMaybe; }>; export type MyTicketsQuery = { __typename?: "Query"; - myTickets: { - __typename?: "PaginatedUserTicket"; + searchEvents: { + __typename?: "PaginatedEvent"; data: Array<{ - __typename?: "UserTicket"; - approvalStatus: Types.TicketApprovalStatus; + __typename?: "Event"; id: string; - paymentStatus: Types.TicketPaymentStatus; - redemptionStatus: Types.TicketRedemptionStatus; + name: string; + description?: string | null; + startDateTime: any; + status: Types.EventStatus; + community?: { + __typename?: "Community"; + id: string; + name?: string | null; + } | null; + usersTickets: Array<{ + __typename?: "UserTicket"; + id: string; + approvalStatus: Types.TicketApprovalStatus; + paymentStatus: Types.TicketPaymentStatus; + redemptionStatus: Types.TicketRedemptionStatus; + ticketTemplate: { + __typename?: "Ticket"; + description?: string | null; + id: string; + }; + }>; }>; pagination: { __typename?: "Pagination"; @@ -34,13 +53,31 @@ export type MyTicketsQuery = { }; export const MyTicketsDocument = gql` - query myTickets($input: PaginatedInputMyTicketsSearchValues!) { - myTickets(input: $input) { + query myTickets( + $input: PaginatedInputEventsSearchInput! + $userTicketSearchInput: EventsTicketsSearchInput + ) { + searchEvents(input: $input) { data { - approvalStatus id - paymentStatus - redemptionStatus + name + description + startDateTime + community { + id + name + } + status + usersTickets(input: $userTicketSearchInput) { + id + approvalStatus + paymentStatus + redemptionStatus + ticketTemplate { + description + id + } + } } pagination { currentPage @@ -65,6 +102,7 @@ export const MyTicketsDocument = gql` * const { data, loading, error } = useMyTicketsQuery({ * variables: { * input: // value for 'input' + * userTicketSearchInput: // value for 'userTicketSearchInput' * }, * }); */ diff --git a/app/components/MyTickets/graphql/myTickets.gql b/app/components/MyTickets/graphql/myTickets.gql index f7b178c..e9f8b2e 100644 --- a/app/components/MyTickets/graphql/myTickets.gql +++ b/app/components/MyTickets/graphql/myTickets.gql @@ -1,10 +1,28 @@ -query myTickets($input: PaginatedInputMyTicketsSearchValues!) { - myTickets(input: $input) { +query myTickets( + $input: PaginatedInputEventsSearchInput! + $userTicketSearchInput: EventsTicketsSearchInput +) { + searchEvents(input: $input) { data { - approvalStatus id - paymentStatus - redemptionStatus + name + description + startDateTime + community { + id + name + } + status + usersTickets(input: $userTicketSearchInput) { + id + approvalStatus + paymentStatus + redemptionStatus + ticketTemplate { + description + id + } + } } pagination { currentPage diff --git a/app/root.tsx b/app/root.tsx index b6ede27..4dc20e5 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -5,6 +5,8 @@ import { Scripts, ScrollRestoration, } from "@remix-run/react"; +import { setDefaultOptions } from "date-fns"; +import { es } from "date-fns/locale"; import "./tailwind.css"; import { ApolloWrapper } from "~/api/ApolloWrapper"; @@ -12,6 +14,8 @@ import { Navbar } from "~/components/Navbar"; import { Toaster } from "~/components/ui/sonner"; import { AuthProvider } from "~/utils/supabase/AuthProvider"; +setDefaultOptions({ locale: es }); + export function Layout({ children }: { children: React.ReactNode }) { return ( diff --git a/app/routes/_authenticated/tickets/index.tsx b/app/routes/_authenticated/tickets/index.tsx index 5a1dd5a..7f34812 100644 --- a/app/routes/_authenticated/tickets/index.tsx +++ b/app/routes/_authenticated/tickets/index.tsx @@ -1,9 +1,28 @@ +import { cx } from "class-variance-authority"; +import { Suspense } from "react"; + +import { MyTicketsList } from "~/components/MyTickets/MyTicketsList"; +import { MyTicketsLoadingSkeleton } from "~/components/MyTickets/MyTicketsLoadingSkeleton"; import { sharedLayoutStyle } from "~/components/sharedLayouts"; +import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs"; export default function Layout() { return ( -
-

Mis Tickets

+
+
+

Mis Tickets

+
+ + + Pasados + Futuros + + +
+
+ }> + +
); } diff --git a/codegen.ts b/codegen.ts index 08788b0..90fd97d 100644 --- a/codegen.ts +++ b/codegen.ts @@ -15,6 +15,9 @@ const noTypeCheckingPlugin = { }; const config = { ...defaultConfig, + hooks: { + afterOneFileWrite: ["prettier --write"], + }, ignoreNoDocuments: true, generates: { "app/api/gql/": { @@ -23,7 +26,7 @@ const config = { config: { useTypeImports: true, skipTypename: true, - avoidOptionals: true, + avoidOptionals: false, nonOptionalTypename: false, // Lamentablemente, code-gen establece "any" como predeterminado, cuando no tiene un // tipo para un "scalar". Esta opciĆ³n nos obliga a definir un tipo cada vez que diff --git a/package-lock.json b/package-lock.json index c700e37..8add5e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "@supabase/supabase-js": "^2.44.2", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "date-fns": "^3.6.0", "framer-motion": "^11.2.12", "graphiql": "^3.0.6", "graphql": "^16.8.1", @@ -8210,6 +8211,15 @@ "integrity": "sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g==", "dev": true }, + "node_modules/date-fns": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/debounce": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", diff --git a/package.json b/package.json index 0208ed7..b559510 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "@supabase/supabase-js": "^2.44.2", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "date-fns": "^3.6.0", "framer-motion": "^11.2.12", "graphiql": "^3.0.6", "graphql": "^16.8.1",