Skip to content
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

Add visions page basic #49

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 134 additions & 52 deletions app/@types/graphql/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ export type ActivityUpdatePayload = {

export type Advice = {
__typename?: 'Advice';
activitiesTotal: Scalars['Int']['output'];
activityPrompt?: Maybe<Scalars['String']['output']>;
activitySummary?: Maybe<Scalars['String']['output']>;
aiEngine: AiEngine;
aiEngineId: Scalars['Int']['output'];
analyzedActivitiesTotal: Scalars['Int']['output'];
analyzedAt: Scalars['ISO8601DateTime']['output'];
cycle?: Maybe<Cycle>;
cycleId: Scalars['Int']['output'];
Expand All @@ -92,11 +94,12 @@ export type Advice = {
individualId: Scalars['Int']['output'];
isActivityAnalyzed: Scalars['Boolean']['output'];
isAnalyzed: Scalars['Boolean']['output'];
isOutlookAnalyzed: Scalars['Boolean']['output'];
outlookPrompt?: Maybe<Scalars['String']['output']>;
outlookSummary?: Maybe<Scalars['String']['output']>;
isVisionAnalyzed: Scalars['Boolean']['output'];
prompt?: Maybe<Scalars['String']['output']>;
result?: Maybe<Scalars['String']['output']>;
visionPrompt?: Maybe<Scalars['String']['output']>;
visionSummary?: Maybe<Scalars['String']['output']>;
visionsTotal: Scalars['Int']['output'];
};

/** The connection type for Advice. */
Expand Down Expand Up @@ -412,17 +415,6 @@ export type ManagerReportsArgs = {
last?: InputMaybe<Scalars['Int']['input']>;
};

/** The connection type for Manager. */
export type ManagerConnection = {
__typename?: 'ManagerConnection';
/** A list of edges. */
edges?: Maybe<Array<Maybe<ManagerEdge>>>;
/** A list of nodes. */
nodes?: Maybe<Array<Maybe<Manager>>>;
/** Information to aid in pagination. */
pageInfo: PageInfo;
};

/** Autogenerated input type of ManagerCreate */
export type ManagerCreateInput = {
/** A unique identifier for the client performing the mutation. */
Expand All @@ -438,15 +430,6 @@ export type ManagerCreatePayload = {
manager: Manager;
};

/** An edge in a connection. */
export type ManagerEdge = {
__typename?: 'ManagerEdge';
/** A cursor for use in pagination. */
cursor: Scalars['String']['output'];
/** The item at the end of the edge. */
node?: Maybe<Manager>;
};

export type ManagerInput = {
Id: Scalars['Int']['input'];
Name: Scalars['String']['input'];
Expand Down Expand Up @@ -480,7 +463,7 @@ export type Mutation = {
cycleCreate?: Maybe<CycleCreatePayload>;
/** Update an existing cycle by id */
cycleUpdate?: Maybe<CycleUpdatePayload>;
/** Gather activities and outlooks for an individual's cycle, generate summaries and then generate advice based on them */
/** Gather activities and visions for an individual's cycle, generate summaries and then generate advice based on them */
generateCycleAdvice?: Maybe<GenerateCycleAdvicePayload>;
/** Import activities from external channel */
importActivities?: Maybe<ImportActivitiesPayload>;
Expand Down Expand Up @@ -615,16 +598,12 @@ export type Query = {
individual: Individual;
/** Returns a list of individuals */
individuals: IndividualConnection;
/** Returns a manager */
manager: Manager;
/** Returns a list of managers */
managers: ManagerConnection;
/** Returns logged in user details */
myInfo: UserInfo;
/** Returns a report */
report: Report;
/** Returns a list of reports */
reports: ReportConnection;
/** Returns a vision */
vision: Vision;
/** Returns a list of visions */
visions: VisionConnection;
};


Expand Down Expand Up @@ -692,32 +671,22 @@ export type QueryIndividualsArgs = {
};


export type QueryManagerArgs = {
export type QueryVisionArgs = {
id: Scalars['ID']['input'];
};


export type QueryManagersArgs = {
export type QueryVisionsArgs = {
after?: InputMaybe<Scalars['String']['input']>;
before?: InputMaybe<Scalars['String']['input']>;
cycleId?: InputMaybe<Scalars['ID']['input']>;
first?: InputMaybe<Scalars['Int']['input']>;
hasContent?: InputMaybe<Scalars['Boolean']['input']>;
individualId?: InputMaybe<Scalars['ID']['input']>;
last?: InputMaybe<Scalars['Int']['input']>;
orderBy?: InputMaybe<Array<Order>>;
};


export type QueryReportArgs = {
id: Scalars['ID']['input'];
};


export type QueryReportsArgs = {
after?: InputMaybe<Scalars['String']['input']>;
before?: InputMaybe<Scalars['String']['input']>;
first?: InputMaybe<Scalars['Int']['input']>;
last?: InputMaybe<Scalars['Int']['input']>;
};

export type Report = {
__typename?: 'Report';
Id: Scalars['Int']['output'];
Expand Down Expand Up @@ -791,6 +760,45 @@ export type UserInfo = {
UserId: Scalars['Int']['output'];
};

export type Vision = {
__typename?: 'Vision';
content?: Maybe<Scalars['String']['output']>;
cycle?: Maybe<Cycle>;
cycleId?: Maybe<Scalars['Int']['output']>;
date: Scalars['ISO8601DateTime']['output'];
description: Scalars['String']['output'];
documentId?: Maybe<Scalars['String']['output']>;
documentUrl?: Maybe<Scalars['String']['output']>;
hasContent: Scalars['Boolean']['output'];
id: Scalars['Int']['output'];
individual?: Maybe<Individual>;
individualId?: Maybe<Scalars['Int']['output']>;
organizationId?: Maybe<Scalars['Int']['output']>;
validFrom?: Maybe<Scalars['ISO8601DateTime']['output']>;
validTo?: Maybe<Scalars['ISO8601DateTime']['output']>;
visionTypeId: Scalars['Int']['output'];
};

/** The connection type for Vision. */
export type VisionConnection = {
__typename?: 'VisionConnection';
/** A list of edges. */
edges?: Maybe<Array<Maybe<VisionEdge>>>;
/** A list of nodes. */
nodes?: Maybe<Array<Maybe<Vision>>>;
/** Information to aid in pagination. */
pageInfo: PageInfo;
};

/** An edge in a connection. */
export type VisionEdge = {
__typename?: 'VisionEdge';
/** A cursor for use in pagination. */
cursor: Scalars['String']['output'];
/** The item at the end of the edge. */
node?: Maybe<Vision>;
};

export type AssignActivitiesMutationVariables = Exact<{
input: AssignMissedCycleActivitiesInput;
}>;
Expand Down Expand Up @@ -855,16 +863,16 @@ export type GenerateCycleAdviceMutationVariables = Exact<{
}>;


export type GenerateCycleAdviceMutation = { __typename?: 'Mutation', generateCycleAdvice?: { __typename?: 'GenerateCycleAdvicePayload', advice: { __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isOutlookAnalyzed: boolean, result?: string | null, outlookSummary?: string | null, activitySummary?: string | null, analyzedAt: any } } | null };
export type GenerateCycleAdviceMutation = { __typename?: 'Mutation', generateCycleAdvice?: { __typename?: 'GenerateCycleAdvicePayload', advice: { __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isVisionAnalyzed: boolean, result?: string | null, visionSummary?: string | null, activitySummary?: string | null, analyzedAt: any, activitiesTotal: number, analyzedActivitiesTotal: number, visionsTotal: number } } | null };

export type AdviceFragmentFragment = { __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isOutlookAnalyzed: boolean, result?: string | null, outlookSummary?: string | null, activitySummary?: string | null, analyzedAt: any };
export type AdviceFragmentFragment = { __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isVisionAnalyzed: boolean, result?: string | null, visionSummary?: string | null, activitySummary?: string | null, analyzedAt: any, activitiesTotal: number, analyzedActivitiesTotal: number, visionsTotal: number };

export type CoachIndividualQueryVariables = Exact<{
id: Scalars['ID']['input'];
}>;


export type CoachIndividualQuery = { __typename?: 'Query', individual: { __typename?: 'Individual', id: number, fullname?: string | null, handleGithub?: string | null, handleGoogle?: string | null, jobTitle?: string | null, jobLevelId?: string | null, userId?: number | null, managerId?: number | null, isManager: boolean, activeCycles?: { __typename?: 'CycleConnection', nodes?: Array<{ __typename?: 'Cycle', id: number, title: string, description?: string | null, from: any, to: any } | null> | null } | null }, adviceList: { __typename?: 'AdviceConnection', nodes?: Array<{ __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isOutlookAnalyzed: boolean, result?: string | null, outlookSummary?: string | null, activitySummary?: string | null, analyzedAt: any } | null> | null } };
export type CoachIndividualQuery = { __typename?: 'Query', individual: { __typename?: 'Individual', id: number, fullname?: string | null, handleGithub?: string | null, handleGoogle?: string | null, jobTitle?: string | null, jobLevelId?: string | null, userId?: number | null, managerId?: number | null, isManager: boolean, activeCycles?: { __typename?: 'CycleConnection', nodes?: Array<{ __typename?: 'Cycle', id: number, title: string, description?: string | null, from: any, to: any } | null> | null } | null }, adviceList: { __typename?: 'AdviceConnection', nodes?: Array<{ __typename?: 'Advice', cycleId: number, id: number, isAnalyzed: boolean, isActivityAnalyzed: boolean, isVisionAnalyzed: boolean, result?: string | null, visionSummary?: string | null, activitySummary?: string | null, analyzedAt: any, activitiesTotal: number, analyzedActivitiesTotal: number, visionsTotal: number } | null> | null } };

export type FindIndividualQueryVariables = Exact<{
id: Scalars['ID']['input'];
Expand Down Expand Up @@ -917,6 +925,14 @@ export type GetManagersQueryVariables = Exact<{ [key: string]: never; }>;

export type GetManagersQuery = { __typename?: 'Query', managers: { __typename?: 'IndividualConnection', nodes?: Array<{ __typename?: 'Individual', id: number, fullname?: string | null } | null> | null } };

export type IndividualVisionsQueryVariables = Exact<{
individualId: Scalars['ID']['input'];
cycleId?: InputMaybe<Scalars['ID']['input']>;
}>;


export type IndividualVisionsQuery = { __typename?: 'Query', individual: { __typename?: 'Individual', fullname?: string | null }, cycles: { __typename?: 'CycleConnection', nodes?: Array<{ __typename?: 'Cycle', id: number, title: string } | null> | null }, visions: { __typename?: 'VisionConnection', nodes?: Array<{ __typename?: 'Vision', id: number, visionTypeId: number, documentId?: string | null, documentUrl?: string | null, hasContent: boolean, date: any, validFrom?: any | null, validTo?: any | null, description: string, cycleId?: number | null, cycle?: { __typename?: 'Cycle', title: string } | null } | null> | null } };

export type IndividualsQueryVariables = Exact<{
managerId?: InputMaybe<Scalars['ID']['input']>;
fetchManagerId: Scalars['ID']['input'];
Expand Down Expand Up @@ -956,11 +972,14 @@ export const AdviceFragmentFragmentDoc = gql`
id
isAnalyzed
isActivityAnalyzed
isOutlookAnalyzed
isVisionAnalyzed
result
outlookSummary
visionSummary
activitySummary
analyzedAt
activitiesTotal
analyzedActivitiesTotal
visionsTotal
}
`;
export const IndividualFragmentFragmentDoc = gql`
Expand Down Expand Up @@ -1628,6 +1647,69 @@ export function useGetManagersLazyQuery(baseOptions?: Apollo.LazyQueryHookOption
export type GetManagersQueryHookResult = ReturnType<typeof useGetManagersQuery>;
export type GetManagersLazyQueryHookResult = ReturnType<typeof useGetManagersLazyQuery>;
export type GetManagersQueryResult = Apollo.QueryResult<GetManagersQuery, GetManagersQueryVariables>;
export const IndividualVisionsDocument = gql`
query individualVisions($individualId: ID!, $cycleId: ID) {
individual(id: $individualId) {
fullname
}
cycles(orderBy: [{field: "from", direction: "desc"}]) {
nodes {
id
title
}
}
visions(
individualId: $individualId
cycleId: $cycleId
orderBy: [{field: "date", direction: "desc"}]
) {
nodes {
id
visionTypeId
documentId
documentUrl
hasContent
date
validFrom
validTo
description
cycleId
cycle {
title
}
}
}
}
`;

/**
* __useIndividualVisionsQuery__
*
* To run a query within a React component, call `useIndividualVisionsQuery` and pass it any options that fit your needs.
* When your component renders, `useIndividualVisionsQuery` 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 } = useIndividualVisionsQuery({
* variables: {
* individualId: // value for 'individualId'
* cycleId: // value for 'cycleId'
* },
* });
*/
export function useIndividualVisionsQuery(baseOptions: Apollo.QueryHookOptions<IndividualVisionsQuery, IndividualVisionsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<IndividualVisionsQuery, IndividualVisionsQueryVariables>(IndividualVisionsDocument, options);
}
export function useIndividualVisionsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<IndividualVisionsQuery, IndividualVisionsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<IndividualVisionsQuery, IndividualVisionsQueryVariables>(IndividualVisionsDocument, options);
}
export type IndividualVisionsQueryHookResult = ReturnType<typeof useIndividualVisionsQuery>;
export type IndividualVisionsLazyQueryHookResult = ReturnType<typeof useIndividualVisionsLazyQuery>;
export type IndividualVisionsQueryResult = Apollo.QueryResult<IndividualVisionsQuery, IndividualVisionsQueryVariables>;
export const IndividualsDocument = gql`
query individuals($managerId: ID, $fetchManagerId: ID!, $fetchManagerDetails: Boolean = false, $isManager: Boolean) {
individuals(managerId: $managerId, isManager: $isManager, isActive: true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ fragment AdviceFragment on Advice {
id
isAnalyzed
isActivityAnalyzed
isOutlookAnalyzed
isVisionAnalyzed
result
outlookSummary
visionSummary
activitySummary
analyzedAt
activitiesTotal
analyzedActivitiesTotal
visionsTotal
}
41 changes: 33 additions & 8 deletions app/routes/_dashboard.individuals.$id.coach/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Card,
CardBody,
Spinner,
Tooltip,
Typography,
} from "@material-tailwind/react";

Expand Down Expand Up @@ -109,12 +110,23 @@ export default function IndividualCoach() {
<Card className="flex-1">
<CardBody>
<Typography variant="h6" color="gray" className="mb-4 uppercase">
<Link
to={`/individuals/${id}/activities?cycleid=${cycle.id}`}
className="flex items-center gap-1 hover:underline"
<Tooltip
content={
"This summary is based on " +
cycle.advice?.analyzedActivitiesTotal.toString() +
" analyzed activities out of " +
cycle.advice?.activitiesTotal.toString() +
" total. Click to see more details..."
}
>
Activities Summary
</Link>
<Link
to={`/individuals/${id}/activities?cycleid=${cycle.id}`}
className="flex items-center gap-1 hover:underline"
>
Activities Summary ({cycle.advice?.analyzedActivitiesTotal}/
{cycle.advice?.activitiesTotal})
</Link>
</Tooltip>
</Typography>

<Typography color="gray" className="mb-8 font-normal">
Expand All @@ -131,14 +143,27 @@ export default function IndividualCoach() {
<Card className="flex-1">
<CardBody>
<Typography variant="h6" color="gray" className="mb-4 uppercase">
Expectations
<Tooltip
content={
"This summary is based on " +
cycle.advice?.visionsTotal.toString() +
" analyzed visions. Click to see more details..."
}
>
<Link
to={`/individuals/${id}/visions?cycleid=${cycle.id}`}
className="flex items-center gap-1 hover:underline"
>
Expectations ({cycle.advice?.visionsTotal})
</Link>
</Tooltip>
</Typography>

<Typography color="gray" className="mb-8 font-normal">
{isOnGneratingAdvice ? (
<DefaultSkeleton />
) : cycle.advice?.outlookSummary ? (
cycle.advice.outlookSummary
) : cycle.advice?.visionSummary ? (
cycle.advice.visionSummary
) : (
"-"
)}
Expand Down
11 changes: 11 additions & 0 deletions app/routes/_dashboard.individuals.($id).activities/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ export default function Activities() {
/>
Import recent activities...
</Button>
<Button
className="flex items-center gap-3"
size="sm"
variant="outlined"
>
<ArrowDownOnSquareStackIcon
strokeWidth={2}
className="h-4 w-4"
/>
Analyze remained activities...
</Button>
</div>
</div>
<div className="flex flex-col items-center justify-between gap-4 md:flex-row">
Expand Down
Loading
Loading