Skip to content

Commit

Permalink
feat: and onSessionActivityExpired subscription (#195)
Browse files Browse the repository at this point in the history
V1C-364
  • Loading branch information
danijel authored Jan 8, 2024
1 parent 572717f commit 31b12c9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# import 'Activity'
subscription OnSessionActivityExpired($only_stakeholder_activities: Boolean!) {
sessionActivityExpired(
only_stakeholder_activities: $only_stakeholder_activities
) {
...Activity
}
}
1 change: 1 addition & 0 deletions src/hooks/useSessionActivities/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GetHostedSessionActivitiesQuery } from '../../types/generated/types-orc
export {
useOnSessionActivityCompletedSubscription,
useOnSessionActivityCreatedSubscription,
useOnSessionActivityExpiredSubscription,
useGetHostedSessionActivitiesQuery,
ActivityObjectType,
ActivityStatus,
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useSessionActivities/useSessionActivities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Activity,
useOnSessionActivityCompletedSubscription,
useOnSessionActivityCreatedSubscription,
useOnSessionActivityExpiredSubscription,
useGetHostedSessionActivitiesQuery,
GetHostedSessionActivitiesDocument,
GetHostedSessionActivitiesQuery,
Expand Down Expand Up @@ -53,6 +54,7 @@ export const useSessionActivities = (): UsePathwayActivitiesHook => {
* which means the `activities` array will also be automatically updated.
*/
useOnSessionActivityCompletedSubscription({ variables })
useOnSessionActivityExpiredSubscription({ variables })

const sortActivitiesByDate = (activities: Activity[]): Activity[] => {
if (isNil(activities) || isEmpty(activities)) {
Expand Down
68 changes: 68 additions & 0 deletions src/types/generated/types-orchestration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export enum ActivityAction {
Delegated = 'DELEGATED',
Deliver = 'DELIVER',
Discarded = 'DISCARDED',
Expired = 'EXPIRED',
Failed = 'FAILED',
FailedToSend = 'FAILED_TO_SEND',
Generated = 'GENERATED',
Expand Down Expand Up @@ -213,6 +214,7 @@ export enum ActivityObjectType {
}

export enum ActivityResolution {
Expired = 'EXPIRED',
Failure = 'FAILURE',
Success = 'SUCCESS'
}
Expand All @@ -221,6 +223,7 @@ export enum ActivityStatus {
Active = 'ACTIVE',
Canceled = 'CANCELED',
Done = 'DONE',
Expired = 'EXPIRED',
Failed = 'FAILED'
}

Expand Down Expand Up @@ -754,12 +757,18 @@ export type Form = {
id: Scalars['ID'];
key: Scalars['String'];
metadata?: Maybe<Scalars['String']>;
previous_answers?: Maybe<Array<PreviousAnswers>>;
questions: Array<Question>;
release_id: Scalars['String'];
title: Scalars['String'];
trademark?: Maybe<Scalars['String']>;
};


export type FormPrevious_AnswersArgs = {
pathway_id: Scalars['String'];
};

export enum FormDisplayMode {
Conversational = 'CONVERSATIONAL',
Regular = 'REGULAR'
Expand Down Expand Up @@ -1368,6 +1377,13 @@ export type PluginActionSettingsProperty = {
value: Scalars['String'];
};

export type PreviousAnswers = {
__typename?: 'PreviousAnswers';
activity_id: Scalars['ID'];
answers: Array<Answer>;
date: Scalars['String'];
};

export type PublishedPathwayDefinition = {
__typename?: 'PublishedPathwayDefinition';
active_activities?: Maybe<Scalars['Float']>;
Expand Down Expand Up @@ -2041,6 +2057,7 @@ export type Subscription = {
__typename?: 'Subscription';
activityCompleted: Activity;
activityCreated: Activity;
activityExpired: Activity;
activityUpdated: Activity;
apiCallCreated: ApiCall;
apiCallUpdated: ApiCall;
Expand All @@ -2050,6 +2067,7 @@ export type Subscription = {
pathwayUpdated: Pathway;
sessionActivityCompleted: Activity;
sessionActivityCreated: Activity;
sessionActivityExpired: Activity;
sessionActivityUpdated: Activity;
sessionCompleted: HostedSession;
sessionExpired: HostedSession;
Expand All @@ -2070,6 +2088,12 @@ export type SubscriptionActivityCreatedArgs = {
};


export type SubscriptionActivityExpiredArgs = {
only_patient_activities?: InputMaybe<Scalars['Boolean']>;
pathway_id?: InputMaybe<Scalars['String']>;
};


export type SubscriptionActivityUpdatedArgs = {
only_patient_activities?: InputMaybe<Scalars['Boolean']>;
pathway_id?: InputMaybe<Scalars['String']>;
Expand Down Expand Up @@ -2119,6 +2143,11 @@ export type SubscriptionSessionActivityCreatedArgs = {
};


export type SubscriptionSessionActivityExpiredArgs = {
only_stakeholder_activities?: InputMaybe<Scalars['Boolean']>;
};


export type SubscriptionSessionActivityUpdatedArgs = {
only_stakeholder_activities?: InputMaybe<Scalars['Boolean']>;
};
Expand Down Expand Up @@ -2470,6 +2499,13 @@ export type OnSessionActivityCreatedSubscriptionVariables = Exact<{

export type OnSessionActivityCreatedSubscription = { __typename?: 'Subscription', sessionActivityCreated: { __typename?: 'Activity', id: string, date: string, status: ActivityStatus, form_display_mode?: FormDisplayMode | null, object: { __typename?: 'ActivityObject', id: string, type: ActivityObjectType, name: string }, indirect_object?: { __typename?: 'ActivityObject', id: string, type: ActivityObjectType, name: string } | null } };

export type OnSessionActivityExpiredSubscriptionVariables = Exact<{
only_stakeholder_activities: Scalars['Boolean'];
}>;


export type OnSessionActivityExpiredSubscription = { __typename?: 'Subscription', sessionActivityExpired: { __typename?: 'Activity', id: string, date: string, status: ActivityStatus, form_display_mode?: FormDisplayMode | null, object: { __typename?: 'ActivityObject', id: string, type: ActivityObjectType, name: string }, indirect_object?: { __typename?: 'ActivityObject', id: string, type: ActivityObjectType, name: string } | null } };

export type OnSessionActivityUpdatedSubscriptionVariables = Exact<{
only_stakeholder_activities: Scalars['Boolean'];
}>;
Expand Down Expand Up @@ -3103,6 +3139,38 @@ export function useOnSessionActivityCreatedSubscription(baseOptions: Apollo.Subs
}
export type OnSessionActivityCreatedSubscriptionHookResult = ReturnType<typeof useOnSessionActivityCreatedSubscription>;
export type OnSessionActivityCreatedSubscriptionResult = Apollo.SubscriptionResult<OnSessionActivityCreatedSubscription>;
export const OnSessionActivityExpiredDocument = gql`
subscription OnSessionActivityExpired($only_stakeholder_activities: Boolean!) {
sessionActivityExpired(
only_stakeholder_activities: $only_stakeholder_activities
) {
...Activity
}
}
${ActivityFragmentDoc}`;

/**
* __useOnSessionActivityExpiredSubscription__
*
* To run a query within a React component, call `useOnSessionActivityExpiredSubscription` and pass it any options that fit your needs.
* When your component renders, `useOnSessionActivityExpiredSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useOnSessionActivityExpiredSubscription({
* variables: {
* only_stakeholder_activities: // value for 'only_stakeholder_activities'
* },
* });
*/
export function useOnSessionActivityExpiredSubscription(baseOptions: Apollo.SubscriptionHookOptions<OnSessionActivityExpiredSubscription, OnSessionActivityExpiredSubscriptionVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSubscription<OnSessionActivityExpiredSubscription, OnSessionActivityExpiredSubscriptionVariables>(OnSessionActivityExpiredDocument, options);
}
export type OnSessionActivityExpiredSubscriptionHookResult = ReturnType<typeof useOnSessionActivityExpiredSubscription>;
export type OnSessionActivityExpiredSubscriptionResult = Apollo.SubscriptionResult<OnSessionActivityExpiredSubscription>;
export const OnSessionActivityUpdatedDocument = gql`
subscription OnSessionActivityUpdated($only_stakeholder_activities: Boolean!) {
sessionActivityUpdated(
Expand Down

0 comments on commit 31b12c9

Please sign in to comment.