From 1747776811835a3e68b939d6df86b2d1deaa8157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20H=C3=A4rter?= Date: Tue, 26 Sep 2023 19:30:30 +0200 Subject: [PATCH] fix frontend type issues --- frontend/src/composables/useUser.ts | 1 + frontend/src/gql/gql.ts | 4 +-- frontend/src/gql/graphql.ts | 42 ++++++++++++++++++++++++++++- frontend/src/views/LoginView.vue | 4 +++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/frontend/src/composables/useUser.ts b/frontend/src/composables/useUser.ts index 5e25325..32c6b3b 100644 --- a/frontend/src/composables/useUser.ts +++ b/frontend/src/composables/useUser.ts @@ -3,6 +3,7 @@ import { computed } from "vue" const useToken = () => { return computed({ set: (value) => { + if (!value) return localStorage.setItem('token', value) }, get: () => { diff --git a/frontend/src/gql/gql.ts b/frontend/src/gql/gql.ts index 6464bb6..2caf7a9 100644 --- a/frontend/src/gql/gql.ts +++ b/frontend/src/gql/gql.ts @@ -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, }; /** @@ -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] ?? {}; diff --git a/frontend/src/gql/graphql.ts b/frontend/src/gql/graphql.ts index 22711e7..b6e614d 100644 --- a/frontend/src/gql/graphql.ts +++ b/frontend/src/gql/graphql.ts @@ -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; } }; @@ -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; }; @@ -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']; @@ -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; @@ -107,6 +128,18 @@ export type QueryTimeEntryArgs = { id: Scalars['ID']['input']; }; +export type RequestPasswordResetPayload = { + __typename?: 'RequestPasswordResetPayload'; + /** @deprecated reserved for future use. Use __typename */ + _?: Maybe; +}; + +export type ResetPasswordPayload = { + __typename?: 'ResetPasswordPayload'; + /** @deprecated reserved for future use. Use __typename */ + _?: Maybe; +}; + export type SignInPayload = { __typename?: 'SignInPayload'; token: Scalars['String']['output']; @@ -135,6 +168,11 @@ export type TimeEntryConnection = { edges: Array; }; +export type UpdateMorningRecapOptInPayload = { + __typename?: 'UpdateMorningRecapOptInPayload'; + user: User; +}; + export type UpdateProjectInput = { color?: InputMaybe; name?: InputMaybe; @@ -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; }>; @@ -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']; }>; @@ -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; 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; 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; -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; \ No newline at end of file +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; \ No newline at end of file diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index 368d14a..948d5af 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -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) }