Skip to content

Commit 2fd4086

Browse files
authored
Merge pull request #17 from teacoder-team/dev
Dev
2 parents 21f577d + 363aebb commit 2fd4086

11 files changed

Lines changed: 96 additions & 27 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Generated by orval v7.4.1 🍺
3+
* Do not edit manually.
4+
* TeaCoder API
5+
* API for Teacoder educational platform
6+
* OpenAPI spec version: 1.0.0
7+
*/
8+
9+
export interface GenerateDownloadLinkResponse {
10+
/** URL to download the course */
11+
url: string;
12+
}

src/api/generated/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ export * from './createRestrictionRequestReason';
2525
export * from './createUserRequest';
2626
export * from './createUserResponse';
2727
export * from './extensionOptions';
28+
export * from './generateDownloadLinkResponse';
2829
export * from './generatePasskeyOptionsResponse';
2930
export * from './generatePasskeyOptionsResponseExcludeCredentialsItem';
3031
export * from './initPaymentRequest';
3132
export * from './initPaymentRequestMethod';
33+
export * from './initPaymentResponse';
3234
export * from './lastLessonResponse';
3335
export * from './leaderResponse';
3436
export * from './lessonResponse';

src/api/generated/initPaymentRequest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
* API for Teacoder educational platform
66
* OpenAPI spec version: 1.0.0
77
*/
8-
import type { InitPaymentRequestMethod } from './initPaymentRequestMethod'
8+
import type { InitPaymentRequestMethod } from './initPaymentRequestMethod';
99

1010
export interface InitPaymentRequest {
11-
method: InitPaymentRequestMethod
11+
/** Payment method */
12+
method: InitPaymentRequestMethod;
1213
}

src/api/generated/initPaymentRequestMethod.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
* OpenAPI spec version: 1.0.0
77
*/
88

9+
/**
10+
* Payment method
11+
*/
912
export type InitPaymentRequestMethod = typeof InitPaymentRequestMethod[keyof typeof InitPaymentRequestMethod];
1013

1114

1215
// eslint-disable-next-line @typescript-eslint/no-redeclare
1316
export const InitPaymentRequestMethod = {
1417
BANK_CARD: 'BANK_CARD',
1518
SBP: 'SBP',
19+
YOOMONEY: 'YOOMONEY',
1620
CRYPTO: 'CRYPTO',
1721
} as const;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Generated by orval v7.4.1 🍺
3+
* Do not edit manually.
4+
* TeaCoder API
5+
* API for Teacoder educational platform
6+
* OpenAPI spec version: 1.0.0
7+
*/
8+
9+
export interface InitPaymentResponse {
10+
/** URL to complete the payment */
11+
url: string;
12+
}

src/api/generated/ssoConnectResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
*/
88

99
export interface SsoConnectResponse {
10-
/** The URL for authorization via the external provider (e.g., Google, GitHub) */
11-
url: string
10+
/** The URL for authorization via the external provider (e.g., Google, GitHub) */
11+
url: string;
1212
}

src/components/course/course-actions.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ export function CourseActions({ course }: CourseActionsProps) {
2929
})
3030

3131
const handleDownload = async () => {
32-
// if (!isAuthorized || !user?.isPremium)
33-
// return router.push(ROUTES.PREMIUM)
34-
35-
if (!isAuthorized) return router.push('/auth/login')
32+
if (!isAuthorized || !user?.isPremium)
33+
return router.push(ROUTES.PREMIUM)
3634

3735
try {
3836
const { url } = await generate(course.id)

src/components/icons/sbp-icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SVGProps } from 'react'
1+
import type { SVGProps } from 'react'
22

33
interface SbpIconProps extends SVGProps<SVGSVGElement> {}
44

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { SVGProps } from 'react'
2+
3+
interface YoomoneyIconProps extends SVGProps<SVGSVGElement> {}
4+
5+
export function YoomoneyIcon({ ...props }: YoomoneyIconProps) {
6+
return (
7+
<svg
8+
width='2861'
9+
height='2031'
10+
viewBox='0 0 2861 2031'
11+
fill='none'
12+
xmlns='http://www.w3.org/2000/svg'
13+
{...props}
14+
>
15+
<path
16+
d='M1844.91 0C1279.2 0 829.27 456.278 829.27 1015.42C829.27 1581.01 1285.65 2030.84 1844.91 2030.84C2404.12 2030.84 2860.55 1574.56 2860.55 1015.42C2860.55 456.278 2404.12 0 1844.91 0ZM1844.91 1388.18C1639.19 1388.18 1465.57 1214.64 1465.57 1008.97C1465.57 803.348 1639.19 629.813 1844.91 629.813C2050.58 629.813 2224.15 803.348 2224.15 1008.97C2217.7 1221.09 2050.58 1388.18 1844.86 1388.18H1844.91ZM822.821 289.191V1767.34H462.776L0 289.191H822.821Z'
17+
fill='currentColor'
18+
/>
19+
</svg>
20+
)
21+
}

src/components/premium/payment-methods.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,52 @@ import { ComponentType, SVGProps } from 'react'
33
import { Control } from 'react-hook-form'
44

55
import { SbpIcon } from '../icons/sbp-icon'
6+
import { YoomoneyIcon } from '../icons/yoomoney-icon'
67

78
import type { PaymentFormValues } from './premium'
9+
import { InitPaymentRequestMethod } from '@/src/api/generated'
810
import { FormControl, FormField, FormItem } from '@/src/components/ui/form'
911
import { Label } from '@/src/components/ui/label'
1012
import { RadioGroup, RadioGroupItem } from '@/src/components/ui/radio-group'
1113
import { cn } from '@/src/lib/utils'
1214

1315
interface PaymentMethod {
14-
id: string
16+
id: InitPaymentRequestMethod
1517
name: string
1618
description: string
1719
icon: ComponentType<SVGProps<SVGSVGElement>>
1820
textColor: string
1921
bgColor: string
22+
isAllowed?: boolean
2023
}
2124

2225
const paymentMethods: PaymentMethod[] = [
2326
{
24-
id: 'BANK_CARD',
27+
id: InitPaymentRequestMethod.BANK_CARD,
2528
name: 'Банковская карта',
2629
description: 'Оплата кредитной или дебетовой карты',
2730
icon: CreditCardIcon,
2831
textColor: 'text-blue-600',
29-
bgColor: 'bg-blue-100'
32+
bgColor: 'bg-blue-100',
33+
isAllowed: true
3034
},
3135
{
32-
id: 'SBP',
36+
id: InitPaymentRequestMethod.SBP,
3337
name: 'СБП',
3438
description: 'Оплата через Систему быстрых платежей',
3539
icon: SbpIcon,
3640
textColor: 'text-blue-600',
37-
bgColor: 'bg-blue-100'
41+
bgColor: 'bg-blue-100',
42+
isAllowed: false
43+
},
44+
{
45+
id: InitPaymentRequestMethod.YOOMONEY,
46+
name: 'ЮMoney',
47+
description: 'Оплата через кошелек ЮMoney',
48+
icon: YoomoneyIcon,
49+
textColor: 'text-blue-600',
50+
bgColor: 'bg-blue-100',
51+
isAllowed: false
3852
}
3953
// {
4054
// id: 'CRYPTO',
@@ -72,9 +86,11 @@ export function PaymentMethods({ control }: PaymentMethodsProps) {
7286
htmlFor={method.id}
7387
className={cn(
7488
'flex cursor-pointer items-center gap-3 rounded-xl border p-3.5 transition-all duration-200',
75-
isSelected
76-
? 'border-blue-500 bg-blue-50 dark:border-border dark:bg-neutral-800'
77-
: 'border-gray-200 bg-white hover:border-gray-300 dark:border-gray-700 dark:bg-background'
89+
!method.isAllowed
90+
? 'cursor-not-allowed opacity-50'
91+
: isSelected
92+
? 'border-blue-500 bg-blue-50 dark:border-border dark:bg-neutral-800'
93+
: 'border-gray-200 bg-white hover:border-gray-300 dark:border-gray-700 dark:bg-background'
7894
)}
7995
>
8096
<div
@@ -119,6 +135,7 @@ export function PaymentMethods({ control }: PaymentMethodsProps) {
119135
<RadioGroupItem
120136
value={method.id}
121137
id={method.id}
138+
disabled={!method.isAllowed}
122139
className='sr-only'
123140
/>
124141
</Label>

0 commit comments

Comments
 (0)