-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: query submission_services_summary and log result
- Setup up the types and function to query the submission_services_summary for the pertinent data - For now simply log the data out in the console
- Loading branch information
1 parent
3b0bdd7
commit 74c5ee3
Showing
2 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 27 additions & 1 deletion
28
editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
....uk/src/pages/FlowEditor/components/Settings/Submissions/submissionDataTypesAndQueries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import gql from "graphql-tag"; | ||
import { client } from "lib/graphql"; | ||
|
||
type PaymentRequest = { | ||
id: string; | ||
created_at: Date; | ||
paidAt: Date; | ||
govPaymentId: string; | ||
}; | ||
|
||
type PaymentStatus = { | ||
govPaymentId: string; | ||
created_at: Date; | ||
status: string; | ||
}; | ||
|
||
type BopsApplication = { | ||
id: string; | ||
submittedAt: Date; | ||
destinationUrl: string; | ||
}; | ||
|
||
type EmailApplication = { | ||
id: string; | ||
recipient: string; | ||
submittedAt: Date; | ||
}; | ||
|
||
type UniformApplication = { | ||
id: string; | ||
submittedAt: Date; | ||
}; | ||
|
||
export type SubmissionData = { | ||
sessionId: string; | ||
submittedAt: Date | string; | ||
paymentRequests: PaymentRequest[] | null; | ||
paymentStatus: PaymentStatus[] | null; | ||
bopsApplications: BopsApplication[] | null; | ||
uniformApplications: UniformApplication[] | null; | ||
emailApplications: EmailApplication[] | null; | ||
}; | ||
|
||
export async function fetchSubmittedApplications( | ||
flowSlug: string, | ||
teamSlug: string, | ||
) { | ||
const { data } = await client.query({ | ||
query: gql` | ||
query SubmittedApplications($service_slug: String!, $team_slug: String!) { | ||
submission_services_summary( | ||
where: { | ||
service_slug: { _eq: $service_slug } | ||
team_slug: { _eq: $team_slug } | ||
submitted_at: { _is_null: false } | ||
} | ||
order_by: { submitted_at: desc } | ||
) { | ||
sessionId: session_id | ||
submittedAt: submitted_at | ||
paymentRequests: payment_requests | ||
paymentStatus: payment_status | ||
bopsApplications: bops_applications | ||
uniformApplications: uniform_applications | ||
emailApplications: email_applications | ||
} | ||
} | ||
`, | ||
variables: { | ||
service_slug: flowSlug, | ||
team_slug: teamSlug, | ||
}, | ||
}); | ||
return data; | ||
} |