diff --git a/backend/models/responses/stats.go b/backend/models/responses/stats.go index dd9f52f..5e9462c 100644 --- a/backend/models/responses/stats.go +++ b/backend/models/responses/stats.go @@ -1,16 +1,17 @@ package responses type Stats struct { - TotalJobs int `json:"totalJobs"` - Current StatTrack `json:"current"` - Historical StatTrack `json:"historical"` + Total int `json:"total"` + Current Stat `json:"current"` + Historical Stat `json:"historical"` } -type StatTrack struct { +type Stat struct { Applied int `json:"applied"` Interview int `json:"interview"` Offer int `json:"offer"` Rejected int `json:"rejected"` Other int `json:"other"` Accepted int `json:"accepted"` + Withdrawn int `json:"withdrawn"` } diff --git a/backend/services/job_service.go b/backend/services/job_service.go index b61be99..983ad53 100644 --- a/backend/services/job_service.go +++ b/backend/services/job_service.go @@ -114,10 +114,11 @@ func (s *JobService) CreateNewJob(ctx context.Context, userId string, job reques errChan <- err return } - mimeType = "png" + mimeType = "image/png" } - filename := fmt.Sprintf("%s/%s.%s", userId, jobEntity.Id, mimeType) + extension := strings.Split(mimeType, "/")[1] + filename := fmt.Sprintf("%s/%s.%s", userId, jobEntity.Id, extension) downloadUrl, err := s.Storage.UploadFile(ctx, filename, b) if err != nil { log.Println("Error uploading image: ", err) @@ -236,6 +237,8 @@ func (s *JobService) GetStats(ctx context.Context, userId string) (responses.Sta stats.Current.Rejected++ case "accepted": stats.Current.Accepted++ + case "withdrawn": + stats.Current.Withdrawn++ default: stats.Current.Other++ } @@ -256,13 +259,15 @@ func (s *JobService) GetStats(ctx context.Context, userId string) (responses.Sta stats.Historical.Rejected++ case "accepted": stats.Historical.Accepted++ + case "withdrawn": + stats.Historical.Withdrawn++ default: stats.Historical.Other++ } } } - stats.TotalJobs = len(jobs) + stats.Total = len(jobs) return stats, nil } diff --git a/extension/src/pages/popup/hooks/use-screenshot.hook.ts b/extension/src/pages/popup/hooks/use-screenshot.hook.ts index 0cb0699..ac7bb89 100644 --- a/extension/src/pages/popup/hooks/use-screenshot.hook.ts +++ b/extension/src/pages/popup/hooks/use-screenshot.hook.ts @@ -28,7 +28,10 @@ const useScreenshot = () => { await chrome.scripting.executeScript({ target: { tabId: activeTab.id }, - function: () => window.scrollTo(0, 0), + function: async () => { + window.scrollTo({ top: 0, left: 0, behavior: "instant" }); + await new Promise((resolve) => setTimeout(resolve, 100)); + }, }); async function captureScreenshot() { @@ -63,7 +66,7 @@ const useScreenshot = () => { } } - captureScreenshot(); + await captureScreenshot(); setCapturing(false); } diff --git a/extension/src/pages/popup/routes/jobs/add.lazy.tsx b/extension/src/pages/popup/routes/jobs/add.lazy.tsx index c18f1d7..815dbc5 100644 --- a/extension/src/pages/popup/routes/jobs/add.lazy.tsx +++ b/extension/src/pages/popup/routes/jobs/add.lazy.tsx @@ -8,13 +8,15 @@ import { import { createLazyFileRoute } from "@tanstack/react-router"; import useMessage from "@pages/popup/hooks/use-message.hook"; import useScreenshot from "@pages/popup/hooks/use-screenshot.hook"; -import { Aperture } from "lucide-react"; +import { Aperture, Loader2 } from "lucide-react"; +import { useState } from "react"; export const Route = createLazyFileRoute("/jobs/add")({ component: AddJob, }); function AddJob() { + const [capturing, setCapturing] = useState(false); const { captureFullPageScreenshot, canvasRef } = useScreenshot(); const { data: token } = useMessage({ type: "userToken" }); @@ -22,8 +24,10 @@ function AddJob() { useAddJob(token); const onCapture = () => { + setCapturing(true); captureFullPageScreenshot((dataUrl) => { setJobImage(dataUrl); + setCapturing(false); }); }; @@ -38,12 +42,13 @@ function AddJob() { +
+ + + + + ); +} + +interface StatRowProps { + stat: StatResponse; +} + +const StatRow: React.FC = ({ stat }) => { + return ( +
+

+ Applied {stat.applied} +

+

+ Interview {stat.interview} +

+

+ Offer {stat.offer} +

+

+ Rejected {stat.rejected} +

+

+ Other {stat.other} +

+

+ Accepted {stat.accepted} +

+

+ Withdrawn {stat.withdrawn} +

+
+ ); +};