Skip to content

Commit

Permalink
Merge pull request #37 from avantifellows/feat/added-test-attempted-d…
Browse files Browse the repository at this point in the history
…ate-in-reports

Feat: Added test attempted date
  • Loading branch information
Bahugunajii authored Mar 19, 2024
2 parents ab45688 + 503d386 commit 9b1b264
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/reports/reports_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getReports } from "@/api/reporting/reports";
import { ReportsListProps } from "../types";
import { MixpanelTracking } from "@/services/mixpanel";
import { MIXPANEL_EVENT } from "@/constants/config";
import { formatDate } from "@/utils/dateUtils";

export default function ReportsList({ userId }: ReportsListProps) {
const [responseData, setResponseData] = useState<{ reports: Report[] } | null>(null);
Expand Down Expand Up @@ -37,7 +38,7 @@ export default function ReportsList({ userId }: ReportsListProps) {
<div className={`${index % 2 === 0 ? 'bg-orange-200' : 'bg-red-200'} h-full w-2 absolute left-0 top-0 rounded-s-md`}></div>
<div className="text-left mx-6 md:mx-8">
<p className="text-sm md:text-base font-semibold">{report.test_name}</p>
<p className="text-gray-700 text-sm md:text-base mt-2">Rank: {report.rank}</p>
<p className="text-gray-700 text-sm md:text-base mt-2">Date attempted: {formatDate(report.start_date) ?? "Date not available"}</p>
</div>
</Link>
))}
Expand Down
1 change: 1 addition & 0 deletions app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Report {
test_name: string;
rank: string;
report_link: string;
start_date: string;
};

export interface PrimaryButton {
Expand Down
6 changes: 6 additions & 0 deletions utils/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ export function isSessionActive(endTime: string): boolean {
const currentTimeObj = new Date(`2000-01-01T${currentTimeStr}`);
return sessionEndTime.getTime() > currentTimeObj.getTime();
}

export function formatDate(dateStr: string): string {
const [year, month, day] = dateStr.split('-');
return `${day}-${month}-${year}`;
}

0 comments on commit 9b1b264

Please sign in to comment.