Skip to content

Commit

Permalink
fix: restore loo page + load compressed marker data
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Redington committed Nov 22, 2021
1 parent 202524c commit 991a6a3
Show file tree
Hide file tree
Showing 13 changed files with 352 additions and 224 deletions.
38 changes: 38 additions & 0 deletions src/api-client/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export type Query = {
proportions: Proportions;
/** Retrieve a report by ID */
report?: Maybe<Report>;
ukLooMarkers: Array<Scalars['String']>;
};


Expand Down Expand Up @@ -402,6 +403,11 @@ export type SubmitVerificationReportMutationMutationVariables = Exact<{

export type SubmitVerificationReportMutationMutation = { __typename?: 'Mutation', submitVerificationReport?: { __typename?: 'ReportMutationResponse', loo?: { __typename?: 'Loo', id?: string | null | undefined, verifiedAt?: any | null | undefined } | null | undefined } | null | undefined };

export type UkLooMarkersQueryVariables = Exact<{ [key: string]: never; }>;


export type UkLooMarkersQuery = { __typename?: 'Query', ukLooMarkers: Array<string> };

export type UpdateLooMutationVariables = Exact<{
id?: Maybe<Scalars['ID']>;
location: PointInput;
Expand Down Expand Up @@ -666,6 +672,38 @@ export function useSubmitVerificationReportMutationMutation(baseOptions?: Apollo
export type SubmitVerificationReportMutationMutationHookResult = ReturnType<typeof useSubmitVerificationReportMutationMutation>;
export type SubmitVerificationReportMutationMutationResult = Apollo.MutationResult<SubmitVerificationReportMutationMutation>;
export type SubmitVerificationReportMutationMutationOptions = Apollo.BaseMutationOptions<SubmitVerificationReportMutationMutation, SubmitVerificationReportMutationMutationVariables>;
export const UkLooMarkersDocument = gql`
query ukLooMarkers {
ukLooMarkers
}
`;

/**
* __useUkLooMarkersQuery__
*
* To run a query within a React component, call `useUkLooMarkersQuery` and pass it any options that fit your needs.
* When your component renders, `useUkLooMarkersQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useUkLooMarkersQuery({
* variables: {
* },
* });
*/
export function useUkLooMarkersQuery(baseOptions?: Apollo.QueryHookOptions<UkLooMarkersQuery, UkLooMarkersQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<UkLooMarkersQuery, UkLooMarkersQueryVariables>(UkLooMarkersDocument, options);
}
export function useUkLooMarkersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<UkLooMarkersQuery, UkLooMarkersQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<UkLooMarkersQuery, UkLooMarkersQueryVariables>(UkLooMarkersDocument, options);
}
export type UkLooMarkersQueryHookResult = ReturnType<typeof useUkLooMarkersQuery>;
export type UkLooMarkersLazyQueryHookResult = ReturnType<typeof useUkLooMarkersLazyQuery>;
export type UkLooMarkersQueryResult = Apollo.QueryResult<UkLooMarkersQuery, UkLooMarkersQueryVariables>;
export const UpdateLooDocument = gql`
mutation updateLoo($id: ID, $location: PointInput!, $name: String, $openingTimes: OpeningTimes, $accessible: Boolean, $allGender: Boolean, $men: Boolean, $women: Boolean, $children: Boolean, $urinalOnly: Boolean, $babyChange: Boolean, $radar: Boolean, $attended: Boolean, $automatic: Boolean, $noPayment: Boolean, $paymentDetails: String, $notes: String, $campaignUOL: Boolean, $active: Boolean) {
submitReport(
Expand Down
1 change: 1 addition & 0 deletions src/api-client/operations/minimumViableLooResponse.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ query minimumViableLooResponse($limit: Int!) {
radar
campaignUOL
}
}
}
3 changes: 3 additions & 0 deletions src/api-client/operations/ukLooMarkers.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query ukLooMarkers {
ukLooMarkers
}
35 changes: 35 additions & 0 deletions src/api-client/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,38 @@ export const ssrMinimumViableLooResponse = {
}


export async function getServerPageUkLooMarkers
(options: Omit<Apollo.QueryOptions<Types.UkLooMarkersQueryVariables>, 'query'>, ctx?: any ){
const apolloClient = getApolloClient(ctx);

const data = await apolloClient.query<Types.UkLooMarkersQuery>({ ...options, query: Operations.UkLooMarkersDocument });

const apolloState = apolloClient.cache.extract();

return {
props: {
apolloState: apolloState,
data: data?.data,
error: data?.error ?? data?.errors ?? null,
},
};
}
export const useUkLooMarkers = (
optionsFunc?: (router: NextRouter)=> QueryHookOptions<Types.UkLooMarkersQuery, Types.UkLooMarkersQueryVariables>) => {
const router = useRouter();
const options = optionsFunc ? optionsFunc(router) : {};
return useQuery(Operations.UkLooMarkersDocument, options);
};
export type PageUkLooMarkersComp = React.FC<{data?: Types.UkLooMarkersQuery, error?: Apollo.ApolloError}>;
export const withPageUkLooMarkers = (optionsFunc?: (router: NextRouter)=> QueryHookOptions<Types.UkLooMarkersQuery, Types.UkLooMarkersQueryVariables>) => (WrappedComponent:PageUkLooMarkersComp) : NextPage => (props) => {
const router = useRouter()
const options = optionsFunc ? optionsFunc(router) : {};
const {data, error } = useQuery(Operations.UkLooMarkersDocument, options)
return <WrappedComponent {...props} data={data} error={error} /> ;

};
export const ssrUkLooMarkers = {
getServerPage: getServerPageUkLooMarkers,
withPage: withPageUkLooMarkers,
usePage: useUkLooMarkers,
}

0 comments on commit 991a6a3

Please sign in to comment.