Waseel: driver app, dispatch, POI suggestions, map fixes

This commit is contained in:
Krikorios
2026-08-25 02:57:49 +03:00
parent 899ca93cd5
commit 1d84003e0a
50 changed files with 3625 additions and 625 deletions
+51 -49
View File
@@ -18,11 +18,13 @@ import { OAuth } from "@/components/oauth";
import { OtpField } from "@/components/otp-field";
import { icons, images } from "@/constants";
import { ApiError, fetchAPI } from "@/lib/fetch";
import { useT } from "@/lib/i18n";
import { getRememberedEmail, rememberEmail, useSession } from "@/lib/session";
const SignIn = () => {
const router = useRouter();
const { setSession } = useSession();
const t = useT();
const [form, setForm] = useState({
email: "",
password: "",
@@ -84,7 +86,7 @@ const SignIn = () => {
const onRequestReset = async () => {
if (!reset.email.trim()) {
setReset((prev) => ({ ...prev, error: "Enter your email address." }));
setReset((prev) => ({ ...prev, error: t("auth.signIn.errEmail") }));
return;
}
@@ -112,14 +114,14 @@ const SignIn = () => {
const onSubmitReset = async () => {
if (!/^\d{6}$/.test(reset.code)) {
setReset((prev) => ({ ...prev, error: "Enter the 6-digit code." }));
setReset((prev) => ({ ...prev, error: t("auth.signIn.errCode") }));
return;
}
if (reset.password.length < 8) {
setReset((prev) => ({
...prev,
error: "Password must be at least 8 characters.",
error: t("auth.signIn.errPassword"),
}));
return;
}
@@ -148,7 +150,7 @@ const SignIn = () => {
error:
err instanceof ApiError && err.status < 500
? err.message
: "Could not reset your password. Please try again.",
: t("auth.signIn.errReset"),
}));
}
};
@@ -160,8 +162,8 @@ const SignIn = () => {
// otherwise surfaces as a generic "could not sign in".
if (!form.email.trim() || !form.password) {
Alert.alert(
"Missing information",
"Enter both your email and your password.",
t("auth.signIn.alertMissingTitle"),
t("auth.signIn.alertMissingBody"),
);
return;
}
@@ -186,9 +188,9 @@ const SignIn = () => {
const message =
err instanceof ApiError && err.status < 500
? err.message
: "Could not sign in. Please try again.";
: t("auth.signIn.alertErrorFallback");
Alert.alert("Error", message);
Alert.alert(t("auth.signIn.alertErrorTitle"), message);
// Only a rejected password is worth retyping. Clearing it after a
// network blip or a 403 just makes the next attempt fail differently.
@@ -198,38 +200,38 @@ const SignIn = () => {
} finally {
setBusy(false);
}
}, [busy, form.email, form.password, remember, setSession, router]);
}, [busy, form.email, form.password, remember, setSession, router, t]);
return (
<KeyboardAvoidingView
className="flex-1 bg-white"
className="flex-1 bg-white dark:bg-neutral-950"
behavior={Platform.OS === "ios" ? "padding" : "height"}
keyboardVerticalOffset={Platform.OS === "ios" ? 40 : 0}
>
<ScrollView
className="flex-1 bg-white"
className="flex-1 bg-white dark:bg-neutral-950"
keyboardShouldPersistTaps="handled"
contentContainerStyle={{ flexGrow: 1 }}
showsVerticalScrollIndicator={false}
>
<View className="flex-1 bg-white">
<View className="flex-1 bg-white dark:bg-neutral-950">
<View className="relative w-full h-[250px]">
<Image
source={images.signUpCar}
alt="Car"
alt={t("auth.signIn.carAlt")}
className="z-0 w-full h-[250px]"
resizeMode="contain"
/>
<Text className="text-2xl text-black font-JakartaSemiBold absolute bottom-5 left-5">
Welcome 👋
<Text className="text-2xl text-black dark:text-white font-JakartaSemiBold absolute bottom-5 left-5">
{t("auth.signIn.welcome")}
</Text>
</View>
<View className="p-5">
<InputField
label="Email"
placeholder="karim@email.com"
label={t("auth.signIn.email")}
placeholder={t("auth.signIn.emailPlaceholder")}
icon={icons.email}
value={form.email}
onChangeText={(value) =>
@@ -244,8 +246,8 @@ const SignIn = () => {
/>
<InputField
label="Password"
placeholder="••••••••"
label={t("auth.signIn.password")}
placeholder={t("auth.signIn.passwordPlaceholder")}
icon={icons.lock}
secureTextEntry
value={form.password}
@@ -270,7 +272,7 @@ const SignIn = () => {
className={`h-6 w-6 rounded-md items-center justify-center border-2 ${
remember
? "bg-primary-500 border-primary-500"
: "bg-white border-neutral-300"
: "bg-white dark:bg-neutral-900 border-neutral-300 dark:border-neutral-700"
}`}
>
{remember ? (
@@ -278,13 +280,13 @@ const SignIn = () => {
) : null}
</View>
<Text className="ml-3 font-JakartaMedium text-[15px] text-black">
Keep me signed in
<Text className="ml-3 font-JakartaMedium text-[15px] text-black dark:text-white">
{t("auth.signIn.keepSignedIn")}
</Text>
</TouchableOpacity>
<CustomButton
title={busy ? "Signing in…" : "Sign In"}
title={busy ? t("auth.signIn.signingIn") : t("auth.signIn.signInBtn")}
onPress={onSignInPress}
disabled={busy}
className="mt-6"
@@ -292,18 +294,18 @@ const SignIn = () => {
<TouchableOpacity onPress={openReset} className="mt-4">
<Text className="text-primary-500 text-center font-JakartaMedium">
Forgot password?
{t("auth.signIn.forgotPassword")}
</Text>
</TouchableOpacity>
<OAuth title="Sign in with Google" />
<OAuth title={t("auth.signIn.signInGoogle")} />
<Link
href="/sign-up"
className="text-base text-center text-general-200 mt-10"
className="text-base text-center text-general-200 dark:text-neutral-400 mt-10"
>
<Text>Don&apos;t have an account? </Text>
<Text className="text-primary-500">Sign up</Text>
<Text className="text-black dark:text-white">{t("auth.signIn.noAccount")}</Text>
<Text className="text-primary-500">{t("auth.signIn.signUpLink")}</Text>
</Link>
</View>
@@ -311,18 +313,18 @@ const SignIn = () => {
isVisible={reset.state === "request"}
onBackdropPress={closeReset}
>
<View className="bg-white px-7 py-9 rounded-2xl min-h-[280px]">
<Text className="text-2xl font-JakartaExtraBold mb-2">
Reset password
<View className="bg-white dark:bg-neutral-900 px-7 py-9 rounded-2xl min-h-[280px]">
<Text className="text-2xl font-JakartaExtraBold mb-2 text-black dark:text-white">
{t("auth.signIn.reset.title")}
</Text>
<Text className="font-Jakarta mb-5">
Enter your email and we&apos;ll send you a 6-digit reset code.
<Text className="font-Jakarta mb-5 text-black dark:text-white">
{t("auth.signIn.reset.requestBody")}
</Text>
<InputField
label="Email"
placeholder="karim@email.com"
label={t("auth.signIn.email")}
placeholder={t("auth.signIn.reset.emailPlaceholder")}
icon={icons.email}
value={reset.email}
keyboardType="email-address"
@@ -338,7 +340,7 @@ const SignIn = () => {
) : null}
<CustomButton
title={reset.busy ? "Sending" : "Send Code"}
title={reset.busy ? t("auth.signIn.reset.sending") : t("auth.signIn.reset.sendCode")}
onPress={onRequestReset}
disabled={reset.busy}
className="mt-5"
@@ -350,20 +352,20 @@ const SignIn = () => {
isVisible={reset.state === "reset"}
onBackdropPress={closeReset}
>
<View className="bg-white px-7 py-9 rounded-2xl min-h-[300px]">
<Text className="text-2xl font-JakartaExtraBold mb-2">
Enter new password
<View className="bg-white dark:bg-neutral-900 px-7 py-9 rounded-2xl min-h-[300px]">
<Text className="text-2xl font-JakartaExtraBold mb-2 text-black dark:text-white">
{t("auth.signIn.reset.newPassTitle")}
</Text>
<Text className="font-Jakarta mb-5">
We&apos;ve sent a reset code to {reset.email}
<Text className="font-Jakarta mb-5 text-black dark:text-white">
{t("auth.signIn.reset.resetBody", { email: reset.email })}
</Text>
{reset.devCode ? (
<View className="bg-amber-50 border border-amber-300 rounded-xl p-3 mb-5">
<Text className="text-sm text-amber-700 font-Jakarta">
Email delivery is not configured on this server. Your reset
code is <Text className="font-JakartaBold">{reset.devCode}</Text>
<View className="bg-amber-50 dark:bg-amber-950/40 border border-amber-300 dark:border-amber-800 rounded-xl p-3 mb-5">
<Text className="text-sm text-amber-700 dark:text-amber-400 font-Jakarta">
{t("auth.signIn.reset.devBanner")}
<Text className="font-JakartaBold">{reset.devCode}</Text>
</Text>
</View>
) : null}
@@ -376,9 +378,9 @@ const SignIn = () => {
/>
<InputField
label="New password"
label={t("auth.signIn.reset.newPassLabel")}
icon={icons.lock}
placeholder="••••••••"
placeholder={t("auth.signIn.reset.newPasswordPlaceholder")}
secureTextEntry
value={reset.password}
onChangeText={(password) =>
@@ -393,7 +395,7 @@ const SignIn = () => {
) : null}
<CustomButton
title={reset.busy ? "Resetting" : "Reset Password"}
title={reset.busy ? t("auth.signIn.reset.resetting") : t("auth.signIn.reset.resetBtn")}
onPress={onSubmitReset}
disabled={reset.busy}
className="mt-5 bg-emerald-500"
@@ -406,4 +408,4 @@ const SignIn = () => {
);
};
export default SignIn;
export default SignIn;