File tree Expand file tree Collapse file tree 8 files changed +38
-4
lines changed Expand file tree Collapse file tree 8 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ export function useFindTutorActivityScore(id: number | null): {
130130type IForm = {
131131 bio : string ;
132132 about : string ;
133+ price : number ;
133134} ;
134135
135136export function useIntroduceTutor ( {
@@ -149,6 +150,7 @@ export function useIntroduceTutor({
149150 return await api . user . update ( profile . id , {
150151 bio : fields . bio ,
151152 about : fields . about ,
153+ price : fields . price ,
152154 } ) ;
153155 } ,
154156 [ api . user , profile ]
Original file line number Diff line number Diff line change 1+ import { MigrationBuilder } from "node-pg-migrate" ;
2+
3+ export async function up ( pgm : MigrationBuilder ) : Promise < void > {
4+ pgm . addColumn ( "tutors" , {
5+ price : {
6+ type : "int" ,
7+ notNull : false ,
8+ } ,
9+ } ) ;
10+ }
11+
12+ export async function down ( pgm : MigrationBuilder ) : Promise < void > {
13+ pgm . dropColumn ( "tutors" , "price" ) ;
14+ }
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ const fullTutorFields: FullTutorFieldsMap = {
5555 thumbnail : tutorColumn ( "thumbnail" ) ,
5656 notice : tutorColumn ( "notice" ) ,
5757 activated : tutorColumn ( "activated" ) ,
58+ price : tutorColumn ( "price" ) ,
5859 bypass_onboarding : tutorColumn ( "bypass_onboarding" ) ,
5960} as const ;
6061
@@ -85,6 +86,7 @@ export class Tutors {
8586 . update ( {
8687 bio : payload . bio ,
8788 about : payload . about ,
89+ price : payload . price ,
8890 video : payload . video ,
8991 notice : payload . notice ,
9092 thumbnail : payload . thumbnail ,
@@ -507,6 +509,7 @@ export class Tutors {
507509 id : row . id ,
508510 bio : row . bio ,
509511 about : row . about ,
512+ price : row . price ,
510513 video : row . video ,
511514 thumbnail : row . thumbnail ,
512515 studioId : row . studio_id ,
@@ -543,6 +546,7 @@ export class Tutors {
543546 id : row . id ,
544547 bio : row . bio ,
545548 about : row . about ,
549+ price : row . price ,
546550 video : row . video ,
547551 thumbnail : row . thumbnail ,
548552 studioId : row . studio_id ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export type Self = {
55 id : number ;
66 bio : string | null ;
77 about : string | null ;
8+ price : number | null ;
89 video : string | null ;
910 studioId : number | null ;
1011 thumbnail : string | null ;
@@ -74,6 +75,7 @@ export type Row = {
7475 notice : number ;
7576 bio : string | null ;
7677 about : string | null ;
78+ price : number | null ;
7779 video : string | null ;
7880 role : IUser . Role ;
7981 activated : boolean ;
@@ -95,6 +97,7 @@ export type TutorMedia = {
9597export type UpdatePayload = {
9698 bio ?: string | null ;
9799 about ?: string | null ;
100+ price ?: number | null ;
98101 video ?: string | null ;
99102 thumbnail ?: string | null ;
100103 studioId ?: number | null ;
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ export type UpdateApiPayload = {
156156 video ?: null ;
157157 bio ?: string | null ;
158158 about ?: string | null ;
159+ price ?: number | null ;
159160 phone ?: string | null ;
160161 city ?: City | null ;
161162 studioId ?: number | null ;
Original file line number Diff line number Diff line change 1- import { ILesson } from "@litespace/types" ;
1+ import { ILesson , ITutor } from "@litespace/types" ;
22import { MINUTES_IN_HOUR , TOTAL_LESSON_HOURLY_RATE } from "@/constants" ;
33import { sumBy } from "lodash" ;
44
55/**
66 * @param duration {ILesson.Duration}
77 * @returns scaled lesson price
88 */
9- export function calculateLessonPrice ( duration : ILesson . Duration ) : number {
10- return Math . floor ( ( duration / MINUTES_IN_HOUR ) * TOTAL_LESSON_HOURLY_RATE ) ;
9+ export function calculateLessonPrice (
10+ duration : ILesson . Duration ,
11+ tutor ?: ITutor . Self
12+ ) : number {
13+ return Math . floor (
14+ ( duration / MINUTES_IN_HOUR ) * ( tutor ?. price ?? TOTAL_LESSON_HOURLY_RATE )
15+ ) ;
1116}
1217
1318export function sumLessonsDuration ( lessons : ILesson . Self [ ] ) : number {
Original file line number Diff line number Diff line change @@ -276,6 +276,7 @@ function update(_: ApiContext) {
276276 video,
277277 bio,
278278 about,
279+ price,
279280 notice,
280281 studioId,
281282 phone,
@@ -382,6 +383,7 @@ function update(_: ApiContext) {
382383 const updateTutorPayload : ITutor . UpdatePayload = {
383384 bio,
384385 about,
386+ price,
385387 notice,
386388 studioId,
387389 video,
Original file line number Diff line number Diff line change @@ -374,10 +374,13 @@ export async function createLesson({
374374 slotId,
375375 start,
376376 duration,
377+ price,
377378 } ) ;
378379 if ( tutor instanceof Error ) return tutor ;
379380
380- const price = isTutorManager ( tutor ) ? 0 : calculateLessonPrice ( duration ) ;
381+ const price = isTutorManager ( tutor )
382+ ? 0
383+ : calculateLessonPrice ( duration , tutor . price ) ;
381384
382385 // Create the lesson with its associated room if it doesn't exist
383386 const roomMembers = [ userId , tutorId ] ;
You can’t perform that action at this time.
0 commit comments