diff --git a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/InstructorController.java b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/InstructorController.java index 0e6b9d5..fa531b5 100644 --- a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/InstructorController.java +++ b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/InstructorController.java @@ -23,9 +23,9 @@ public ResponseEntity getInstructorInfo( return ResponseEntity.ok(instructorService.findInstructorDtoByInstructorEmail(email)); } - @PostMapping("/instructor/paypal") - public ResponseEntity addPayPalEmail(@RequestHeader(value = "Authorization") String instructorToken, - @RequestParam(value = "paypalEmail") String paypalEmail){ + @GetMapping("/instructor/paypal") + public ResponseEntity addPayPalEmail(@RequestHeader(value = "Authorization", defaultValue = "") String instructorToken, + @RequestParam String paypalEmail){ String email = jwtService.extractUserEmail(instructorToken.substring(7)); return ResponseEntity.ok(instructorService.addInstructorPayPalEmail(email,paypalEmail)); } diff --git a/frontend/my-app/src/lib/types.ts b/frontend/my-app/src/lib/types.ts index 4d92489..e16e69e 100644 --- a/frontend/my-app/src/lib/types.ts +++ b/frontend/my-app/src/lib/types.ts @@ -1,10 +1,26 @@ import { type } from "os"; +export type MonthlyData = { + year?: number | null; + firstMonth: number; + secondMonth: number; + thirdMonth: number; + fourthMonth: number; + fifthMonth: number; + sixthMonth: number; + seventhMonth: number; + eighthMonth: number; + ninthMonth: number; + tenthMonth: number; + eleventhMonth: number; + twelfthMonth: number; +} export type InstructorInfo = { id: number; fullName: string; specialization:string; phone:number; avatar:string; + paypalEmail:string; }; export type InstructorSalary = { instructorInfo: InstructorInfo; diff --git a/frontend/my-app/src/routes/CourseCard.svelte b/frontend/my-app/src/routes/CourseCard.svelte index 3d5137d..046ba88 100644 --- a/frontend/my-app/src/routes/CourseCard.svelte +++ b/frontend/my-app/src/routes/CourseCard.svelte @@ -14,6 +14,7 @@ export let isFetchManual: boolean; import { Card, Rating, Badge } from "flowbite-svelte"; let open = true; + let tmpRating: number; let counter = 6; let message = ""; let errorMsg = ""; @@ -91,7 +92,10 @@ await axios .get(apiBaseUrl + `review/rating?courseID=${id}`) .then((response) => { - if (response.status === 200) rating = response.data; + if (response.status === 200){ + tmpRating = response.data; + rating = parseFloat(tmpRating.toFixed(1)); + } }); } let status = false; @@ -146,7 +150,7 @@ - {rating.toFixed(1)} + {rating}
- {#if jwtData.role == "CUSTOMER"} + {#if jwtData.role === "CUSTOMER"} My Learning Your Cart + {:else if jwtData.role === "STAFF"} + Staff Management Dashboard {:else} Assign Instructor {/if} @@ -136,7 +138,7 @@ - User + {jwtData.role} {jwtData.email} diff --git a/frontend/my-app/src/routes/RevenueStatistics.svelte b/frontend/my-app/src/routes/RevenueStatistics.svelte index fa74536..32f106e 100644 --- a/frontend/my-app/src/routes/RevenueStatistics.svelte +++ b/frontend/my-app/src/routes/RevenueStatistics.svelte @@ -1,148 +1,269 @@ - - - -
-
-
- -
-
-
3.4k
-

Leads generated per week

+ const currentYear = new Date().getFullYear(); + const LastYear = currentYear - 1; + const TwoYearsAgo = currentYear - 2; + async function GetMonthlyData(getYear: number) { + let res; + // let year = $page.url.searchParams.get("year"); + console.log(getYear) + res = axios + .get(apiBaseUrl + `transaction/revenue`, { + params: { + year: getYear, + }, + }) + .then((response: AxiosResponse) => { + if (response.status === 200) { + monthlySalary = response.data; + console.log(monthlySalary); + options.series[0].data = [ + { x: "Jan", y: monthlySalary.firstMonth }, + { x: "Feb", y: monthlySalary.secondMonth }, + { x: "Mar", y: monthlySalary.thirdMonth }, + { x: "Apr", y: monthlySalary.fourthMonth }, + { x: "May", y: monthlySalary.fifthMonth }, + { x: "Jun", y: monthlySalary.sixthMonth }, + { x: "Jul", y: monthlySalary.seventhMonth }, + { x: "Aug", y: monthlySalary.eighthMonth }, + { x: "Sep", y: monthlySalary.ninthMonth }, + { x: "Oct", y: monthlySalary.tenthMonth }, + { x: "Nov", y: monthlySalary.eleventhMonth }, + { x: "Dec", y: monthlySalary.twelfthMonth }, + ]; + + totalRevenue = CurrencyHandler(monthlySalary.firstMonth + + monthlySalary.secondMonth + + monthlySalary.thirdMonth + + monthlySalary.fourthMonth + + monthlySalary.fifthMonth + + monthlySalary.sixthMonth + + monthlySalary.seventhMonth + + monthlySalary.eighthMonth + + monthlySalary.ninthMonth + + monthlySalary.tenthMonth + + monthlySalary.eleventhMonth + + monthlySalary.twelfthMonth); + + } + }) + .catch((error: AxiosError) => { + console.log(error); + }); + } + + onMount(() => { + GetMonthlyData(currentYear); + }); + + + +
+
+
+ +
+
+
+ 3.4k +
+

+ Leads generated per week +

+
-
-
- - - 42.5% - -
+
-
-
Money spent:
-
$3,232
-
-
-
Conversion rate:
-
1.2%
-
+
+
+ Money spent: +
+
+ {totalRevenue} +
+
+
-
-
- - - Yesterday - Today - Last 7 days - Last 30 days - Last 90 days - - - Leads Report - - -
+
+
+ + + {GetMonthlyData(currentYear)}}>This Year + {GetMonthlyData(LastYear)}}>Last Year + {GetMonthlyData(TwoYearsAgo)}}>2 Years Ago + + + Leads Report + + +
- \ No newline at end of file + diff --git a/frontend/my-app/src/routes/instructor/+page.svelte b/frontend/my-app/src/routes/instructor/+page.svelte index c4166a5..e2f134e 100644 --- a/frontend/my-app/src/routes/instructor/+page.svelte +++ b/frontend/my-app/src/routes/instructor/+page.svelte @@ -1,28 +1,22 @@