Skip to content

Commit

Permalink
fix frontend type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhaerter committed Sep 26, 2023
1 parent d94e043 commit 1747776
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions frontend/src/composables/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { computed } from "vue"
const useToken = () => {
return computed({
set: (value) => {
if (!value) return
localStorage.setItem('token', value)
},
get: () => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const documents = {
"mutation updateTimeEntry($id: ID!, $input: UpdateTimeEntryInput!) {\n updateTimeEntry(id: $id, input: $input) {\n timeEntry {\n id\n description\n createdAt\n startedAt\n completedAt\n }\n }\n}": types.UpdateTimeEntryDocument,
"query timeEntries {\n timeEntries {\n edges {\n id\n description\n createdAt\n startedAt\n completedAt\n }\n }\n}": types.TimeEntriesDocument,
"mutation signIn($email: String!, $password: String!) {\n signIn(email: $email, password: $password) {\n token\n user {\n id\n }\n }\n}": types.SignInDocument,
"mutation signUp($email: String!, $password: String!) {\n signUp(email: $email, password: $password) {\n token\n user {\n id\n }\n }\n}": types.SignUpDocument,
"\n mutation signUp($email: String!, $password: String!, $name: String!) {\n signUp(email: $email, password: $password, name: $name) {\n token\n user {\n id\n }\n }\n }\n": types.SignUpDocument,
};

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ export function graphql(source: "mutation signIn($email: String!, $password: Str
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "mutation signUp($email: String!, $password: String!) {\n signUp(email: $email, password: $password) {\n token\n user {\n id\n }\n }\n}"): (typeof documents)["mutation signUp($email: String!, $password: String!) {\n signUp(email: $email, password: $password) {\n token\n user {\n id\n }\n }\n}"];
export function graphql(source: "\n mutation signUp($email: String!, $password: String!, $name: String!) {\n signUp(email: $email, password: $password, name: $name) {\n token\n user {\n id\n }\n }\n }\n"): (typeof documents)["\n mutation signUp($email: String!, $password: String!, $name: String!) {\n signUp(email: $email, password: $password, name: $name) {\n token\n user {\n id\n }\n }\n }\n"];

export function graphql(source: string) {
return (documents as any)[source] ?? {};
Expand Down
42 changes: 41 additions & 1 deletion frontend/src/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Scalars = {
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
Any: { input: any; output: any; }
Time: { input: any; output: any; }
};

Expand Down Expand Up @@ -41,8 +42,11 @@ export type Mutation = {
__typename?: 'Mutation';
createProject: CreateProjectPayload;
createTimeEntry: CreateTimeEntryPayload;
requestPasswordReset: RequestPasswordResetPayload;
resetPassword: ResetPasswordPayload;
signIn: SignInPayload;
signUp: SignUpPayload;
updateMorningRecapOptIn: UpdateMorningRecapOptInPayload;
updateProject: UpdateProjectPayload;
updateTimeEntry: UpdateTimeEntryPayload;
};
Expand All @@ -58,6 +62,17 @@ export type MutationCreateTimeEntryArgs = {
};


export type MutationRequestPasswordResetArgs = {
email: Scalars['String']['input'];
};


export type MutationResetPasswordArgs = {
newPassword: Scalars['String']['input'];
token: Scalars['String']['input'];
};


export type MutationSignInArgs = {
email: Scalars['String']['input'];
password: Scalars['String']['input'];
Expand All @@ -66,10 +81,16 @@ export type MutationSignInArgs = {

export type MutationSignUpArgs = {
email: Scalars['String']['input'];
name: Scalars['String']['input'];
password: Scalars['String']['input'];
};


export type MutationUpdateMorningRecapOptInArgs = {
enabled: Scalars['Boolean']['input'];
};


export type MutationUpdateProjectArgs = {
id: Scalars['ID']['input'];
input: UpdateProjectInput;
Expand Down Expand Up @@ -107,6 +128,18 @@ export type QueryTimeEntryArgs = {
id: Scalars['ID']['input'];
};

export type RequestPasswordResetPayload = {
__typename?: 'RequestPasswordResetPayload';
/** @deprecated reserved for future use. Use __typename */
_?: Maybe<Scalars['Any']['output']>;
};

export type ResetPasswordPayload = {
__typename?: 'ResetPasswordPayload';
/** @deprecated reserved for future use. Use __typename */
_?: Maybe<Scalars['Any']['output']>;
};

export type SignInPayload = {
__typename?: 'SignInPayload';
token: Scalars['String']['output'];
Expand Down Expand Up @@ -135,6 +168,11 @@ export type TimeEntryConnection = {
edges: Array<TimeEntry>;
};

export type UpdateMorningRecapOptInPayload = {
__typename?: 'UpdateMorningRecapOptInPayload';
user: User;
};

export type UpdateProjectInput = {
color?: InputMaybe<Scalars['String']['input']>;
name?: InputMaybe<Scalars['String']['input']>;
Expand All @@ -160,6 +198,7 @@ export type User = {
__typename?: 'User';
email: Scalars['String']['output'];
id: Scalars['ID']['output'];
morningRecapOptIn: Scalars['Boolean']['output'];
};

export type RunningTimeEntryQueryVariables = Exact<{ [key: string]: never; }>;
Expand Down Expand Up @@ -198,6 +237,7 @@ export type SignInMutation = { __typename?: 'Mutation', signIn: { __typename?: '
export type SignUpMutationVariables = Exact<{
email: Scalars['String']['input'];
password: Scalars['String']['input'];
name: Scalars['String']['input'];
}>;


Expand All @@ -209,4 +249,4 @@ export const CreateTimeEntryDocument = {"kind":"Document","definitions":[{"kind"
export const UpdateTimeEntryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"updateTimeEntry"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateTimeEntryInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateTimeEntry"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"timeEntry"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"completedAt"}}]}}]}}]}}]} as unknown as DocumentNode<UpdateTimeEntryMutation, UpdateTimeEntryMutationVariables>;
export const TimeEntriesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"timeEntries"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"timeEntries"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"completedAt"}}]}}]}}]}}]} as unknown as DocumentNode<TimeEntriesQuery, TimeEntriesQueryVariables>;
export const SignInDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"signIn"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"password"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signIn"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"password"},"value":{"kind":"Variable","name":{"kind":"Name","value":"password"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]} as unknown as DocumentNode<SignInMutation, SignInMutationVariables>;
export const SignUpDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"signUp"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"password"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signUp"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"password"},"value":{"kind":"Variable","name":{"kind":"Name","value":"password"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]} as unknown as DocumentNode<SignUpMutation, SignUpMutationVariables>;
export const SignUpDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"signUp"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"password"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"name"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signUp"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"password"},"value":{"kind":"Variable","name":{"kind":"Name","value":"password"}}},{"kind":"Argument","name":{"kind":"Name","value":"name"},"value":{"kind":"Variable","name":{"kind":"Name","value":"name"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]} as unknown as DocumentNode<SignUpMutation, SignUpMutationVariables>;
4 changes: 4 additions & 0 deletions frontend/src/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ async function onSubmit() {
}
console.log(data)
if (!data?.signIn) {
alert('Invalid credentials')
return
}
localStorage.setItem('token', data?.signIn.token)
console.log(data)
}
Expand Down

0 comments on commit 1747776

Please sign in to comment.