diff --git a/app/components/bonus/AccountCard.vue b/app/components/bonus/AccountCard.vue new file mode 100644 index 0000000..46d8be0 --- /dev/null +++ b/app/components/bonus/AccountCard.vue @@ -0,0 +1,95 @@ + + + diff --git a/app/composables/graphql/generated.ts b/app/composables/graphql/generated.ts index e5dd4c7..d7fe0ee 100644 --- a/app/composables/graphql/generated.ts +++ b/app/composables/graphql/generated.ts @@ -176,6 +176,22 @@ export enum LoginChannel { Telegram = 'TELEGRAM' } +export type ManagerBonusAccount = { + __typename?: 'ManagerBonusAccount'; + balance: Scalars['Float']['output']; + companyName?: Maybe; + earnedAmount: Scalars['Float']['output']; + email: Scalars['String']['output']; + fullName: Scalars['String']['output']; + pendingWithdrawalAmount: Scalars['Float']['output']; + pendingWithdrawals: Array; + referralLinks: Array; + referralsCount: Scalars['Int']['output']; + transactions: Array; + transactionsCount: Scalars['Int']['output']; + userId: Scalars['ID']['output']; +}; + export type ManagerBonusBalance = { __typename?: 'ManagerBonusBalance'; balance: Scalars['Float']['output']; @@ -541,6 +557,7 @@ export type Query = { __typename?: 'Query'; clientProducts: Array; healthcheck: Scalars['String']['output']; + managerBonusAccount: ManagerBonusAccount; managerBonusBalances: Array; managerNotificationHistory: Array; managerOrders: Array; @@ -561,6 +578,11 @@ export type Query = { }; +export type QueryManagerBonusAccountArgs = { + userId: Scalars['ID']['input']; +}; + + export type QueryManagerNotificationHistoryArgs = { channel: MessengerType; limit?: InputMaybe; @@ -862,6 +884,13 @@ export type CreateReferralMutationVariables = Exact<{ export type CreateReferralMutation = { __typename?: 'Mutation', createReferral: { __typename?: 'ReferralLink', id: string, referrerId: string, refereeId: string, createdById: string, bonusPercent: number, createdAt: any } }; +export type ManagerBonusAccountQueryVariables = Exact<{ + userId: Scalars['ID']['input']; +}>; + + +export type ManagerBonusAccountQuery = { __typename?: 'Query', managerBonusAccount: { __typename?: 'ManagerBonusAccount', userId: string, email: string, fullName: string, companyName?: string | null, balance: number, earnedAmount: number, pendingWithdrawalAmount: number, transactionsCount: number, referralsCount: number, referralLinks: Array<{ __typename?: 'ManagerReferralLink', id: string, referrerId: string, referrerName: string, referrerEmail: string, referrerCompanyName?: string | null, refereeId: string, refereeName: string, refereeEmail: string, refereeCompanyName?: string | null, createdById: string, bonusPercent: number, createdAt: any }>, transactions: Array<{ __typename?: 'BonusTransaction', id: string, userId: string, amount: number, reason: string, orderId?: string | null, createdAt: any }>, pendingWithdrawals: Array<{ __typename?: 'RewardWithdrawalRequest', id: string, requesterId: string, amount: number, status: WithdrawalStatus, reviewComment?: string | null, createdAt: any, updatedAt: any }> } }; + export type ManagerBonusBalancesQueryVariables = Exact<{ [key: string]: never; }>; @@ -1679,6 +1708,75 @@ export function useCreateReferralMutation(options: VueApolloComposable.UseMutati return VueApolloComposable.useMutation(CreateReferralDocument, options); } export type CreateReferralMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn; +export const ManagerBonusAccountDocument = gql` + query ManagerBonusAccount($userId: ID!) { + managerBonusAccount(userId: $userId) { + userId + email + fullName + companyName + balance + earnedAmount + pendingWithdrawalAmount + transactionsCount + referralsCount + referralLinks { + id + referrerId + referrerName + referrerEmail + referrerCompanyName + refereeId + refereeName + refereeEmail + refereeCompanyName + createdById + bonusPercent + createdAt + } + transactions { + id + userId + amount + reason + orderId + createdAt + } + pendingWithdrawals { + id + requesterId + amount + status + reviewComment + createdAt + updatedAt + } + } +} + `; + +/** + * __useManagerBonusAccountQuery__ + * + * To run a query within a Vue component, call `useManagerBonusAccountQuery` and pass it any options that fit your needs. + * When your component renders, `useManagerBonusAccountQuery` returns an object from Apollo Client that contains result, loading and error properties + * you can use to render your UI. + * + * @param variables that will be passed into the query + * @param options that will be passed into the query, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/query.html#options; + * + * @example + * const { result, loading, error } = useManagerBonusAccountQuery({ + * userId: // value for 'userId' + * }); + */ +export function useManagerBonusAccountQuery(variables: ManagerBonusAccountQueryVariables | VueCompositionApi.Ref | ReactiveFunction, options: VueApolloComposable.UseQueryOptions | VueCompositionApi.Ref> | ReactiveFunction> = {}) { + return VueApolloComposable.useQuery(ManagerBonusAccountDocument, variables, options); +} +export function useManagerBonusAccountLazyQuery(variables?: ManagerBonusAccountQueryVariables | VueCompositionApi.Ref | ReactiveFunction, options: VueApolloComposable.UseQueryOptions | VueCompositionApi.Ref> | ReactiveFunction> = {}) { + return VueApolloComposable.useLazyQuery(ManagerBonusAccountDocument, variables, options); +} +export type ManagerBonusAccountQueryCompositionFunctionResult = VueApolloComposable.UseQueryReturn; export const ManagerBonusBalancesDocument = gql` query ManagerBonusBalances { managerBonusBalances { diff --git a/app/pages/bonus-system/[userId].vue b/app/pages/bonus-system/[userId].vue new file mode 100644 index 0000000..cee26d2 --- /dev/null +++ b/app/pages/bonus-system/[userId].vue @@ -0,0 +1,151 @@ + + + diff --git a/app/pages/bonus-system/index.vue b/app/pages/bonus-system/index.vue index c24d872..b58e54c 100644 --- a/app/pages/bonus-system/index.vue +++ b/app/pages/bonus-system/index.vue @@ -108,6 +108,13 @@ const filteredWithdrawals = computed(() => { .includes(query); }); }); + +function formatAmount(value: number) { + return new Intl.NumberFormat('ru-RU', { + minimumFractionDigits: 0, + maximumFractionDigits: 2, + }).format(value); +} diff --git a/graphql/operations/manager/manager-bonus-account.graphql b/graphql/operations/manager/manager-bonus-account.graphql new file mode 100644 index 0000000..6213a97 --- /dev/null +++ b/graphql/operations/manager/manager-bonus-account.graphql @@ -0,0 +1,44 @@ +query ManagerBonusAccount($userId: ID!) { + managerBonusAccount(userId: $userId) { + userId + email + fullName + companyName + balance + earnedAmount + pendingWithdrawalAmount + transactionsCount + referralsCount + referralLinks { + id + referrerId + referrerName + referrerEmail + referrerCompanyName + refereeId + refereeName + refereeEmail + refereeCompanyName + createdById + bonusPercent + createdAt + } + transactions { + id + userId + amount + reason + orderId + createdAt + } + pendingWithdrawals { + id + requesterId + amount + status + reviewComment + createdAt + updatedAt + } + } +} diff --git a/graphql/schema.graphql b/graphql/schema.graphql index b813dae..5d340bf 100644 --- a/graphql/schema.graphql +++ b/graphql/schema.graphql @@ -327,6 +327,21 @@ type ManagerBonusBalance { transactionsCount: Int! } +type ManagerBonusAccount { + userId: ID! + email: String! + fullName: String! + companyName: String + balance: Float! + earnedAmount: Float! + pendingWithdrawalAmount: Float! + transactionsCount: Int! + referralsCount: Int! + referralLinks: [ManagerReferralLink!]! + transactions: [BonusTransaction!]! + pendingWithdrawals: [RewardWithdrawalRequest!]! +} + type ManagerWithdrawalRequest { id: ID! requesterId: ID! @@ -358,6 +373,7 @@ type Query { managerOrders(status: OrderStatus, customerId: ID): [Order!]! managerReferralLinks: [ManagerReferralLink!]! managerBonusBalances: [ManagerBonusBalance!]! + managerBonusAccount(userId: ID!): ManagerBonusAccount! managerWithdrawalRequests(status: WithdrawalStatus): [ManagerWithdrawalRequest!]! registrationRequests(status: RegistrationStatus): [RegistrationRequest!]! referralStats: ReferralStats!