fix telegramId type (number)

This commit is contained in:
vchikalkin 2025-05-16 20:06:09 +03:00
parent c91a188761
commit 35134e9663
10 changed files with 19 additions and 16 deletions

View File

@ -21,7 +21,7 @@ export default function Auth() {
signIn('telegram', {
callbackUrl: '/profile',
redirect: false,
telegramId: String(user?.id),
telegramId: user?.id,
});
});
}

View File

@ -28,7 +28,7 @@ function useAuth() {
signIn('telegram', {
callbackUrl: '/profile',
redirect: false,
telegramId: String(initDataUser.id),
telegramId: initDataUser.id,
}).then(() => redirect('/profile'));
}
}, [initDataUser?.id, status]);

View File

@ -7,7 +7,7 @@ type Props = { params: Promise<{ telegramId: string }> };
export default async function ProfilePage(props: Readonly<Props>) {
const parameters = await props.params;
const { telegramId } = parameters;
const telegramId = Number.parseInt(parameters.telegramId, 10);
const queryClient = new QueryClient();

View File

@ -1,3 +1,3 @@
export type ProfileProps = {
readonly telegramId?: string;
readonly telegramId?: number;
};

View File

@ -12,7 +12,7 @@ export const authOptions: AuthOptions = {
},
async session({ session, token }) {
if (token?.id && session?.user) {
session.user.telegramId = token.id as string;
session.user.telegramId = token.id as number;
}
return session;

View File

@ -5,7 +5,7 @@ import { env } from '@/config/env';
export async function getTelegramUser() {
if (process.env.NODE_ENV !== 'production')
return {
id: env.__DEV_TELEGRAM_ID,
id: Number.parseInt(env.__DEV_TELEGRAM_ID, 10),
};
return null;

View File

@ -4,11 +4,11 @@ import { type DefaultSession } from 'next-auth';
declare module 'next-auth' {
interface Session extends DefaultSession {
user?: {
telegramId?: null | string;
telegramId?: null | number;
};
}
interface User extends DefaultUser {
telegramId?: null | string;
telegramId?: null | number;
}
}

View File

@ -1,5 +1,5 @@
type CustomerProfile = {
telegramId: string;
telegramId: number;
};
export class BaseService {

View File

@ -5,9 +5,12 @@ module.exports = {
'./types/operations.generated.ts': {
config: {
avoidOptionals: false,
maybeValue: 'T | null | undefined',
onlyOperationTypes: true,
scalars: {
Long: 'number',
},
useTypeImports: true,
maybeValue: 'T | null | undefined'
},
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
},

View File

@ -16,7 +16,7 @@ export type Scalars = {
Date: { input: any; output: any; }
DateTime: { input: any; output: any; }
JSON: { input: any; output: any; }
Long: { input: any; output: any; }
Long: { input: number; output: number; }
Time: { input: any; output: any; }
};
@ -651,7 +651,7 @@ export type LoginMutationVariables = Exact<{
export type LoginMutation = { __typename?: 'Mutation', login: { __typename?: 'UsersPermissionsLoginPayload', jwt?: string | null | undefined } };
export type CustomerFieldsFragment = { __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: any | null | undefined };
export type CustomerFieldsFragment = { __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: number | null | undefined };
export type CreateCustomerMutationVariables = Exact<{
name: Scalars['String']['input'];
@ -668,7 +668,7 @@ export type GetCustomerQueryVariables = Exact<{
}>;
export type GetCustomerQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: any | null | undefined } | null | undefined> };
export type GetCustomerQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: number | null | undefined } | null | undefined> };
export type GetCustomerMastersQueryVariables = Exact<{
phone?: InputMaybe<Scalars['String']['input']>;
@ -676,7 +676,7 @@ export type GetCustomerMastersQueryVariables = Exact<{
}>;
export type GetCustomerMastersQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', documentId: string, masters: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: any | null | undefined } | null | undefined> } | null | undefined> };
export type GetCustomerMastersQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', documentId: string, masters: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: number | null | undefined } | null | undefined> } | null | undefined> };
export type GetCustomerClientsQueryVariables = Exact<{
phone?: InputMaybe<Scalars['String']['input']>;
@ -684,7 +684,7 @@ export type GetCustomerClientsQueryVariables = Exact<{
}>;
export type GetCustomerClientsQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', documentId: string, clients: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: any | null | undefined } | null | undefined> } | null | undefined> };
export type GetCustomerClientsQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', documentId: string, clients: Array<{ __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: number | null | undefined } | null | undefined> } | null | undefined> };
export type UpdateCustomerMutationVariables = Exact<{
documentId: Scalars['ID']['input'];
@ -692,7 +692,7 @@ export type UpdateCustomerMutationVariables = Exact<{
}>;
export type UpdateCustomerMutation = { __typename?: 'Mutation', updateCustomer?: { __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: any | null | undefined } | null | undefined };
export type UpdateCustomerMutation = { __typename?: 'Mutation', updateCustomer?: { __typename?: 'Customer', active?: boolean | null | undefined, documentId: string, name: string, phone: string, photoUrl?: string | null | undefined, role: Enum_Customer_Role, telegramId?: number | null | undefined } | null | undefined };
export type OrderFieldsFragment = { __typename?: 'Order', documentId: string, time_start?: any | null | undefined, time_end?: any | null | undefined, state?: Enum_Order_State | null | undefined, order_number?: number | null | undefined, services: Array<{ __typename?: 'Service', documentId: string, name?: string | null | undefined } | null | undefined>, client?: { __typename?: 'Customer', name: string, documentId: string, photoUrl?: string | null | undefined } | null | undefined };