-
Notifications
You must be signed in to change notification settings - Fork 90
feat(2915): admin front-end for tenant support #3254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
99d6982
344e21a
657780f
3ce9128
15cb387
4aafebb
9072e02
e4a6e6c
45dcb5b
59d4638
993e4c4
ac04fa6
9cd9899
8bc7d7f
b7ea593
ef3601f
4de527d
3258767
cc03979
8f78849
ae76925
719bb18
e718b64
f90efd0
267ef6c
f15bad3
970fcbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import { gql } from '@apollo/client' | ||
import type { | ||
CreateTenantInput, | ||
CreateTenantMutation, | ||
CreateTenantMutationVariables, | ||
QueryTenantsArgs, | ||
ListTenantsQuery, | ||
ListTenantsQueryVariables | ||
} from '~/generated/graphql' | ||
import { getApolloClient } from '../apollo.server' | ||
|
||
export const listTenants = async (request: Request, args: QueryTenantsArgs) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.query< | ||
ListTenantsQuery, | ||
ListTenantsQueryVariables | ||
>({ | ||
query: gql` | ||
query ListTenantsQuery( | ||
$after: String | ||
$before: String | ||
$first: Int | ||
$last: Int | ||
) { | ||
tenants(after: $after, before: $before, first: $first, last: $last) { | ||
edges { | ||
node { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
createdAt | ||
deletedAt | ||
isOperator | ||
} | ||
} | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasNextPage | ||
hasPreviousPage | ||
} | ||
} | ||
} | ||
`, | ||
variables: args | ||
}) | ||
return response.data.tenants | ||
} | ||
|
||
export const createTenant = async ( | ||
request: Request, | ||
args: CreateTenantInput | ||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
CreateTenantMutation, | ||
CreateTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation CreateTenantMutation($input: CreateTenantInput!) { | ||
createTenant(input: $input) { | ||
tenant { | ||
id | ||
publicName | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
} | ||
} | ||
} | ||
`, | ||
variables: { | ||
input: args | ||
} | ||
}) | ||
|
||
return response.data?.createTenant | ||
} | ||
|
||
export const updateTenant = async ( | ||
request: Request, | ||
args: UpdateTenantInput | ||
koekiebox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
UpdateTenantMutation, | ||
UpdateTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation UpdateTenantMutation($input: UpdateTenantInput!) { | ||
updateTenant(input: $input) { | ||
tenant { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
} | ||
} | ||
} | ||
`, | ||
variables: { | ||
input: args | ||
} | ||
}) | ||
|
||
return response.data?.updateTenant | ||
} | ||
|
||
export const deleteTenant = async (request: Request, args: string) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
DeleteTenantMutation, | ||
DeleteTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation DeleteTenantMutation($id: String!) { | ||
deleteTenant(id: $id) { | ||
success | ||
} | ||
} | ||
`, | ||
variables: { | ||
id: args | ||
} | ||
}) | ||
|
||
return response.data?.deleteTenant | ||
} | ||
|
||
export const getTenantInfo = async ( | ||
request: Request, | ||
args: QueryTenantArgs | ||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.query< | ||
GetTenantQuery, | ||
GetTenantQueryVariables | ||
>({ | ||
query: gql` | ||
query GetTenantQuery($id: String!) { | ||
tenant(id: $id) { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
createdAt | ||
deletedAt | ||
isOperator | ||
} | ||
} | ||
`, | ||
variables: args | ||
}) | ||
return response.data.tenant | ||
} |
Uh oh!
There was an error while loading. Please reload this page.