Add rider/driver role selection after sign-up

- users.role column (+ migration in seed script)
- /(api)/user: GET role by clerkId, PATCH to set role
- Role selection screen; drivers get placeholder driver-home
- Root index routes by role; hardened location handling on home
This commit is contained in:
Krikorios
2026-08-22 16:13:59 +03:00
parent fdc1664cce
commit fbe92c9d16
9 changed files with 243 additions and 19 deletions
+36 -14
View File
@@ -48,24 +48,37 @@ const Home = () => {
useEffect(() => {
const requestLocation = async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
try {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== "granted") return setHasPermissions(false);
if (status !== "granted") return setHasPermissions(false);
setHasPermissions(true);
setHasPermissions(true);
let location = await Location.getCurrentPositionAsync();
let location = await Location.getCurrentPositionAsync();
const address = await Location.reverseGeocodeAsync({
longitude: location.coords?.longitude,
latitude: location.coords?.latitude,
});
let addressText = "Unknown location";
try {
const address = await Location.reverseGeocodeAsync({
longitude: location.coords?.longitude,
latitude: location.coords?.latitude,
});
if (address[0]) {
addressText = `${address[0].name}, ${address[0].region}`;
}
} catch (geocodeErr) {
console.log("[REVERSE_GEOCODE]: ", geocodeErr);
}
setUserLocation({
latitude: location.coords.latitude,
longitude: location.coords.longitude,
address: `${address[0].name}, ${address[0].region}`,
});
setUserLocation({
latitude: location.coords.latitude,
longitude: location.coords.longitude,
address: addressText,
});
} catch (err) {
console.log("[LOCATION]: ", err);
setHasPermissions(false);
}
};
requestLocation();
@@ -143,7 +156,16 @@ const Home = () => {
</Text>
<View className="flex flex-row items-center bg-transparent h-[300px]">
{hasPermissions && <Map />}
{hasPermissions ? (
<Map />
) : (
<View className="flex-1 items-center justify-center bg-white rounded-2xl h-full">
<Text className="text-general-200 text-center font-JakartaMedium px-5">
Location access is off.{"\n"}Enable it in your device
settings to see nearby drivers.
</Text>
</View>
)}
</View>
<Text className="text-xl font-JakartaBold mt-5 mb-3">