Waseel: driver app, dispatch, POI suggestions, map fixes
This commit is contained in:
+24
-19
@@ -1,3 +1,4 @@
|
||||
import { tr } from "@/lib/i18n";
|
||||
import type { Ride } from "@/types/type";
|
||||
|
||||
export const sortRides = (rides: Ride[]): Ride[] => {
|
||||
@@ -7,36 +8,40 @@ export const sortRides = (rides: Ride[]): Ride[] => {
|
||||
);
|
||||
};
|
||||
|
||||
// Unit words and month names are localized through the module-level translator
|
||||
// in lib/i18n (set by I18nProvider). Until the provider boots, `tr` falls back
|
||||
// to English, so these stay safe to call during the initial render.
|
||||
export function formatTime(minutes: number): string {
|
||||
const formattedMinutes = Math.round(minutes) || 0;
|
||||
|
||||
if (formattedMinutes < 60) {
|
||||
return `${formattedMinutes} min`;
|
||||
} else {
|
||||
const hours = Math.floor(formattedMinutes / 60);
|
||||
const remainingMinutes = formattedMinutes % 60;
|
||||
return `${hours}h ${remainingMinutes}m`;
|
||||
return tr("units.min", {}, formattedMinutes);
|
||||
}
|
||||
|
||||
const hours = Math.floor(formattedMinutes / 60);
|
||||
const remainingMinutes = formattedMinutes % 60;
|
||||
|
||||
return tr("units.hoursMinutes", { h: hours, m: remainingMinutes });
|
||||
}
|
||||
|
||||
export function formatDate(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
const day = date.getDate();
|
||||
const monthNames = [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
const monthKeys = [
|
||||
"months.jan",
|
||||
"months.feb",
|
||||
"months.mar",
|
||||
"months.apr",
|
||||
"months.may",
|
||||
"months.jun",
|
||||
"months.jul",
|
||||
"months.aug",
|
||||
"months.sep",
|
||||
"months.oct",
|
||||
"months.nov",
|
||||
"months.dec",
|
||||
];
|
||||
const month = monthNames[date.getMonth()];
|
||||
const month = tr(monthKeys[date.getMonth()]);
|
||||
const year = date.getFullYear();
|
||||
|
||||
return `${day < 10 ? "0" + day : day} ${month} ${year}`;
|
||||
|
||||
Reference in New Issue
Block a user