Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Store/shopstore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Shop {
timeout: string;
isOpen?: boolean;
categoryId?: number;
category?: { id: number; name: string };
services?: ShopService[];
}

Expand Down Expand Up @@ -60,7 +61,7 @@ export const useShopStore = create<ShopState>((set, get) => ({
set({ shops, loading: false });
return shops;
} catch (error: any) {
set({ error: error.message || "Failed to fetch shops", loading: false });
set({ error: error.message || "Failed to fetch shop", loading: false });
return [];
}
},
Expand Down
3 changes: 1 addition & 2 deletions app/(authadmin)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function AuthLayout() {
</LinearGradient>

{/* Card */}
<View style={styles.card}>
<View style={[styles.card, { backgroundColor: colors.surface }]}>
<Slot />
</View>
</ScrollView>
Expand Down Expand Up @@ -123,7 +123,6 @@ const styles = StyleSheet.create({
letterSpacing: 0.2,
},
card: {
backgroundColor: 'white',
borderTopLeftRadius: 28,
borderTopRightRadius: 28,
marginTop: -24,
Expand Down
15 changes: 14 additions & 1 deletion app/(authadmin)/adminsign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import * as WebBrowser from 'expo-web-browser';
import * as Google from 'expo-auth-session/providers/google';
import * as AppleAuthentication from 'expo-apple-authentication';
import { makeRedirectUri } from 'expo-auth-session';
import { registerAdminPushToken } from '@/constants/adminApi';
import { registerForPushNotificationsAsync } from '@/app/utils/pushNotifications';

const Signin = () => {
const { colors } = useThemeStore();
Expand Down Expand Up @@ -47,6 +49,10 @@ const Signin = () => {
const res = await apiClient.post('/api/v1/admin/google', { idToken });
await SecureStore.deleteItemAsync('token');
await SecureStore.setItemAsync('admintoken', res.data.token);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerAdminPushToken(pushToken);
} catch (ignored) {}
router.replace('/adminfolder' as any);
} catch (error: any) {
Alert.alert('Google Sign-In Failed', error.message || 'Something went wrong');
Expand All @@ -70,6 +76,10 @@ const Signin = () => {
const res = await apiClient.post('/api/v1/admin/apple', { idToken: credential.identityToken, name });
await SecureStore.deleteItemAsync('token');
await SecureStore.setItemAsync('admintoken', res.data.token);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerAdminPushToken(pushToken);
} catch (ignored) {}
router.replace('/adminfolder' as any);
} catch (e: any) {
if (e.code !== 'ERR_REQUEST_CANCELED') {
Expand Down Expand Up @@ -108,9 +118,12 @@ const Signin = () => {
try {
const response = await apiClient.post('/api/v1/admin/signin', form);
const { token } = response.data;
// Clear any legacy 'token' key that may still contain a stale admin token
await SecureStore.deleteItemAsync('token');
await SecureStore.setItemAsync('admintoken', token);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerAdminPushToken(pushToken);
} catch (ignored) {}
router.replace('/adminfolder' as any);
} catch (error: any) {
const message = error.response?.data?.error || error.message || 'Something went wrong';
Expand Down
3 changes: 1 addition & 2 deletions app/(authuser)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function AuthLayout() {
</LinearGradient>

{/* Card */}
<View style={styles.card}>
<View style={[styles.card, { backgroundColor: colors.surface }]}>
<Slot />
</View>
</ScrollView>
Expand Down Expand Up @@ -110,7 +110,6 @@ const styles = StyleSheet.create({
letterSpacing: 0.2,
},
card: {
backgroundColor: 'white',
borderTopLeftRadius: 28,
borderTopRightRadius: 28,
marginTop: -24,
Expand Down
15 changes: 14 additions & 1 deletion app/(authuser)/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import * as WebBrowser from 'expo-web-browser';
import * as Google from 'expo-auth-session/providers/google';
import * as AppleAuthentication from 'expo-apple-authentication';
import { makeRedirectUri } from 'expo-auth-session';
import { userAppleSignin, userGoogleSignin } from '@/constants/userApi';
import { userAppleSignin, userGoogleSignin, registerUserPushToken } from '@/constants/userApi';
import { registerForPushNotificationsAsync } from '@/app/utils/pushNotifications';
import { useEffect } from 'react';

WebBrowser.maybeCompleteAuthSession();
Expand Down Expand Up @@ -48,6 +49,10 @@ const UserSignInScreen = () => {
setSubmitting(true);
try {
await userGoogleSignin(idToken);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerUserPushToken(pushToken);
} catch (ignored) {}
router.replace('/userflow/setting');
} catch (error: any) {
Alert.alert('Google Sign-In Failed', error.message || 'Something went wrong');
Expand All @@ -69,6 +74,10 @@ const UserSignInScreen = () => {
? `${credential.fullName.givenName} ${credential.fullName.familyName || ''}`.trim()
: undefined;
await userAppleSignin(credential.identityToken!, name);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerUserPushToken(pushToken);
} catch (ignored) {}
router.replace('/userflow/setting');
} catch (e: any) {
if (e.code !== 'ERR_REQUEST_CANCELED') {
Expand All @@ -93,6 +102,10 @@ const UserSignInScreen = () => {
setSubmitting(true);
try {
await userSignin(form.email, form.password);
try {
const pushToken = await registerForPushNotificationsAsync();
if (pushToken) await registerUserPushToken(pushToken);
} catch (ignored) {}
router.replace('/userflow/setting');
} catch (error: any) {
Alert.alert('Sign in Failed', error.message);
Expand Down
22 changes: 13 additions & 9 deletions app/(tabs)/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,8 @@ export default function Cart() {

const categorizeBooking = (booking: any) => {
if (!booking.booked || booking.status === 'cancelled') return 'Cancelled';

try {
const endTimeObj = new Date(booking.endTime);
const now = new Date();

return now <= endTimeObj ? 'Active' : 'Completed';
} catch(e) {
return 'Completed';
}
if (booking.status === 'completed') return 'Completed';
return 'Active'; // 'upcoming' from backend
};

const handleCancel = (bookingId: number) => {
Expand Down Expand Up @@ -316,6 +309,17 @@ export default function Cart() {
</Text>
</TouchableOpacity>

{activeTab === 'Active' && (
<TouchableOpacity
style={{ flex: 1, paddingVertical: 12, borderRadius: 12, backgroundColor: colors.background, alignItems: 'center', borderWidth: 1, borderColor: colors.primary }}
onPress={() => router.push(`/shops/${order.service?.shop?.id}` as any)}
>
<Text style={{ color: colors.primary, fontWeight: '600', fontSize: 14 }}>
Reschedule
</Text>
</TouchableOpacity>
)}

<TouchableOpacity
style={{ flex: 1, paddingVertical: 12, borderRadius: 12, backgroundColor: activeTab === 'Active' ? colors.primary : colors.text, alignItems: 'center' }}
onPress={() => activeTab === 'Active' ? setSelectedBooking(order) : router.push(`/shops/${order.service?.shop?.id}` as any)}
Expand Down
92 changes: 82 additions & 10 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SafeAreaView } from "react-native-safe-area-context";
import { FlatList, Image, Pressable, Text, TouchableOpacity, View, StyleSheet } from "react-native";
import { FlatList, Image, Pressable, Text, TouchableOpacity, View, StyleSheet, ScrollView } from "react-native";
import { Fragment, useEffect, useState } from "react";
import { router } from "expo-router";
import * as Location from 'expo-location';
Expand Down Expand Up @@ -123,16 +123,49 @@ export default function Index() {
<Text style={styles.subtitle}>Book the services you need</Text>
</View>

<TouchableOpacity
style={[styles.sellerBtn, { borderColor: colors.primary, backgroundColor: colors.surface }]}
onPress={() => router.replace('/(authadmin)/adminsign-in')}
activeOpacity={0.8}
>
<Ionicons name="storefront-outline" size={14} color={colors.primary} />
<Text style={[styles.sellerBtnText, { color: colors.primary }]}>Become a Seller</Text>
</TouchableOpacity>
<View style={{ flexDirection: 'row', gap: 12, marginBottom: 28 }}>
<TouchableOpacity
style={[styles.sellerBtn, { borderColor: colors.primary, backgroundColor: colors.surface, marginBottom: 0 }]}
onPress={() => router.replace('/(authadmin)/adminsign-in')}
activeOpacity={0.8}
>
<Ionicons name="storefront-outline" size={14} color={colors.primary} />
<Text style={[styles.sellerBtnText, { color: colors.primary }]}>Become a Seller</Text>
</TouchableOpacity>

<TouchableOpacity
style={[styles.sellerBtn, { borderColor: colors.primary, backgroundColor: colors.primary, marginBottom: 0 }]}
onPress={() => router.push('/userflow/map')}
activeOpacity={0.8}
>
<Ionicons name="map-outline" size={14} color={'#fff'} />
<Text style={[styles.sellerBtnText, { color: '#fff' }]}>Map View</Text>
</TouchableOpacity>
</View>

<Text style={[styles.sectionTitle, { color: colors.text }]}>Browse Categories</Text>
<Text style={[styles.sectionTitle, { color: colors.text, marginBottom: 16 }]}>Popular Shops</Text>

<ScrollView horizontal showsHorizontalScrollIndicator={false} style={{ marginBottom: 24, marginHorizontal: -20 }} contentContainerStyle={{ paddingHorizontal: 20, gap: 16 }}>
{shops.slice(0, 5).map(shop => (
<TouchableOpacity
key={shop.id}
style={[styles.shopCard, { backgroundColor: colors.surface, borderColor: colors.border }]}
onPress={() => router.push(`/shops/${shop.id}`)}
>
<Image source={{ uri: shop.image || 'https://via.placeholder.com/150' }} style={styles.shopImage} />
<View style={styles.shopInfo}>
<Text style={[styles.shopTitle, { color: colors.text }]} numberOfLines={1}>{shop.name || `Best ${shop.occupation}`}</Text>
<Text style={styles.shopCategory}>{shop.category?.name || shop.occupation}</Text>
<View style={styles.shopRatingRow}>
<Ionicons name="star" size={12} color="#F59E0B" />
<Text style={[styles.shopRating, { color: colors.text }]}>4.8</Text>
</View>
</View>
</TouchableOpacity>
))}
</ScrollView>

<Text style={[styles.sectionTitle, { color: colors.text }]}>Explore Offers</Text>
</View>
)}
/>
Expand Down Expand Up @@ -166,6 +199,45 @@ const styles = StyleSheet.create({
},
sellerBtnText: { fontSize: 13, fontWeight: '700' },
sectionTitle: { fontSize: 18, fontWeight: '800', marginBottom: 4 },
shopCard: {
width: 160,
borderRadius: 16,
borderWidth: 1,
overflow: 'hidden',
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.05,
shadowRadius: 8,
elevation: 3,
},
shopImage: {
width: '100%',
height: 100,
backgroundColor: '#e5e7eb',
},
shopInfo: {
padding: 12,
},
shopTitle: {
fontSize: 14,
fontWeight: '700',
marginBottom: 4,
},
shopCategory: {
fontSize: 12,
color: '#6366f1',
fontWeight: '500',
marginBottom: 6,
},
shopRatingRow: {
flexDirection: 'row',
alignItems: 'center',
gap: 4,
},
shopRating: {
fontSize: 12,
fontWeight: '600',
},
card: {
width: '100%',
height: 160,
Expand Down
15 changes: 9 additions & 6 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Stack } from 'expo-router';
import { useFonts } from 'expo-font';
import { useEffect } from 'react';
import { useThemeStore } from '@/Store/themeStore';
import { ErrorBoundary } from '@/components/ErrorBoundary';
import './globals.css';

export default function RootLayout() {
Expand All @@ -22,11 +23,13 @@ export default function RootLayout() {
}, [hydrateTheme]);

return (
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: colors.background },
}}
/>
<ErrorBoundary>
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: colors.background },
}}
/>
</ErrorBoundary>
);
}
Loading