Skip to content

Commit

Permalink
add Individuals pages - show only
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoudmoravej committed Dec 6, 2023
1 parent 67d5a01 commit df45d10
Show file tree
Hide file tree
Showing 22 changed files with 591 additions and 309 deletions.
258 changes: 233 additions & 25 deletions app/@types/graphql/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,123 @@ export type Scalars = {
Float: { input: number; output: number; }
};

export type Individual = {
__typename?: 'Individual';
fullname?: Maybe<Scalars['String']['output']>;
handleGithub?: Maybe<Scalars['String']['output']>;
handleGoogle?: Maybe<Scalars['String']['output']>;
id: Scalars['Int']['output'];
isActive: Scalars['Boolean']['output'];
isManager: Scalars['Boolean']['output'];
jobLevelId?: Maybe<Scalars['String']['output']>;
jobTitle?: Maybe<Scalars['String']['output']>;
manager?: Maybe<Individual>;
managerId?: Maybe<Scalars['Int']['output']>;
organizationId: Scalars['Int']['output'];
reports: IndividualConnection;
userId?: Maybe<Scalars['Int']['output']>;
};


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

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

export type IndividualCreate = {
fullname?: InputMaybe<Scalars['String']['input']>;
handleGithub?: InputMaybe<Scalars['String']['input']>;
handleGoogle?: InputMaybe<Scalars['String']['input']>;
isActive: Scalars['Boolean']['input'];
isManager: Scalars['Boolean']['input'];
jobLevelId?: InputMaybe<Scalars['String']['input']>;
jobTitle?: InputMaybe<Scalars['String']['input']>;
managerId?: InputMaybe<Scalars['Int']['input']>;
organizationId?: InputMaybe<Scalars['Int']['input']>;
userId?: InputMaybe<Scalars['Int']['input']>;
};

/** Autogenerated input type of IndividualCreate */
export type IndividualCreateInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
individualInput: IndividualCreate;
};

/** Autogenerated return type of IndividualCreate. */
export type IndividualCreatePayload = {
__typename?: 'IndividualCreatePayload';
/** A unique identifier for the client performing the mutation. */
clientMutationId?: Maybe<Scalars['String']['output']>;
individual: Individual;
};

/** Autogenerated input type of IndividualDestroy */
export type IndividualDestroyInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
id: Scalars['ID']['input'];
};

/** Autogenerated return type of IndividualDestroy. */
export type IndividualDestroyPayload = {
__typename?: 'IndividualDestroyPayload';
/** A unique identifier for the client performing the mutation. */
clientMutationId?: Maybe<Scalars['String']['output']>;
individual: Individual;
};

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

export type IndividualUpdate = {
fullname?: InputMaybe<Scalars['String']['input']>;
handleGithub?: InputMaybe<Scalars['String']['input']>;
handleGoogle?: InputMaybe<Scalars['String']['input']>;
isActive?: InputMaybe<Scalars['Boolean']['input']>;
isManager?: InputMaybe<Scalars['Boolean']['input']>;
jobLevelId?: InputMaybe<Scalars['String']['input']>;
jobTitle?: InputMaybe<Scalars['String']['input']>;
managerId?: InputMaybe<Scalars['Int']['input']>;
organizationId?: InputMaybe<Scalars['Int']['input']>;
userId?: InputMaybe<Scalars['Int']['input']>;
};

/** Autogenerated input type of IndividualUpdate */
export type IndividualUpdateInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
id: Scalars['ID']['input'];
individualInput: IndividualUpdate;
};

/** Autogenerated return type of IndividualUpdate. */
export type IndividualUpdatePayload = {
__typename?: 'IndividualUpdatePayload';
/** A unique identifier for the client performing the mutation. */
clientMutationId?: Maybe<Scalars['String']['output']>;
individual: Individual;
};

export type Manager = {
__typename?: 'Manager';
Id: Scalars['Int']['output'];
Expand Down Expand Up @@ -90,6 +207,12 @@ export type ManagerUpdatePayload = {

export type Mutation = {
__typename?: 'Mutation';
/** Creates a new individual */
individualCreate?: Maybe<IndividualCreatePayload>;
/** remove an existing individual by id */
individualDestroy?: Maybe<IndividualDestroyPayload>;
/** Update an existing individual by id */
individualUpdate?: Maybe<IndividualUpdatePayload>;
/** Creates a new manager */
managerCreate?: Maybe<ManagerCreatePayload>;
/** Updates a manager by id */
Expand All @@ -101,6 +224,21 @@ export type Mutation = {
};


export type MutationIndividualCreateArgs = {
input: IndividualCreateInput;
};


export type MutationIndividualDestroyArgs = {
input: IndividualDestroyInput;
};


export type MutationIndividualUpdateArgs = {
input: IndividualUpdateInput;
};


export type MutationManagerCreateArgs = {
input: ManagerCreateInput;
};
Expand Down Expand Up @@ -149,17 +287,38 @@ export enum PerformanceCategory {

export type Query = {
__typename?: 'Query';
/** Returns an individual */
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;
};


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


export type QueryIndividualsArgs = {
after?: InputMaybe<Scalars['String']['input']>;
before?: InputMaybe<Scalars['String']['input']>;
first?: InputMaybe<Scalars['Int']['input']>;
last?: InputMaybe<Scalars['Int']['input']>;
managerId?: InputMaybe<Scalars['ID']['input']>;
orderBy?: InputMaybe<Array<Order>>;
};


export type QueryManagerArgs = {
id: Scalars['ID']['input'];
};
Expand Down Expand Up @@ -253,6 +412,12 @@ export type ReportUpdatePayload = {
report: Report;
};

export type UserInfo = {
__typename?: 'UserInfo';
Individual?: Maybe<Individual>;
UserId: Scalars['Int']['output'];
};

export type FindManagerQueryVariables = Exact<{
id: Scalars['ID']['input'];
}>;
Expand All @@ -269,10 +434,12 @@ export type UpdateManagerMutationVariables = Exact<{

export type UpdateManagerMutation = { __typename?: 'Mutation', managerUpdate?: { __typename?: 'ManagerUpdatePayload', manager: { __typename?: 'Manager', Name: string, Id: number } } | null };

export type ManagersQueryVariables = Exact<{ [key: string]: never; }>;
export type IndividualsQueryVariables = Exact<{
managerId?: InputMaybe<Scalars['ID']['input']>;
}>;


export type ManagersQuery = { __typename?: 'Query', managers: { __typename?: 'ManagerConnection', nodes?: Array<{ __typename?: 'Manager', id: number, name: string, reports: { __typename?: 'ReportConnection', nodes?: Array<{ __typename?: 'Report', id: number, name: string } | null> | null } } | null> | null } };
export type IndividualsQuery = { __typename?: 'Query', individuals: { __typename?: 'IndividualConnection', nodes?: Array<{ __typename?: 'Individual', id: number, fullname?: string | null, jobTitle?: string | null, jobLevelId?: string | null, isManager: boolean } | null> | null } };

export type CreateManagerMutationVariables = Exact<{
name: Scalars['String']['input'];
Expand All @@ -282,6 +449,11 @@ export type CreateManagerMutationVariables = Exact<{

export type CreateManagerMutation = { __typename?: 'Mutation', managerCreate?: { __typename?: 'ManagerCreatePayload', manager: { __typename?: 'Manager', Name: string, Id: number } } | null };

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


export type GetLoggedInUserInfoQuery = { __typename?: 'Query', myInfo: { __typename?: 'UserInfo', UserId: number, Individual?: { __typename?: 'Individual', id: number, isManager: boolean } | null } };


export const FindManagerDocument = gql`
query findManager($id: ID!) {
Expand Down Expand Up @@ -357,49 +529,47 @@ export function useUpdateManagerMutation(baseOptions?: Apollo.MutationHookOption
export type UpdateManagerMutationHookResult = ReturnType<typeof useUpdateManagerMutation>;
export type UpdateManagerMutationResult = Apollo.MutationResult<UpdateManagerMutation>;
export type UpdateManagerMutationOptions = Apollo.BaseMutationOptions<UpdateManagerMutation, UpdateManagerMutationVariables>;
export const ManagersDocument = gql`
query managers {
managers(first: 10, orderBy: {field: "name", direction: "ASC"}) {
export const IndividualsDocument = gql`
query individuals($managerId: ID) {
individuals(managerId: $managerId) {
nodes {
id: Id
name: Name
reports: Reports {
nodes {
id: Id
name: Name
}
}
id
fullname
jobTitle
jobLevelId
isManager
}
}
}
`;

/**
* __useManagersQuery__
* __useIndividualsQuery__
*
* To run a query within a React component, call `useManagersQuery` and pass it any options that fit your needs.
* When your component renders, `useManagersQuery` returns an object from Apollo Client that contains loading, error, and data properties
* To run a query within a React component, call `useIndividualsQuery` and pass it any options that fit your needs.
* When your component renders, `useIndividualsQuery` 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 } = useManagersQuery({
* const { data, loading, error } = useIndividualsQuery({
* variables: {
* managerId: // value for 'managerId'
* },
* });
*/
export function useManagersQuery(baseOptions?: Apollo.QueryHookOptions<ManagersQuery, ManagersQueryVariables>) {
export function useIndividualsQuery(baseOptions?: Apollo.QueryHookOptions<IndividualsQuery, IndividualsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ManagersQuery, ManagersQueryVariables>(ManagersDocument, options);
return Apollo.useQuery<IndividualsQuery, IndividualsQueryVariables>(IndividualsDocument, options);
}
export function useManagersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ManagersQuery, ManagersQueryVariables>) {
export function useIndividualsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<IndividualsQuery, IndividualsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ManagersQuery, ManagersQueryVariables>(ManagersDocument, options);
return Apollo.useLazyQuery<IndividualsQuery, IndividualsQueryVariables>(IndividualsDocument, options);
}
export type ManagersQueryHookResult = ReturnType<typeof useManagersQuery>;
export type ManagersLazyQueryHookResult = ReturnType<typeof useManagersLazyQuery>;
export type ManagersQueryResult = Apollo.QueryResult<ManagersQuery, ManagersQueryVariables>;
export type IndividualsQueryHookResult = ReturnType<typeof useIndividualsQuery>;
export type IndividualsLazyQueryHookResult = ReturnType<typeof useIndividualsLazyQuery>;
export type IndividualsQueryResult = Apollo.QueryResult<IndividualsQuery, IndividualsQueryVariables>;
export const CreateManagerDocument = gql`
mutation createManager($name: String!, $id: Int!) {
managerCreate(input: {managerInput: {Name: $name, Id: $id}}) {
Expand Down Expand Up @@ -436,4 +606,42 @@ export function useCreateManagerMutation(baseOptions?: Apollo.MutationHookOption
}
export type CreateManagerMutationHookResult = ReturnType<typeof useCreateManagerMutation>;
export type CreateManagerMutationResult = Apollo.MutationResult<CreateManagerMutation>;
export type CreateManagerMutationOptions = Apollo.BaseMutationOptions<CreateManagerMutation, CreateManagerMutationVariables>;
export type CreateManagerMutationOptions = Apollo.BaseMutationOptions<CreateManagerMutation, CreateManagerMutationVariables>;
export const GetLoggedInUserInfoDocument = gql`
query getLoggedInUserInfo {
myInfo {
UserId
Individual {
id
isManager
}
}
}
`;

/**
* __useGetLoggedInUserInfoQuery__
*
* To run a query within a React component, call `useGetLoggedInUserInfoQuery` and pass it any options that fit your needs.
* When your component renders, `useGetLoggedInUserInfoQuery` 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 } = useGetLoggedInUserInfoQuery({
* variables: {
* },
* });
*/
export function useGetLoggedInUserInfoQuery(baseOptions?: Apollo.QueryHookOptions<GetLoggedInUserInfoQuery, GetLoggedInUserInfoQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<GetLoggedInUserInfoQuery, GetLoggedInUserInfoQueryVariables>(GetLoggedInUserInfoDocument, options);
}
export function useGetLoggedInUserInfoLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetLoggedInUserInfoQuery, GetLoggedInUserInfoQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GetLoggedInUserInfoQuery, GetLoggedInUserInfoQueryVariables>(GetLoggedInUserInfoDocument, options);
}
export type GetLoggedInUserInfoQueryHookResult = ReturnType<typeof useGetLoggedInUserInfoQuery>;
export type GetLoggedInUserInfoLazyQueryHookResult = ReturnType<typeof useGetLoggedInUserInfoLazyQuery>;
export type GetLoggedInUserInfoQueryResult = Apollo.QueryResult<GetLoggedInUserInfoQuery, GetLoggedInUserInfoQueryVariables>;
22 changes: 3 additions & 19 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";

import {
ApolloProvider,
ApolloClient,
InMemoryCache,
createHttpLink,
} from "@apollo/client";
import { ApolloProvider } from "@apollo/client";
import { getDataFromTree } from "@apollo/client/react/ssr";
import { authenticator } from "./services/auth.server";
import type { ReactElement } from "react";
import * as utils from "./utils";

const ABORT_DELAY = 5_000;

Expand Down Expand Up @@ -178,17 +174,5 @@ async function wrapRemixServerWithApollo(
async function getApolloClient(request: Request) {
let user = await authenticator.isAuthenticated(request);

const client = new ApolloClient({
ssrMode: true,
cache: new InMemoryCache(),
link: createHttpLink({
uri: process.env.GRAPHQL_SCHEMA_URL || "GRAPHQL_SCHEMA_URL IS NOT SET",
headers: {
...Object.fromEntries(request.headers),
Authorization: `Bearer ${user?.jwt_token ?? "ERROR TOKEN!"}`,
},
credentials: request.credentials ?? "include", // or "same-origin" if your backend server is the same domain
}),
});
return client;
return utils.getApolloClient(request, user?.jwt_token);
}
3 changes: 3 additions & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ export type User = {
email: string;
jwt_token: string;
name: string;
user_id: number;
individual_id?: number;
is_manager?: boolean;
};
Loading

0 comments on commit df45d10

Please sign in to comment.