Compare commits

..

1 Commits

Author SHA1 Message Date
AppCakes 52125c20dc build: fce83541-8c54-465f-a1fc-71388f99db57 2026-07-13 08:54:39 +00:00
80 changed files with 5080 additions and 8680 deletions
Vendored
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -4,7 +4,7 @@ android {
namespace = "io.ionic.starter" namespace = "io.ionic.starter"
compileSdk = rootProject.ext.compileSdkVersion compileSdk = rootProject.ext.compileSdkVersion
defaultConfig { defaultConfig {
applicationId "io.ionic.starter" applicationId "com.afmeaglesnzw.app"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1 versionCode 1
+6
View File
@@ -21,6 +21,12 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.afmeaglesnzw.app" />
</intent-filter>
</activity> </activity>
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<resources> <resources>
<string name="app_name">bringg</string> <string name="app_name">AFM.EAGLESNZW</string>
<string name="title_activity_main">bringg</string> <string name="title_activity_main">AFM.EAGLESNZW</string>
<string name="package_name">io.ionic.starter</string> <string name="package_name">io.ionic.starter</string>
<string name="custom_url_scheme">io.ionic.starter</string> <string name="custom_url_scheme">io.ionic.starter</string>
</resources> </resources>
-1
View File
@@ -15,5 +15,4 @@ ext {
cordovaAndroidVersion = '14.0.1' cordovaAndroidVersion = '14.0.1'
rgcfaIncludeGoogle = true rgcfaIncludeGoogle = true
androidxCredentialsVersion = '1.3.0' androidxCredentialsVersion = '1.3.0'
javaVersion = JavaVersion.VERSION_17
} }
+2 -2
View File
@@ -1,8 +1,8 @@
import type { CapacitorConfig } from '@capacitor/cli'; import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { const config: CapacitorConfig = {
appId: 'com.bringg.app', appId: 'com.afmeaglesnzw.app',
appName: 'bringg', appName: 'AFM.EAGLESNZW',
webDir: 'dist', webDir: 'dist',
plugins: { plugins: {
FirebaseAuthentication: { FirebaseAuthentication: {
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+6 -2
View File
@@ -26,6 +26,7 @@
504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1A4EB3C21FED79650016851F /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; }; 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; }; 958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@@ -68,6 +69,7 @@
504EC30E1FED79650016851F /* Assets.xcassets */, 504EC30E1FED79650016851F /* Assets.xcassets */,
504EC3101FED79650016851F /* LaunchScreen.storyboard */, 504EC3101FED79650016851F /* LaunchScreen.storyboard */,
504EC3131FED79650016851F /* Info.plist */, 504EC3131FED79650016851F /* Info.plist */,
1A4EB3C21FED79650016851F /* App.entitlements */,
2FAD9762203C412B000D30F8 /* config.xml */, 2FAD9762203C412B000D30F8 /* config.xml */,
50B271D01FEDC1A000F3C39B /* public */, 50B271D01FEDC1A000F3C39B /* public */,
); );
@@ -295,6 +297,7 @@
baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */; baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
INFOPLIST_FILE = App/Info.plist; INFOPLIST_FILE = App/Info.plist;
@@ -305,7 +308,7 @@
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.bringg.app; PRODUCT_BUNDLE_IDENTIFIER = com.afmeaglesnzw.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@@ -317,6 +320,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
INFOPLIST_FILE = App/Info.plist; INFOPLIST_FILE = App/Info.plist;
@@ -326,7 +330,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.bringg.app; PRODUCT_BUNDLE_IDENTIFIER = com.afmeaglesnzw.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
+7 -3
View File
@@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>bringg</string> <string>AFM.EAGLESNZW</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
@@ -51,12 +51,16 @@
<array> <array>
<dict> <dict>
<key>CFBundleURLName</key> <key>CFBundleURLName</key>
<string>com.bringg.app</string> <string>com.afmeaglesnzw.app</string>
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array> <array>
<string>com.bringg.app</string> <string>com.afmeaglesnzw.app</string>
</array> </array>
</dict> </dict>
</array> </array>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to your photo library.</string>
<key>NSCameraUsageDescription</key>
<string>This app needs camera access.</string>
</dict> </dict>
</plist> </plist>
+5 -3
View File
@@ -18,12 +18,14 @@
"@capacitor/haptics": "8.0.2", "@capacitor/haptics": "8.0.2",
"@capacitor/ios": "8.3.4", "@capacitor/ios": "8.3.4",
"@capacitor/keyboard": "8.0.3", "@capacitor/keyboard": "8.0.3",
"@capacitor/preferences": "^8.0.1",
"@capacitor/push-notifications": "^8.1.1", "@capacitor/push-notifications": "^8.1.1",
"@capacitor/status-bar": "8.0.2", "@capacitor/status-bar": "8.0.2",
"@hookform/resolvers": "^3.9.0",
"@ionic/pwa-elements": "^3.0.0", "@ionic/pwa-elements": "^3.0.0",
"@ionic/react": "^8.5.0", "@ionic/react": "8.8.7",
"@ionic/react-router": "^8.5.0", "@ionic/react-router": "8.8.7",
"@supabase/supabase-js": "^2.0.0", "@supabase/supabase-js": "^2.108.1",
"firebase": "^11.0.0", "firebase": "^11.0.0",
"ionicons": "^7.4.0", "ionicons": "^7.4.0",
"katex": "^0.16.0", "katex": "^0.16.0",
BIN
View File
Binary file not shown.
+145 -52
View File
@@ -1,12 +1,32 @@
import React from 'react'; import React, { useEffect } from 'react';
import { Redirect, Route } from 'react-router-dom'; import { Redirect, Route } from 'react-router-dom';
import { IonApp, IonRouterOutlet } from '@ionic/react'; import {
IonApp,
IonIcon,
IonLabel,
IonRouterOutlet,
IonTabBar,
IonTabButton,
IonTabs,
setupIonicReact,
} from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router'; import { IonReactRouter } from '@ionic/react-router';
import {
homeOutline,
calendarOutline,
personOutline,
newspaperOutline,
} from 'ionicons/icons';
/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css'; import '@ionic/react/css/core.css';
/* Basic CSS for apps built with Ionic */
import '@ionic/react/css/normalize.css'; import '@ionic/react/css/normalize.css';
import '@ionic/react/css/structure.css'; import '@ionic/react/css/structure.css';
import '@ionic/react/css/typography.css'; import '@ionic/react/css/typography.css';
/* Optional CSS utils that can be commented out */
import '@ionic/react/css/padding.css'; import '@ionic/react/css/padding.css';
import '@ionic/react/css/float-elements.css'; import '@ionic/react/css/float-elements.css';
import '@ionic/react/css/text-alignment.css'; import '@ionic/react/css/text-alignment.css';
@@ -14,60 +34,133 @@ import '@ionic/react/css/text-transformation.css';
import '@ionic/react/css/flex-utils.css'; import '@ionic/react/css/flex-utils.css';
import '@ionic/react/css/display.css'; import '@ionic/react/css/display.css';
/* Theme variables */
import './theme/variables.css'; import './theme/variables.css';
import Home from './pages/Home'; import { AuthProvider, useAuth } from './contexts/AuthContext';
import ProductDetail from './pages/ProductDetail'; import ProtectedRoute from './components/ProtectedRoute';
import Cart from './pages/Cart';
import OrderConfirmation from './pages/OrderConfirmation';
import MyOrders from './pages/MyOrders';
import OrderDetail from './pages/OrderDetail';
import Auth from './pages/Auth';
import Profile from './pages/Profile';
import Addresses from './pages/Addresses';
import Wallet from './pages/Wallet';
import PaymentMethods from './pages/PaymentMethods';
import AddPaymentMethod from './pages/AddPaymentMethod';
import AdminOrders from './pages/AdminOrders';
import AdminOrderDetail from './pages/AdminOrderDetail';
import { AuthProvider } from './context/AuthContext';
const App: React.FC = () => ( import Auth from './pages/Auth';
<IonApp> import VerifyEmail from './pages/VerifyEmail';
<IonReactRouter> import SetupProfile from './pages/SetupProfile';
import Home from './pages/Home';
import Events from './pages/Events';
import Profile from './pages/Profile';
import EventDetail from './pages/EventDetail';
import AdminEventForm from './pages/AdminEventForm';
import News from './pages/News';
import NewsDetail from './pages/NewsDetail';
import AdminNewsForm from './pages/AdminNewsForm';
import { setStatusBarStyle, Style } from './utils/statusBar';
setupIonicReact();
const SetupProfileRoute: React.FC = () => {
const { user } = useAuth();
if (!user) return <Redirect to="/auth" />;
return <SetupProfile />;
};
const App: React.FC = () => {
useEffect(() => {
setStatusBarStyle(Style.Dark);
}, []);
return (
<IonApp>
<AuthProvider> <AuthProvider>
<IonRouterOutlet> <IonReactRouter>
<Route path="/home" component={Home} exact /> <IonRouterOutlet>
<Route path="/auth" component={Auth} exact /> {/* Unprotected Routes */}
<Route path="/product/:id" component={ProductDetail} exact /> <Route path="/auth" component={Auth} exact />
<Route path="/cart" component={Cart} exact /> <Route path="/verify-email" component={VerifyEmail} exact />
<Route path="/orders" component={MyOrders} exact />
<Route path="/orders/:id" component={OrderDetail} exact /> {/* Profile Setup (requires user, but no profile yet) */}
<Route path="/profile" component={Profile} exact /> <Route path="/setup-profile" component={SetupProfileRoute} exact />
<Route path="/addresses" component={Addresses} exact />
<Route path="/wallet" component={Wallet} exact /> {/* Non-tab Protected Routes */}
<Route <ProtectedRoute
path="/wallet/payment-methods" path="/event/:id([0-9a-fA-F-]{36})"
component={PaymentMethods} component={EventDetail}
exact exact
/> />
<Route <ProtectedRoute
path="/wallet/payment-methods/add" path="/admin/events/new"
component={AddPaymentMethod} component={AdminEventForm}
exact exact
/> />
<Route path="/admin/orders" component={AdminOrders} exact /> <ProtectedRoute
<Route path="/admin/orders/:id" component={AdminOrderDetail} exact /> path="/admin/events/:id([0-9a-fA-F-]{36})/edit"
<Route component={AdminEventForm}
path="/order-confirmation" exact
component={OrderConfirmation} />
exact <ProtectedRoute
/> path="/news/:id([0-9a-fA-F-]{36})"
<Redirect exact from="/" to="/home" /> component={NewsDetail}
</IonRouterOutlet> exact
/>
<ProtectedRoute
path="/admin/news/new"
component={AdminNewsForm}
exact
/>
<ProtectedRoute
path="/admin/news/:id([0-9a-fA-F-]{36})"
component={AdminNewsForm}
exact
/>
{/* Tabs */}
<ProtectedRoute
path={['/home', '/events', '/news', '/profile']}
component={() => (
<IonTabs>
<IonRouterOutlet>
<Route path="/home" component={Home} exact />
<Route path="/events" component={Events} exact />
<Route path="/news" component={News} exact />
<Route path="/profile" component={Profile} exact />
</IonRouterOutlet>
<IonTabBar
slot="bottom"
style={{
'--background': 'var(--color-surface)',
'--border': 'none',
color: 'var(--color-text-secondary)',
boxShadow: '0 -2px 10px rgba(47,34,29,0.05)',
}}
>
<IonTabButton tab="home" href="/home">
<IonIcon icon={homeOutline} />
<IonLabel>Home</IonLabel>
</IonTabButton>
<IonTabButton tab="events" href="/events">
<IonIcon icon={calendarOutline} />
<IonLabel>Events</IonLabel>
</IonTabButton>
<IonTabButton tab="news" href="/news">
<IonIcon icon={newspaperOutline} />
<IonLabel>News</IonLabel>
</IonTabButton>
<IonTabButton tab="profile" href="/profile">
<IonIcon icon={personOutline} />
<IonLabel>Profile</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
)}
/>
{/* Root Redirect */}
<Route exact path="/">
<Redirect to="/auth" />
</Route>
</IonRouterOutlet>
</IonReactRouter>
</AuthProvider> </AuthProvider>
</IonReactRouter> </IonApp>
</IonApp> );
); };
export default App; export default App;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 839 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 KiB

-36
View File
@@ -1,36 +0,0 @@
import React from 'react';
import { Redirect, Route, RouteProps } from 'react-router-dom';
import { IonLoading } from '@ionic/react';
import { useAuth } from '../context/AuthContext';
type Props = RouteProps;
const AdminRoute: React.FC<Props> = ({ component: Component, ...rest }) => {
const { user, profile, isLoading } = useAuth();
if (!Component) return null;
return (
<Route
{...rest}
render={(props) => {
if (isLoading) {
return <IonLoading isOpen message="Loading..." />;
}
if (!user) {
return <Redirect to="/auth" />;
}
if (!profile?.is_admin) {
return <Redirect to="/home" />;
}
const RouteComponent = Component as React.ComponentType<any>;
return <RouteComponent {...props} />;
}}
/>
);
};
export default AdminRoute;
+112
View File
@@ -0,0 +1,112 @@
import React from 'react';
import { ChurchEvent } from '../types';
interface EventListCardProps {
event: ChurchEvent;
onClick: () => void;
}
const EventListCard: React.FC<EventListCardProps> = ({ event, onClick }) => {
const categoryName = event.event_categories?.name || 'Event';
const date = new Date(event.start_at);
const hasTime = date.getHours() !== 0 || date.getMinutes() !== 0;
const startTime = hasTime
? date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
})
: null;
const dateStr = date.toLocaleDateString(undefined, {
month: 'short',
day: 'numeric',
});
return (
<div
onClick={onClick}
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '18px',
display: 'flex',
flexDirection: 'column',
gap: '12px',
cursor: 'pointer',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div
style={{
background: 'var(--color-brand-soft)',
color: 'var(--color-brand)',
borderRadius: '999px',
padding: '4px 10px',
fontSize: '12px',
fontWeight: '600',
}}
>
{dateStr}
{startTime ? `${startTime}` : ''}
</div>
<div
style={{
fontSize: '12px',
fontWeight: '500',
color: 'var(--color-text-secondary)',
}}
>
{categoryName}
</div>
</div>
<div>
<h3
style={{
margin: '0 0 4px 0',
fontSize: '16px',
fontWeight: '700',
color: 'var(--color-text-primary)',
}}
>
{event.title}
</h3>
<p
style={{
margin: 0,
fontSize: '13px',
fontWeight: '400',
color: 'var(--color-text-secondary)',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{event.description}
</p>
</div>
<div
style={{
fontSize: '13px',
fontWeight: '500',
color: 'var(--color-text-primary)',
}}
>
{event.venue}
</div>
</div>
);
};
export default EventListCard;
+100
View File
@@ -0,0 +1,100 @@
import React from 'react';
import { ChurchEvent } from '../types';
import { IonIcon } from '@ionic/react';
import { calendarOutline } from 'ionicons/icons';
interface EventPreviewCardProps {
event: ChurchEvent;
onClick: () => void;
}
const EventPreviewCard: React.FC<EventPreviewCardProps> = ({
event,
onClick,
}) => {
const categoryName = event.event_categories?.name || 'Event';
return (
<div
onClick={onClick}
style={{
display: 'flex',
alignItems: 'center',
padding: '8px 0',
gap: '10px',
background: 'transparent',
cursor: 'pointer',
}}
>
<div
style={{
width: '40px',
height: '40px',
borderRadius: '12px',
background: 'var(--color-brand-soft)',
flexShrink: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<IonIcon
icon={calendarOutline}
style={{ color: 'var(--color-brand)', fontSize: '20px' }}
/>
</div>
<div style={{ flex: 1, minWidth: 0 }}>
<h4
style={{
margin: '0 0 2px 0',
fontSize: '15px',
fontWeight: '600',
color: 'var(--color-text-primary)',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{event.title}
</h4>
<p
style={{
margin: 0,
fontSize: '12px',
fontWeight: '400',
color: 'var(--color-text-secondary)',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{(() => {
const date = new Date(event.start_at);
const hasTime = date.getHours() !== 0 || date.getMinutes() !== 0;
const timeStr = hasTime
? `${date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} • `
: '';
return `${timeStr}${event.day_label}`;
})()}
</p>
</div>
<div
style={{
background: 'var(--color-brand-soft)',
color: 'var(--color-brand)',
borderRadius: '999px',
padding: '4px 10px',
fontSize: '12px',
fontWeight: '600',
flexShrink: 0,
}}
>
{categoryName}
</div>
</div>
);
};
export default EventPreviewCard;
+76
View File
@@ -0,0 +1,76 @@
import React from 'react';
import { IonIcon } from '@ionic/react';
interface HomeStatCardProps {
label: string;
value: string;
caption: string;
icon?: string;
}
const HomeStatCard: React.FC<HomeStatCardProps> = ({
label,
value,
caption,
icon,
}) => {
return (
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '18px',
flex: 1,
display: 'flex',
flexDirection: 'column',
gap: '8px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}
>
<span
style={{
fontSize: '12px',
fontWeight: '600',
color: 'var(--color-text-secondary)',
}}
>
{label}
</span>
{icon && (
<IonIcon
icon={icon}
style={{ color: 'var(--color-brand)', fontSize: '16px' }}
/>
)}
</div>
<div
style={{
fontSize: '28px',
fontWeight: '400',
color: 'var(--color-text-primary)',
margin: '4px 0 0 0',
}}
>
{value}
</div>
<div
style={{
fontSize: '12px',
fontWeight: '400',
color: 'var(--color-text-secondary)',
}}
>
{caption}
</div>
</div>
);
};
export default HomeStatCard;
+70
View File
@@ -0,0 +1,70 @@
import React from 'react';
import { IonInput } from '@ionic/react';
interface OtpInputRowProps {
digits: string[];
onChange: (index: number, value: string) => void;
onKeyDown: (
index: number,
e: React.KeyboardEvent<HTMLIonInputElement>
) => void;
inputRefs: React.RefObject<HTMLIonInputElement>[];
}
const OtpInputRow: React.FC<OtpInputRowProps> = ({
digits,
onChange,
onKeyDown,
inputRefs,
}) => {
return (
<div
style={{
display: 'flex',
gap: '10px',
justifyContent: 'center',
margin: '0 0 20px 0',
}}
>
{digits.map((digit, index) => (
<div
key={index}
style={{
background: '#ffffff',
borderRadius: '12px',
width: '48px',
height: '56px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
boxShadow: '0 1px 3px rgba(0,0,0,0.05)',
}}
>
<IonInput
ref={inputRefs[index]}
type="tel"
inputMode="numeric"
maxlength={1}
value={digit}
onIonInput={(e) =>
onChange(index, (e.target as HTMLIonInputElement).value as string)
}
onKeyDown={(e) => onKeyDown(index, e)}
style={{
fontSize: '24px',
fontWeight: '600',
color: '#1f2937',
textAlign: 'center',
'--padding-start': '0px',
'--padding-end': '0px',
width: '100%',
height: '100%',
}}
/>
</div>
))}
</div>
);
};
export default OtpInputRow;
-101
View File
@@ -1,101 +0,0 @@
import React from 'react';
import {
IonButton,
IonIcon,
IonLabel,
IonModal,
IonRadio,
IonRadioGroup,
IonItem,
IonList,
} from '@ionic/react';
import { funnelOutline } from 'ionicons/icons';
export type SortOption = 'popular' | 'price-asc' | 'price-desc' | 'name-asc';
type Props = {
categories: string[];
selectedCategory: string;
setSelectedCategory: (value: string) => void;
sortOption: SortOption;
setSortOption: (value: SortOption) => void;
isOpen: boolean;
onClose: () => void;
};
const ProductFilters: React.FC<Props> = ({
categories,
selectedCategory,
setSelectedCategory,
sortOption,
setSortOption,
isOpen,
onClose,
}) => (
<>
<div className="filter-row">
<div className="filter-chip-row">
<IonButton
fill={selectedCategory === 'All' ? 'solid' : 'outline'}
size="small"
onClick={() => setSelectedCategory('All')}
>
All
</IonButton>
{categories.map((category) => (
<IonButton
key={category}
fill={selectedCategory === category ? 'solid' : 'outline'}
size="small"
onClick={() => setSelectedCategory(category)}
>
{category}
</IonButton>
))}
</div>
<IonButton fill="clear" className="filter-button" onClick={onClose}>
<IonIcon icon={funnelOutline} slot="start" />
Filters
</IonButton>
</div>
<IonModal
isOpen={isOpen}
onDidDismiss={onClose}
breakpoints={[0, 0.45]}
initialBreakpoint={0.45}
>
<div className="filter-modal ion-padding">
<h2>Sort products</h2>
<IonRadioGroup
value={sortOption}
onIonChange={(e) => setSortOption(e.detail.value)}
>
<IonList lines="none">
<IonItem>
<IonLabel>Most popular</IonLabel>
<IonRadio value="popular" />
</IonItem>
<IonItem>
<IonLabel>Price: low to high</IonLabel>
<IonRadio value="price-asc" />
</IonItem>
<IonItem>
<IonLabel>Price: high to low</IonLabel>
<IonRadio value="price-desc" />
</IonItem>
<IonItem>
<IonLabel>Name: A to Z</IonLabel>
<IonRadio value="name-asc" />
</IonItem>
</IonList>
</IonRadioGroup>
<IonButton expand="block" onClick={onClose}>
Done
</IonButton>
</div>
</IonModal>
</>
);
export default ProductFilters;
+17 -15
View File
@@ -1,29 +1,31 @@
import React from 'react'; import React from 'react';
import { Redirect, Route, RouteProps } from 'react-router-dom'; import { Route, Redirect, RouteProps } from 'react-router-dom';
import { IonLoading } from '@ionic/react'; import { useAuth } from '../contexts/AuthContext';
import { useAuth } from '../context/AuthContext';
type Props = RouteProps; interface ProtectedRouteProps extends RouteProps {
component: React.ComponentType<any>;
}
const ProtectedRoute: React.FC<Props> = ({ component: Component, ...rest }) => { const ProtectedRoute: React.FC<ProtectedRouteProps> = ({
const { user, isLoading } = useAuth(); component: Component,
...rest
if (!Component) return null; }) => {
const { user, profile } = useAuth();
return ( return (
<Route <Route
{...rest} {...rest}
render={(props) => { render={(props) => {
if (isLoading) {
return <IonLoading isOpen message="Loading..." />;
}
if (!user) { if (!user) {
return <Redirect to="/auth" />; return <Redirect to="/auth" />;
} }
if (profile !== undefined && profile === null) {
const RouteComponent = Component as React.ComponentType<any>; return <Redirect to="/setup-profile" />;
return <RouteComponent {...props} />; }
if (profile !== undefined && profile !== null && !profile.full_name) {
return <Redirect to="/setup-profile" />;
}
return <Component {...props} />;
}} }}
/> />
); );
-97
View File
@@ -1,97 +0,0 @@
import React, {
createContext,
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import type { Session, User } from '@supabase/supabase-js';
import { supabase } from '../supabase';
import type { Tables } from '../database.types';
type Profile = Tables<'profiles'>;
type AuthContextValue = {
session: Session | null;
user: User | null;
profile: Profile | null;
isLoading: boolean;
refreshProfile: () => Promise<void>;
signOut: () => Promise<void>;
};
const AuthContext = createContext<AuthContextValue | undefined>(undefined);
export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [session, setSession] = useState<Session | null>(null);
const [user, setUser] = useState<User | null>(null);
const [profile, setProfile] = useState<Profile | null>(null);
const [isLoading, setIsLoading] = useState(true);
const loadProfile = async (userId: string | null) => {
if (!userId) {
setProfile(null);
return;
}
const { data } = await supabase
.from('profiles')
.select('*')
.eq('id', userId)
.maybeSingle();
setProfile(data ?? null);
};
useEffect(() => {
let isMounted = true;
supabase.auth.getSession().then(async ({ data }) => {
if (!isMounted) return;
const nextSession = data.session ?? null;
setSession(nextSession);
setUser(nextSession?.user ?? null);
await loadProfile(nextSession?.user?.id ?? null);
if (isMounted) setIsLoading(false);
});
const {
data: { subscription },
} = supabase.auth.onAuthStateChange(async (_event, nextSession) => {
setSession(nextSession);
setUser(nextSession?.user ?? null);
await loadProfile(nextSession?.user?.id ?? null);
setIsLoading(false);
});
return () => {
isMounted = false;
subscription.unsubscribe();
};
}, []);
const value = useMemo<AuthContextValue>(
() => ({
session,
user,
profile,
isLoading,
refreshProfile: async () => loadProfile(user?.id ?? null),
signOut: async () => {
await supabase.auth.signOut();
},
}),
[session, user, profile, isLoading]
);
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
};
export const useAuth = () => {
const context = useContext(AuthContext);
if (!context) {
throw new Error('useAuth must be used within AuthProvider');
}
return context;
};
+137
View File
@@ -0,0 +1,137 @@
import React, { createContext, useContext, useEffect, useState } from 'react';
import { User } from '@supabase/supabase-js';
import { supabase } from '../supabase';
import { IonSpinner } from '@ionic/react';
export interface Profile {
id: string;
email: string;
full_name: string;
role: string;
ministry_group: string | null;
avatar_url: string | null;
}
interface AuthContextType {
user: User | null;
profile: Profile | null;
refreshProfile: () => Promise<void>;
signOut: () => Promise<void>;
}
const AuthContext = createContext<AuthContextType>({
user: null,
profile: null,
refreshProfile: async () => {},
signOut: async () => {},
});
const PROFILE_CACHE_KEY = 'church_app_profile_cache';
async function getCachedProfile(): Promise<Profile | null> {
const cached = localStorage.getItem(PROFILE_CACHE_KEY);
if (cached) {
try {
return JSON.parse(cached);
} catch (e) {
return null;
}
}
return null;
}
async function cacheProfile(profile: Profile) {
localStorage.setItem(PROFILE_CACHE_KEY, JSON.stringify(profile));
}
async function clearCachedProfile() {
localStorage.removeItem(PROFILE_CACHE_KEY);
}
export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [user, setUser] = useState<User | null>(null);
const [profile, setProfile] = useState<Profile | null>(null);
const [initializing, setInitializing] = useState(true);
const fetchProfile = async (userId: string) => {
const cached = await getCachedProfile();
if (cached && cached.id === userId) {
setProfile(cached);
}
const { data } = await supabase
.from('profiles')
.select('*')
.eq('id', userId)
.single();
if (data) {
setProfile(data);
await cacheProfile(data);
}
};
const signOut = async () => {
await supabase.auth.signOut();
};
useEffect(() => {
// One-shot bootstrap
supabase.auth.getSession().then(async ({ data }) => {
const currentUser = data.session?.user ?? null;
setUser(currentUser);
if (currentUser) {
await fetchProfile(currentUser.id);
}
setInitializing(false); // only ever called once - IonReactRouter mounts after this
});
// Subsequent events: update state, never touch initializing
const {
data: { subscription },
} = supabase.auth.onAuthStateChange(async (_event, session) => {
const currentUser = session?.user ?? null;
setUser(currentUser);
if (currentUser) {
await fetchProfile(currentUser.id);
} else {
setProfile(null);
await clearCachedProfile();
}
});
return () => subscription.unsubscribe();
}, []);
if (initializing) {
return (
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100vh',
backgroundColor: '#f5f7f4',
}}
>
<IonSpinner name="crescent" color="primary" />
</div>
);
}
return (
<AuthContext.Provider
value={{
user,
profile,
refreshProfile: () =>
user ? fetchProfile(user.id) : Promise.resolve(),
signOut,
}}
>
{children}
</AuthContext.Provider>
);
};
export const useAuth = () => useContext(AuthContext);
+81 -201
View File
@@ -14,277 +14,157 @@ export type Database = {
} }
public: { public: {
Tables: { Tables: {
addresses: { event_categories: {
Row: { Row: {
address_line: string accent_color: string | null
created_at: string created_at: string
id: string id: string
is_default: boolean name: string
label: string slug: string
notes: string | null
phone: string
recipient_name: string
user_id: string
} }
Insert: { Insert: {
address_line: string accent_color?: string | null
created_at?: string created_at?: string
id?: string id?: string
is_default?: boolean name: string
label: string slug: string
notes?: string | null
phone: string
recipient_name: string
user_id: string
} }
Update: { Update: {
address_line?: string accent_color?: string | null
created_at?: string created_at?: string
id?: string id?: string
is_default?: boolean name?: string
label?: string slug?: string
notes?: string | null
phone?: string
recipient_name?: string
user_id?: string
} }
Relationships: [] Relationships: []
} }
order_items: { events: {
Row: { Row: {
audience: string
category_id: string | null
created_at: string created_at: string
created_by: string | null
day_label: string
description: string
end_at: string | null
id: string id: string
order_id: string is_featured: boolean
product_id: string start_at: string
product_name: string title: string
quantity: number updated_at: string
unit_price: number venue: string
} }
Insert: { Insert: {
audience?: string
category_id?: string | null
created_at?: string created_at?: string
created_by?: string | null
day_label: string
description?: string
end_at?: string | null
id?: string id?: string
order_id: string is_featured?: boolean
product_id: string start_at: string
product_name: string title: string
quantity: number updated_at?: string
unit_price: number venue: string
} }
Update: { Update: {
audience?: string
category_id?: string | null
created_at?: string created_at?: string
created_by?: string | null
day_label?: string
description?: string
end_at?: string | null
id?: string id?: string
order_id?: string is_featured?: boolean
product_id?: string start_at?: string
product_name?: string title?: string
quantity?: number updated_at?: string
unit_price?: number venue?: string
} }
Relationships: [ Relationships: [
{ {
foreignKeyName: "order_items_order_id_fkey" foreignKeyName: "events_category_id_fkey"
columns: ["order_id"] columns: ["category_id"]
isOneToOne: false isOneToOne: false
referencedRelation: "orders" referencedRelation: "event_categories"
referencedColumns: ["id"] referencedColumns: ["id"]
}, },
] ]
} }
orders: { news: {
Row: { Row: {
address_id: string | null content: string
created_at: string created_at: string | null
customer_name: string | null created_by: string
customer_phone: string | null
delivery_address: string | null
delivery_fee: number
delivery_notes: string | null
id: string id: string
item_count: number image_url: string | null
order_number: string title: string
status: string updated_at: string | null
subtotal: number
total: number
user_id: string | null
} }
Insert: { Insert: {
address_id?: string | null content: string
created_at?: string created_at?: string | null
customer_name?: string | null created_by: string
customer_phone?: string | null
delivery_address?: string | null
delivery_fee?: number
delivery_notes?: string | null
id?: string id?: string
item_count?: number image_url?: string | null
order_number: string title: string
status?: string updated_at?: string | null
subtotal?: number
total?: number
user_id?: string | null
} }
Update: { Update: {
address_id?: string | null content?: string
created_at?: string created_at?: string | null
customer_name?: string | null created_by?: string
customer_phone?: string | null
delivery_address?: string | null
delivery_fee?: number
delivery_notes?: string | null
id?: string id?: string
item_count?: number image_url?: string | null
order_number?: string title?: string
status?: string updated_at?: string | null
subtotal?: number
total?: number
user_id?: string | null
} }
Relationships: [ Relationships: [
{ {
foreignKeyName: "orders_address_id_fkey" foreignKeyName: "news_created_by_fkey"
columns: ["address_id"] columns: ["created_by"]
isOneToOne: false isOneToOne: false
referencedRelation: "addresses" referencedRelation: "profiles"
referencedColumns: ["id"] referencedColumns: ["id"]
}, },
] ]
} }
payment_methods: {
Row: {
brand: string
cardholder_name: string | null
created_at: string
expiry_month: number
expiry_year: number
id: string
is_default: boolean
last4: string
user_id: string
}
Insert: {
brand: string
cardholder_name?: string | null
created_at?: string
expiry_month: number
expiry_year: number
id?: string
is_default?: boolean
last4: string
user_id: string
}
Update: {
brand?: string
cardholder_name?: string | null
created_at?: string
expiry_month?: number
expiry_year?: number
id?: string
is_default?: boolean
last4?: string
user_id?: string
}
Relationships: []
}
profiles: { profiles: {
Row: { Row: {
avatar_url: string | null
created_at: string created_at: string
email: string
full_name: string | null full_name: string | null
id: string id: string
is_admin: boolean ministry_group: string | null
phone: string | null role: string
updated_at: string updated_at: string
} }
Insert: { Insert: {
avatar_url?: string | null
created_at?: string created_at?: string
email: string
full_name?: string | null full_name?: string | null
id: string id: string
is_admin?: boolean ministry_group?: string | null
phone?: string | null role?: string
updated_at?: string updated_at?: string
} }
Update: { Update: {
avatar_url?: string | null
created_at?: string created_at?: string
email?: string
full_name?: string | null full_name?: string | null
id?: string id?: string
is_admin?: boolean ministry_group?: string | null
phone?: string | null role?: string
updated_at?: string updated_at?: string
} }
Relationships: [] Relationships: []
} }
wallet_transactions: {
Row: {
amount: number
created_at: string
description: string | null
id: string
order_id: string | null
title: string
type: string
wallet_id: string
}
Insert: {
amount: number
created_at?: string
description?: string | null
id?: string
order_id?: string | null
title: string
type: string
wallet_id: string
}
Update: {
amount?: number
created_at?: string
description?: string | null
id?: string
order_id?: string | null
title?: string
type?: string
wallet_id?: string
}
Relationships: [
{
foreignKeyName: "wallet_transactions_order_id_fkey"
columns: ["order_id"]
isOneToOne: false
referencedRelation: "orders"
referencedColumns: ["id"]
},
{
foreignKeyName: "wallet_transactions_wallet_id_fkey"
columns: ["wallet_id"]
isOneToOne: false
referencedRelation: "wallets"
referencedColumns: ["id"]
},
]
}
wallets: {
Row: {
balance: number
created_at: string
currency: string
id: string
updated_at: string
user_id: string
}
Insert: {
balance?: number
created_at?: string
currency?: string
id?: string
updated_at?: string
user_id: string
}
Update: {
balance?: number
created_at?: string
currency?: string
id?: string
updated_at?: string
user_id?: string
}
Relationships: []
}
} }
Views: { Views: {
[_ in never]: never [_ in never]: never
+10 -5
View File
@@ -5,7 +5,7 @@ import { Capacitor } from '@capacitor/core';
import App from './App'; import App from './App';
// ── Ionic initialisation ────────────────────────────────────────────────────── // ── Ionic initialisation ──────────────────────────────────────────────────────
// ?mode=md|ios overrides (used by AppSuite preview); otherwise follow the platform. // ?mode=md|ios overrides (used by Appcakes preview); otherwise follow the platform.
const _urlMode = new URLSearchParams(window.location.search).get('mode'); const _urlMode = new URLSearchParams(window.location.search).get('mode');
const _platform = Capacitor.getPlatform(); // 'ios' | 'android' | 'web' const _platform = Capacitor.getPlatform(); // 'ios' | 'android' | 'web'
setupIonicReact({ setupIonicReact({
@@ -13,7 +13,7 @@ setupIonicReact({
}); });
// Derive the studio parent origin dynamically so this works in both dev // Derive the studio parent origin dynamically so this works in both dev
// (parent at localhost:3000) and production (parent at appcakes.qqura.com). // (parent at localhost:3000) and production (parent at studio.appcakes.dev).
const studioOrigin = (() => { const studioOrigin = (() => {
try { try {
if (document.referrer) return new URL(document.referrer).origin; if (document.referrer) return new URL(document.referrer).origin;
@@ -49,7 +49,7 @@ if (import.meta.hot) {
} }
// ── Session bridge ──────────────────────────────────────────────────────────── // ── Session bridge ────────────────────────────────────────────────────────────
// Post auth session to the AppSuite parent frame so the AI can test auth-protected // Post auth session to the Appcakes parent frame so the AI can test auth-protected
// Edge Functions. Uses import.meta.glob so Vite never errors if supabase.ts is absent. // Edge Functions. Uses import.meta.glob so Vite never errors if supabase.ts is absent.
(async () => { (async () => {
const mods = import.meta.glob('./supabase.ts', { eager: false }); const mods = import.meta.glob('./supabase.ts', { eager: false });
@@ -73,12 +73,17 @@ if (import.meta.hot) {
})(); })();
// ── Runtime error reporting ─────────────────────────────────────────────────── // ── Runtime error reporting ───────────────────────────────────────────────────
// Forward uncaught errors to the AppSuite dev server so the AI can read them. // Forward uncaught errors to the Appcakes dev server so the AI can read them.
// Extract projectId from the preview URL (/preview/{projectId}/) so errors are
// scoped per-project on the server rather than mixed into a global queue.
const _previewMatch = window.location.pathname.match(/\/preview\/([^/]+)/);
const _projectId = _previewMatch?.[1] ?? null;
function reportError(message: string, stack?: string) { function reportError(message: string, stack?: string) {
fetch(`${studioOrigin}/api/agent/runtime-error`, { fetch(`${studioOrigin}/api/agent/runtime-error`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message, stack }), body: JSON.stringify({ message, stack, projectId: _projectId }),
}).catch(() => {}); }).catch(() => {});
} }
-308
View File
@@ -1,308 +0,0 @@
import React, { useMemo, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonPage,
IonText,
IonToggle,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { cardOutline, chevronBackOutline } from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../context/AuthContext';
import { setStatusBarStyle, Style } from '../utils/statusBar';
const sanitizeCardNumber = (value: string) =>
value.replace(/\D/g, '').slice(0, 19);
const sanitizeExpiry = (value: string) => {
const digits = value.replace(/\D/g, '').slice(0, 4);
if (digits.length <= 2) return digits;
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
};
const sanitizeCvv = (value: string) => value.replace(/\D/g, '').slice(0, 4);
const detectBrand = (cardNumber: string) => {
if (/^4/.test(cardNumber)) return 'Visa';
if (/^(5[1-5]|2[2-7])/.test(cardNumber)) return 'Mastercard';
if (/^3[47]/.test(cardNumber)) return 'Amex';
return 'Card';
};
const AddPaymentMethod: React.FC = () => {
const history = useHistory();
const { user } = useAuth();
const [cardholderName, setCardholderName] = useState('');
const [cardNumber, setCardNumber] = useState('');
const [expiry, setExpiry] = useState('');
const [cvv, setCvv] = useState('');
const [setAsDefault, setSetAsDefault] = useState(true);
const [isPreviewBack, setIsPreviewBack] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [message, setMessage] = useState('');
const [error, setError] = useState('');
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Light);
});
const showError = (text: string) => {
setError(text);
window.setTimeout(() => setError(''), 4000);
};
const formattedCardNumber = useMemo(() => {
return sanitizeCardNumber(cardNumber)
.replace(/(.{4})/g, '$1 ')
.trim();
}, [cardNumber]);
const cardBrand = detectBrand(sanitizeCardNumber(cardNumber));
const previewNumber = formattedCardNumber || '1234 5678 9010 0010';
const previewName = cardholderName.trim() || 'Andrew Johnson';
const previewExpiry = expiry || '10/22';
const previewCvv = cvv || '123';
const handleSave = async () => {
if (!user) {
history.replace('/auth');
return;
}
const cleanCardNumber = sanitizeCardNumber(cardNumber);
const cleanExpiry = sanitizeExpiry(expiry);
const [monthRaw, yearRaw] = cleanExpiry.split('/');
const month = Number(monthRaw);
const year = Number(yearRaw);
if (!cardholderName.trim()) return showError('Enter the name on card.');
if (cleanCardNumber.length < 12)
return showError('Enter a valid card number.');
if (
!month ||
month < 1 ||
month > 12 ||
String(yearRaw ?? '').length !== 2
) {
return showError('Enter a valid expiry date.');
}
if (sanitizeCvv(cvv).length < 3) return showError('Enter a valid CVV.');
setIsSubmitting(true);
setError('');
if (setAsDefault) {
await supabase
.from('payment_methods')
.update({ is_default: false })
.eq('user_id', user.id);
}
const { error: insertError } = await supabase
.from('payment_methods')
.insert({
user_id: user.id,
brand: detectBrand(cleanCardNumber),
last4: cleanCardNumber.slice(-4),
expiry_month: month,
expiry_year: 2000 + year,
cardholder_name: cardholderName.trim(),
is_default: setAsDefault,
});
setIsSubmitting(false);
if (insertError) {
showError('Could not save this payment method.');
return;
}
setMessage('Payment method saved.');
window.setTimeout(() => history.replace('/wallet/payment-methods'), 700);
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to payment methods"
onClick={() => history.replace('/wallet/payment-methods')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Wallet</span>
<strong>Add card</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent fullscreen className="wallet-page add-card-page ion-padding">
<div className="wallet-intro-card add-card-intro-card">
<h1>Add Credit Card</h1>
<p>
Save a card for faster checkout. Only masked card metadata is stored
in this phase.
</p>
</div>
<div className="add-card-preview-shell">
<div className="preview-toggle-wrap">
<IonButton
fill="clear"
className="card-preview-toggle-button"
onClick={() => setIsPreviewBack((value) => !value)}
>
Show {isPreviewBack ? 'front' : 'back'} preview
</IonButton>
</div>
<div className="card-preview-stage">
<div
className={`card-preview card-preview-front ${
!isPreviewBack ? 'is-visible' : 'is-hidden'
}`}
>
<div className="card-preview-top-row">
<div className="card-chip-visual" />
<span className="card-brand-pill">{cardBrand}</span>
</div>
<div className="card-preview-number">{previewNumber}</div>
<div className="card-preview-meta-row">
<div>
<span>Cardholder Name</span>
<strong>{previewName}</strong>
</div>
<div className="card-preview-meta-right">
<span>Valid Thru</span>
<strong>{previewExpiry}</strong>
</div>
</div>
</div>
<div
className={`card-preview card-preview-back ${
isPreviewBack ? 'is-visible' : 'is-hidden'
}`}
>
<div className="card-preview-strip" />
<div className="card-preview-cvv-block">
<span>Security Code</span>
<strong>{previewCvv}</strong>
</div>
</div>
</div>
</div>
<div className="wallet-form-card add-card-form-card">
{message && (
<IonText color="success">
<p className="wallet-inline-message">{message}</p>
</IonText>
)}
{error && (
<IonText color="danger">
<p className="wallet-inline-message">{error}</p>
</IonText>
)}
<div className="checkout-form-grid add-card-form-grid">
<div className="form-field full-width">
<IonLabel>Card Number</IonLabel>
<IonItem lines="none" className="checkout-input add-card-input">
<IonIcon icon={cardOutline} slot="start" />
<IonInput
value={formattedCardNumber}
type="text"
inputMode="numeric"
placeholder="1234 5678 9012 3456"
onIonFocus={() => setIsPreviewBack(false)}
onIonInput={(e) => setCardNumber(e.detail.value ?? '')}
/>
</IonItem>
</div>
<div className="form-field">
<IonLabel>Cardholder Name</IonLabel>
<IonItem lines="none" className="checkout-input add-card-input">
<IonInput
value={cardholderName}
placeholder="Andrew Johnson"
onIonFocus={() => setIsPreviewBack(false)}
onIonInput={(e) => setCardholderName(e.detail.value ?? '')}
/>
</IonItem>
</div>
<div className="form-field">
<IonLabel>Valid Thru</IonLabel>
<IonItem lines="none" className="checkout-input add-card-input">
<IonInput
value={expiry}
type="text"
inputMode="numeric"
placeholder="10/22"
onIonFocus={() => setIsPreviewBack(false)}
onIonInput={(e) =>
setExpiry(sanitizeExpiry(e.detail.value ?? ''))
}
/>
</IonItem>
</div>
<div className="form-field full-width add-card-security-block">
<IonLabel>Security Code (CVV)</IonLabel>
<IonItem
lines="none"
className="checkout-input add-card-input add-card-cvv-input"
>
<IonInput
value={cvv}
type="password"
inputMode="numeric"
placeholder="123"
onIonFocus={() => setIsPreviewBack(true)}
onIonInput={(e) => setCvv(sanitizeCvv(e.detail.value ?? ''))}
/>
</IonItem>
</div>
</div>
<div className="wallet-toggle-row add-card-toggle-row">
<div>
<strong>Set as default</strong>
<p>Use this card first the next time you checkout.</p>
</div>
<IonToggle
checked={setAsDefault}
onIonChange={(e) => setSetAsDefault(e.detail.checked)}
/>
</div>
<IonButton
expand="block"
className="reference-place-order-button add-card-save-button"
onClick={handleSave}
disabled={isSubmitting}
>
{isSubmitting ? 'Save Card' : 'Save Card'}
</IonButton>
</div>
</IonContent>
</IonPage>
);
};
export default AddPaymentMethod;
-262
View File
@@ -1,262 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonPage,
IonText,
IonTextarea,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { chevronBackOutline, trashOutline } from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../context/AuthContext';
import type { Tables } from '../database.types';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Address = Tables<'addresses'>;
const Addresses: React.FC = () => {
const history = useHistory();
const { user } = useAuth();
const [addresses, setAddresses] = useState<Address[]>([]);
const [label, setLabel] = useState('Home');
const [recipientName, setRecipientName] = useState('');
const [phone, setPhone] = useState('');
const [addressLine, setAddressLine] = useState('');
const [notes, setNotes] = useState('');
const [message, setMessage] = useState('');
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Dark);
});
const showMessage = (msg: string) => {
setMessage(msg);
window.setTimeout(() => setMessage(''), 4000);
};
const loadAddresses = async () => {
if (!user) return;
const { data } = await supabase
.from('addresses')
.select('*')
.eq('user_id', user.id)
.order('is_default', { ascending: false })
.order('created_at', { ascending: false });
setAddresses(data ?? []);
};
useEffect(() => {
loadAddresses();
}, [user?.id]);
const saveAddress = async () => {
if (
!user ||
!recipientName.trim() ||
!phone.trim() ||
!addressLine.trim()
) {
showMessage('Complete the required address details.');
return;
}
const makeDefault = addresses.length === 0;
if (makeDefault) {
await supabase
.from('addresses')
.update({ is_default: false })
.eq('user_id', user.id);
}
const { error } = await supabase.from('addresses').insert({
user_id: user.id,
label: label.trim() || 'Address',
recipient_name: recipientName.trim(),
phone: phone.trim(),
address_line: addressLine.trim(),
notes: notes.trim() || null,
is_default: makeDefault,
});
if (!error) {
setLabel('Home');
setRecipientName('');
setPhone('');
setAddressLine('');
setNotes('');
showMessage('Address saved.');
loadAddresses();
}
};
const setDefaultAddress = async (addressId: string) => {
if (!user) return;
await supabase
.from('addresses')
.update({ is_default: false })
.eq('user_id', user.id);
await supabase
.from('addresses')
.update({ is_default: true })
.eq('id', addressId);
loadAddresses();
};
const deleteAddress = async (addressId: string) => {
await supabase.from('addresses').delete().eq('id', addressId);
loadAddresses();
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to profile"
onClick={() => history.replace('/profile')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Profile</span>
<strong>Addresses</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
{message && (
<IonText color="medium">
<p>{message}</p>
</IonText>
)}
<div className="checkout-card">
<div className="section-heading checkout-heading">
<h2>Add address</h2>
</div>
<div className="checkout-form-grid">
<div className="form-field">
<IonLabel position="stacked">Label</IonLabel>
<IonInput
value={label}
onIonInput={(e) => setLabel(e.detail.value ?? '')}
className="checkout-input"
/>
</div>
<div className="form-field">
<IonLabel position="stacked">Recipient</IonLabel>
<IonInput
value={recipientName}
onIonInput={(e) => setRecipientName(e.detail.value ?? '')}
className="checkout-input"
/>
</div>
<div className="form-field">
<IonLabel position="stacked">Phone</IonLabel>
<IonInput
value={phone}
onIonInput={(e) => setPhone(e.detail.value ?? '')}
className="checkout-input"
/>
</div>
<div className="form-field full-width">
<IonLabel position="stacked">Address</IonLabel>
<IonTextarea
value={addressLine}
onIonInput={(e) => setAddressLine(e.detail.value ?? '')}
className="checkout-input checkout-textarea"
autoGrow
rows={3}
/>
</div>
<div className="form-field full-width">
<IonLabel position="stacked">Notes</IonLabel>
<IonTextarea
value={notes}
onIonInput={(e) => setNotes(e.detail.value ?? '')}
className="checkout-input checkout-textarea"
autoGrow
rows={3}
/>
</div>
</div>
<IonButton expand="block" onClick={saveAddress}>
Save address
</IonButton>
</div>
{addresses.length === 0 ? (
<div className="empty-state">
<h3>No saved addresses</h3>
<p className="muted-text">
Save your first address for faster checkout.
</p>
</div>
) : (
<IonList lines="none" className="orders-list">
{addresses.map((address) => (
<div key={address.id} className="order-card">
<div className="order-card-top">
<div>
<span className="order-label">{address.label}</span>
<h3>{address.recipient_name}</h3>
</div>
{address.is_default ? (
<span className="default-pill">Default</span>
) : (
<IonButton
size="small"
fill="outline"
onClick={() => setDefaultAddress(address.id)}
>
Make default
</IonButton>
)}
</div>
<div className="delivery-detail-row delivery-detail-block">
<span>Phone</span>
<strong>{address.phone}</strong>
</div>
<div className="delivery-detail-row delivery-detail-block">
<span>Address</span>
<strong>{address.address_line}</strong>
</div>
{address.notes && (
<div className="delivery-detail-row delivery-detail-block">
<span>Notes</span>
<strong>{address.notes}</strong>
</div>
)}
<IonButton
fill="clear"
color="danger"
onClick={() => deleteAddress(address.id)}
>
<IonIcon slot="start" icon={trashOutline} />
Delete
</IonButton>
</div>
))}
</IonList>
)}
</IonContent>
</IonPage>
);
};
export default Addresses;
+685
View File
@@ -0,0 +1,685 @@
import React, { useState, useEffect } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonButtons,
IonButton,
IonIcon,
IonSpinner,
IonSelect,
IonSelectOption,
IonDatetime,
IonModal,
IonItem,
IonLabel,
} from '@ionic/react';
import { useHistory, useParams } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../contexts/AuthContext';
import {
chevronBackOutline,
calendarOutline,
timeOutline,
} from 'ionicons/icons';
import { EventCategory, ChurchEvent } from '../types';
const AdminEventForm: React.FC = () => {
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
const [categoryId, setCategoryId] = useState('');
const [audience, setAudience] = useState<'all' | 'youth' | 'children'>('all');
const [venue, setVenue] = useState('');
// Date states
const [startAt, setStartAt] = useState<string>(new Date().toISOString());
const [endAt, setEndAt] = useState<string>('');
const [isFeatured, setIsFeatured] = useState(false);
const [categories, setCategories] = useState<EventCategory[]>([]);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
const { id } = useParams<{ id: string }>();
const isEditMode = !!id;
const history = useHistory();
const { user, profile } = useAuth();
useEffect(() => {
if (profile && profile.role !== 'admin') {
history.replace('/home');
return;
}
const loadData = async () => {
setLoading(true);
// Load categories
const { data: catData, error: catError } = await supabase
.from('event_categories')
.select('*')
.order('name');
if (catError) {
setError(catError.message);
setLoading(false);
return;
}
setCategories(catData as EventCategory[]);
// If edit mode, load event
if (isEditMode) {
const { data: eventData, error: eventError } = await supabase
.from('events')
.select('*')
.eq('id', id)
.single();
if (eventError) {
setError(eventError.message);
} else {
const event = eventData as ChurchEvent;
setTitle(event.title);
setDescription(event.description);
setCategoryId(event.category_id);
setAudience(event.audience);
setVenue(event.venue);
setStartAt(event.start_at);
setEndAt(event.end_at || '');
setIsFeatured(event.is_featured);
}
} else if (catData && catData.length > 0) {
setCategoryId(catData[0].id); // default category
}
setLoading(false);
};
if (profile?.role === 'admin') {
loadData();
}
}, [id, isEditMode, profile, history]);
const showError = (msg: string) => {
setError(msg);
setTimeout(() => setError(null), 4000);
};
const getDayLabel = (dateString: string) => {
const d = new Date(dateString);
return d.toLocaleDateString(undefined, { weekday: 'long' });
};
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
if (!title || !description || !categoryId || !venue || !startAt) {
showError('Please fill out all required fields');
return;
}
if (!user || profile?.role !== 'admin') {
showError('Unauthorized');
return;
}
setSaving(true);
setError(null);
const dayLabel = getDayLabel(startAt);
const eventPayload = {
title,
description,
category_id: categoryId,
audience,
venue,
start_at: startAt,
end_at: endAt || null,
day_label: dayLabel,
is_featured: isFeatured,
};
if (isEditMode) {
const { error: updateError } = await supabase
.from('events')
.update(eventPayload)
.eq('id', id);
if (updateError) {
showError(updateError.message);
setSaving(false);
return;
}
} else {
const { error: insertError } = await supabase.from('events').insert({
...eventPayload,
created_by: user.id,
});
if (insertError) {
showError(insertError.message);
setSaving(false);
return;
}
}
setSaving(false);
history.goBack();
};
const handleDelete = async () => {
if (!isEditMode) return;
const confirmDelete = window.confirm(
'Are you sure you want to delete this event?'
);
if (!confirmDelete) return;
setSaving(true);
const { error: deleteError } = await supabase
.from('events')
.delete()
.eq('id', id);
if (deleteError) {
showError(deleteError.message);
setSaving(false);
return;
}
history.replace('/events');
};
return (
<IonPage style={{ background: '#f5f7f4' }}>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()} disabled={saving}>
<IonIcon
icon={chevronBackOutline}
style={{ color: '#1f2937' }}
slot="icon-only"
/>
</IonButton>
</IonButtons>
<IonTitle
style={{ fontSize: '18px', fontWeight: '700', color: '#1f2937' }}
>
{isEditMode ? 'Edit Event' : 'New Event'}
</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent
style={{
'--background': '#f5f7f4',
'--padding-start': '20px',
'--padding-end': '20px',
'--padding-top': '16px',
'--padding-bottom': '24px',
}}
>
{loading ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
padding: '40px 0',
}}
>
<IonSpinner name="crescent" color="primary" />
</div>
) : (
<>
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '20px',
margin: '0 0 16px 0',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<h2
style={{
margin: 0,
fontSize: '18px',
fontWeight: '700',
color: '#1f2937',
}}
>
Event Details
</h2>
<p
style={{
margin: '4px 0 0 0',
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
Provide the schedule and venue info for members.
</p>
</div>
{error && (
<div
style={{
background: 'rgba(163, 59, 50, 0.10)',
borderRadius: '12px',
padding: '12px 14px',
marginBottom: '16px',
}}
>
<p
style={{
margin: 0,
fontSize: '13px',
fontWeight: '500',
color: '#a33b32',
lineHeight: '1.4',
}}
>
{error}
</p>
</div>
)}
<form
onSubmit={handleSave}
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '16px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
{/* Title */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Event Title
</label>
<input
type="text"
placeholder="e.g. Sunday Service"
value={title}
onChange={(e) => setTitle(e.target.value)}
required
style={{
width: '100%',
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
boxSizing: 'border-box',
}}
/>
</div>
{/* Category */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Category
</label>
<div
style={{
background: '#eef2ec',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
display: 'flex',
alignItems: 'center',
}}
>
<IonSelect
value={categoryId}
onIonChange={(e) => setCategoryId(e.detail.value)}
interface="popover"
style={{
width: '100%',
color: '#1f2937',
fontSize: '15px',
}}
>
{categories.map((cat) => (
<IonSelectOption key={cat.id} value={cat.id}>
{cat.name}
</IonSelectOption>
))}
</IonSelect>
</div>
</div>
{/* Audience */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Audience
</label>
<div style={{ display: 'flex', gap: '8px' }}>
<button
type="button"
onClick={() => setAudience('all')}
style={{
flex: 1,
background: audience === 'all' ? '#2f6b4f' : '#eef2ec',
color: audience === 'all' ? '#ffffff' : '#4b5563',
border: 'none',
borderRadius: '999px',
padding: '12px',
fontSize: '14px',
fontWeight: '600',
cursor: 'pointer',
}}
>
All Members
</button>
<button
type="button"
onClick={() => setAudience('youth')}
style={{
flex: 1,
background: audience === 'youth' ? '#2f6b4f' : '#eef2ec',
color: audience === 'youth' ? '#ffffff' : '#4b5563',
border: 'none',
borderRadius: '999px',
padding: '12px',
fontSize: '14px',
fontWeight: '600',
cursor: 'pointer',
}}
>
Youth Only
</button>
<button
type="button"
onClick={() => setAudience('children')}
style={{
flex: 1,
background:
audience === 'children' ? '#2f6b4f' : '#eef2ec',
color: audience === 'children' ? '#ffffff' : '#4b5563',
border: 'none',
borderRadius: '999px',
padding: '12px',
fontSize: '14px',
fontWeight: '600',
cursor: 'pointer',
}}
>
Children
</button>
</div>
</div>
{/* Venue */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Venue
</label>
<input
type="text"
placeholder="e.g. Main Auditorium"
value={venue}
onChange={(e) => setVenue(e.target.value)}
required
style={{
width: '100%',
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
boxSizing: 'border-box',
}}
/>
</div>
{/* Dates */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Start Time
</label>
<div
style={{
background: '#eef2ec',
borderRadius: '12px',
padding: '4px 14px',
display: 'flex',
alignItems: 'center',
}}
>
<IonDatetime
presentation="date-time"
value={startAt}
onIonChange={(e) => setStartAt(e.detail.value as string)}
style={{ background: 'transparent' }}
/>
</div>
</div>
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
End Time (Optional)
</label>
<div
style={{
background: '#eef2ec',
borderRadius: '12px',
padding: '4px 14px',
display: 'flex',
alignItems: 'center',
}}
>
<IonDatetime
presentation="date-time"
value={endAt}
onIonChange={(e) =>
setEndAt((e.detail.value as string) || '')
}
showClearButton={true}
style={{ background: 'transparent' }}
/>
</div>
</div>
{/* Description */}
<div>
<label
style={{
display: 'block',
marginBottom: '6px',
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Description
</label>
<textarea
placeholder="Describe the event..."
value={description}
onChange={(e) => setDescription(e.target.value)}
required
style={{
width: '100%',
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '14px',
minHeight: '120px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
resize: 'vertical',
boxSizing: 'border-box',
}}
/>
</div>
{/* Featured Toggle */}
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '8px 0',
}}
>
<span
style={{
fontSize: '14px',
fontWeight: '600',
color: '#1f2937',
}}
>
Feature on Home Screen
</span>
<button
type="button"
onClick={() => setIsFeatured(!isFeatured)}
style={{
width: '44px',
height: '24px',
background: isFeatured ? '#2f6b4f' : '#eef2ec',
borderRadius: '12px',
border: 'none',
position: 'relative',
cursor: 'pointer',
transition: '0.2s',
}}
>
<div
style={{
width: '20px',
height: '20px',
background: '#ffffff',
borderRadius: '50%',
position: 'absolute',
top: '2px',
left: isFeatured ? '22px' : '2px',
transition: '0.2s',
}}
/>
</button>
</div>
<button
type="submit"
disabled={saving}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
marginTop: '8px',
}}
>
{saving ? (
<IonSpinner name="dots" color="light" />
) : isEditMode ? (
'Update Event'
) : (
'Create Event'
)}
</button>
{isEditMode && (
<button
type="button"
onClick={handleDelete}
disabled={saving}
style={{
background: 'rgba(163, 59, 50, 0.10)',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#a33b32',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
Delete Event
</button>
)}
</form>
</>
)}
</IonContent>
</IonPage>
);
};
export default AdminEventForm;
+330
View File
@@ -0,0 +1,330 @@
import React, { useState, useEffect } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonButtons,
IonButton,
IonIcon,
IonSpinner,
IonItem,
IonLabel,
IonInput,
IonTextarea,
} from '@ionic/react';
import { useHistory, useParams } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../contexts/AuthContext';
import { chevronBackOutline, saveOutline, trashOutline } from 'ionicons/icons';
const AdminNewsForm: React.FC = () => {
const history = useHistory();
const { id } = useParams<{ id: string }>();
const isEdit = !!id && id !== 'new';
const { user, profile } = useAuth();
const [loading, setLoading] = useState(false);
const [initialLoading, setInitialLoading] = useState(isEdit);
const [error, setError] = useState<string | null>(null);
const [title, setTitle] = useState('');
const [content, setContent] = useState('');
const [imageUrl, setImageUrl] = useState('');
const showError = (msg: string) => {
setError(msg);
setTimeout(() => setError(null), 4000);
};
useEffect(() => {
if (profile?.role !== 'admin') {
history.replace('/profile');
return;
}
if (isEdit) {
loadNewsItem();
}
}, [profile, isEdit]);
const loadNewsItem = async () => {
try {
const { data, error } = await supabase
.from('news')
.select('*')
.eq('id', id)
.single();
if (error) throw error;
if (data) {
setTitle(data.title);
setContent(data.content);
setImageUrl(data.image_url || '');
}
} catch (err: any) {
showError(err.message);
} finally {
setInitialLoading(false);
}
};
const handleSave = async () => {
if (!title.trim() || !content.trim()) {
showError('Title and content are required.');
return;
}
setLoading(true);
try {
if (isEdit) {
const { error } = await supabase
.from('news')
.update({
title,
content,
image_url: imageUrl.trim() || null,
})
.eq('id', id);
if (error) throw error;
} else {
const { error } = await supabase.from('news').insert({
title,
content,
image_url: imageUrl.trim() || null,
created_by: user!.id,
});
if (error) throw error;
}
history.goBack();
} catch (err: any) {
showError(err.message);
setLoading(false);
}
};
const handleDelete = async () => {
if (!window.confirm('Delete this news item?')) return;
setLoading(true);
try {
const { error } = await supabase.from('news').delete().eq('id', id);
if (error) throw error;
history.goBack();
} catch (err: any) {
showError(err.message);
setLoading(false);
}
};
if (initialLoading) {
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
</IonButtons>
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '40px',
}}
>
<IonSpinner name="crescent" />
</div>
</IonContent>
</IonPage>
);
}
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
</IonButtons>
<IonTitle style={{ fontWeight: '700', fontSize: '18px' }}>
{isEdit ? 'Edit News' : 'Create News'}
</IonTitle>
{isEdit && (
<IonButtons slot="end">
<IonButton onClick={handleDelete} color="danger">
<IonIcon icon={trashOutline} slot="icon-only" />
</IonButton>
</IonButtons>
)}
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<div style={{ padding: '20px', maxWidth: '600px', margin: '0 auto' }}>
{error && (
<div
style={{
background: '#fee2e2',
color: '#991b1b',
padding: '12px',
borderRadius: '8px',
fontSize: '14px',
marginBottom: '20px',
}}
>
{error}
</div>
)}
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '20px',
display: 'flex',
flexDirection: 'column',
gap: '16px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<div>
<label
style={{
display: 'block',
fontSize: '12px',
fontWeight: '600',
color: '#4b5563',
marginBottom: '8px',
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}
>
Title
</label>
<IonItem
lines="none"
style={{
'--background': '#f9faf9',
'--border-radius': '12px',
'--padding-start': '16px',
}}
>
<IonInput
value={title}
onIonChange={(e) => setTitle(e.detail.value!)}
placeholder="Enter news title"
style={{ fontWeight: '500' }}
/>
</IonItem>
</div>
<div>
<label
style={{
display: 'block',
fontSize: '12px',
fontWeight: '600',
color: '#4b5563',
marginBottom: '8px',
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}
>
Image URL (Optional)
</label>
<IonItem
lines="none"
style={{
'--background': '#f9faf9',
'--border-radius': '12px',
'--padding-start': '16px',
}}
>
<IonInput
value={imageUrl}
onIonChange={(e) => setImageUrl(e.detail.value!)}
placeholder="https://example.com/image.jpg"
/>
</IonItem>
</div>
<div>
<label
style={{
display: 'block',
fontSize: '12px',
fontWeight: '600',
color: '#4b5563',
marginBottom: '8px',
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}
>
Content
</label>
<IonItem
lines="none"
style={{
'--background': '#f9faf9',
'--border-radius': '12px',
'--padding-start': '16px',
alignItems: 'flex-start',
}}
>
<IonTextarea
value={content}
onIonChange={(e) => setContent(e.detail.value!)}
placeholder="Write your news update here..."
autoGrow
style={{ minHeight: '150px' }}
/>
</IonItem>
</div>
</div>
<button
onClick={handleSave}
disabled={loading}
style={{
width: '100%',
background: '#2f6b4f',
color: '#ffffff',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '16px',
fontWeight: '600',
marginTop: '24px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '8px',
cursor: loading ? 'not-allowed' : 'pointer',
opacity: loading ? 0.7 : 1,
}}
>
{loading ? (
<IonSpinner
name="crescent"
style={{ width: '24px', height: '24px' }}
/>
) : (
<>
<IonIcon icon={saveOutline} />
Save News
</>
)}
</button>
</div>
</IonContent>
</IonPage>
);
};
export default AdminNewsForm;
-123
View File
@@ -1,123 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonPage,
IonSelect,
IonSelectOption,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { chevronBackOutline } from 'ionicons/icons';
import { RouteComponentProps, useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import type { Tables } from '../database.types';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Props = RouteComponentProps<{ id: string }>;
type Order = Tables<'orders'>;
type OrderItem = Tables<'order_items'>;
const statuses = ['confirmed', 'packed', 'out_for_delivery', 'delivered'];
const AdminOrderDetail: React.FC<Props> = ({ match }) => {
const history = useHistory();
const [order, setOrder] = useState<Order | null>(null);
const [items, setItems] = useState<OrderItem[]>([]);
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Dark);
});
const loadOrder = async () => {
const [{ data: orderData }, { data: itemData }] = await Promise.all([
supabase.from('orders').select('*').eq('id', match.params.id).single(),
supabase.from('order_items').select('*').eq('order_id', match.params.id),
]);
setOrder(orderData ?? null);
setItems(itemData ?? []);
};
useEffect(() => {
loadOrder();
}, [match.params.id]);
const updateStatus = async (status: string) => {
await supabase.from('orders').update({ status }).eq('id', match.params.id);
loadOrder();
};
if (!order)
return (
<IonPage>
<IonContent />
</IonPage>
);
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to admin orders"
onClick={() => history.replace('/admin/orders')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Admin order</span>
<strong>{order.order_number}</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<div className="tracking-summary-card">
<div className="delivery-detail-row">
<span>Customer</span>
<strong>{order.customer_name || '—'}</strong>
</div>
<div className="delivery-detail-row">
<span>Phone</span>
<strong>{order.customer_phone || '—'}</strong>
</div>
<div className="delivery-detail-row delivery-detail-block">
<span>Address</span>
<strong>{order.delivery_address || '—'}</strong>
</div>
<IonSelect
value={order.status}
interface="action-sheet"
onIonChange={(e) => updateStatus(e.detail.value)}
>
{statuses.map((status) => (
<IonSelectOption key={status} value={status}>
{status.replace(/_/g, ' ')}
</IonSelectOption>
))}
</IonSelect>
</div>
<IonList lines="none" className="cart-list">
{items.map((item) => (
<IonItem key={item.id} className="cart-item">
<IonLabel>
<h2>{item.product_name}</h2>
<p>Qty {item.quantity}</p>
</IonLabel>
</IonItem>
))}
</IonList>
</IonContent>
</IonPage>
);
};
export default AdminOrderDetail;
-109
View File
@@ -1,109 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonPage,
IonSelect,
IonSelectOption,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { chevronBackOutline } from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import type { Tables } from '../database.types';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Order = Tables<'orders'>;
const statuses = ['confirmed', 'packed', 'out_for_delivery', 'delivered'];
const AdminOrders: React.FC = () => {
const history = useHistory();
const [orders, setOrders] = useState<Order[]>([]);
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Dark);
});
const loadOrders = async () => {
const { data } = await supabase
.from('orders')
.select('*')
.order('created_at', { ascending: false });
setOrders(data ?? []);
};
useEffect(() => {
loadOrders();
}, []);
const updateStatus = async (orderId: string, status: string) => {
await supabase.from('orders').update({ status }).eq('id', orderId);
loadOrders();
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to profile"
onClick={() => history.replace('/profile')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Admin</span>
<strong>Orders</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<IonList lines="none" className="orders-list">
{orders.map((order) => (
<IonItem
key={order.id}
className="cart-item admin-order-item"
button
onClick={() => history.push(`/admin/orders/${order.id}`)}
>
<IonLabel>
<h2>{order.order_number}</h2>
<p>
{order.customer_name || 'Customer'} · $
{Number(order.total).toFixed(2)}
</p>
</IonLabel>
<IonSelect
value={order.status}
interface="popover"
onIonChange={(e) => {
e.stopPropagation();
updateStatus(order.id, e.detail.value);
}}
>
{statuses.map((status) => (
<IonSelectOption key={status} value={status}>
{status.replace(/_/g, ' ')}
</IonSelectOption>
))}
</IonSelect>
</IonItem>
))}
</IonList>
</IonContent>
</IonPage>
);
};
export default AdminOrders;
+284 -186
View File
@@ -1,221 +1,319 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
IonButton,
IonContent,
IonHeader,
IonInput,
IonItem,
IonLabel,
IonPage, IonPage,
IonText, IonContent,
IonTitle, IonSpinner,
IonToolbar,
IonToggle,
useIonViewWillEnter, useIonViewWillEnter,
} from '@ionic/react'; } from '@ionic/react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase'; import { supabase } from '../supabase';
import { setStatusBarStyle, Style } from '../utils/statusBar'; import { useAuth } from '../contexts/AuthContext';
const Auth: React.FC = () => { const Auth: React.FC = () => {
const history = useHistory(); const [activeTab, setActiveTab] = useState<'login' | 'register'>('login');
const [mode, setMode] = useState<'login' | 'signup'>('login');
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const [message, setMessage] = useState(''); const [confirmPassword, setConfirmPassword] = useState('');
const [errorMessage, setErrorMessage] = useState(''); const [loading, setLoading] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false); const [error, setError] = useState<string | null>(null);
const [demoMode, setDemoMode] = useState(true);
const history = useHistory();
const { user, profile } = useAuth();
useIonViewWillEnter(() => { useIonViewWillEnter(() => {
setStatusBarStyle(Style.Light); setActiveTab('login');
setError(null);
}); });
const showError = (msg: string) => { const loadProfileAndNavigate = () => {
setErrorMessage(msg); if (!user) return;
window.setTimeout(() => setErrorMessage(''), 4000); if (profile !== undefined && profile === null) {
}; history.replace('/setup-profile');
} else if (profile !== undefined && profile !== null) {
const showMessage = (msg: string) => {
setMessage(msg);
window.setTimeout(() => setMessage(''), 4000);
};
const normaliseAuthError = (msg: string) => {
const lowered = msg.toLowerCase();
if (lowered.includes('email not confirmed')) {
return 'Please confirm your email before signing in. Check your inbox for the verification email.';
}
if (lowered.includes('invalid login credentials')) {
return 'Incorrect email or password. Please try again.';
}
if (lowered.includes('user already registered')) {
return 'An account with this email already exists. Please sign in instead.';
}
return msg;
};
const handleResendConfirmation = async () => {
if (!email.trim()) {
showError(
'Enter your email address first so we can resend the confirmation email.'
);
return;
}
setIsSubmitting(true);
const { error } = await supabase.auth.resend({
type: 'signup',
email: email.trim(),
});
setIsSubmitting(false);
if (error) {
showError(normaliseAuthError(error.message));
return;
}
showMessage('Confirmation email sent. Please check your inbox.');
};
const handleSubmit = async () => {
if (demoMode && mode === 'login') {
history.replace('/wallet');
return;
}
if (!email.trim() || password.trim().length < 6) {
showError('Enter a valid email and password with at least 6 characters.');
return;
}
setIsSubmitting(true);
if (mode === 'login') {
const { error } = await supabase.auth.signInWithPassword({
email: email.trim(),
password,
});
setIsSubmitting(false);
if (error) {
showError(normaliseAuthError(error.message));
return;
}
history.replace('/home'); history.replace('/home');
return;
} }
};
const { data, error } = await supabase.auth.signUp({ useEffect(() => {
email: email.trim(), if (user) {
loadProfileAndNavigate();
}
}, [user, profile]);
const showError = (msg: string) => {
setError(msg);
setTimeout(() => setError(null), 4000);
};
const handleSignIn = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
setError(null);
const { error } = await supabase.auth.signInWithPassword({
email,
password, password,
}); });
setIsSubmitting(false);
if (error) { if (error) {
showError(normaliseAuthError(error.message)); if (error.message.toLowerCase().includes('email not confirmed')) {
await supabase.auth.resend({ type: 'signup', email });
history.push('/verify-email', { email, resent: true });
setLoading(false);
return;
} else {
showError(error.message);
}
setLoading(false);
return; return;
} }
// Success: keep loading=true — useEffect above navigates when user arrives in context
};
if (data.session) { const handleSignUp = async (e: React.FormEvent) => {
history.replace('/home'); e.preventDefault();
if (password !== confirmPassword) {
showError('Passwords do not match');
return; return;
} }
setLoading(true);
setError(null);
const { error } = await supabase.auth.signUp({ email, password });
if (error) {
showError(error.message);
setLoading(false);
return;
}
history.push('/verify-email', { email });
setLoading(false);
};
showMessage('Account created! Check your email for a verification link.'); const handleTabChange = (tab: 'login' | 'register') => {
setActiveTab(tab);
setError(null);
if (tab === 'login') {
setConfirmPassword('');
}
}; };
return ( return (
<IonPage> <IonPage style={{ background: '#f6f1e8' }}>
<IonHeader className="ion-no-border"> <IonContent
<IonToolbar> style={{
<IonTitle> '--background': 'linear-gradient(180deg, #f9f5ee 0%, #f3ede3 100%)',
{mode === 'login' ? 'Welcome back' : 'Create account'} '--padding-start': '0px',
</IonTitle> '--padding-end': '0px',
</IonToolbar> '--padding-top': '0px',
</IonHeader> '--padding-bottom': '0px',
<IonContent className="ion-padding auth-page"> }}
<div className="auth-card"> >
<h1> <div
{mode === 'login' style={{
? 'Sign in to continue' padding:
: 'Create your shopping account'} 'calc(var(--ion-safe-area-top, 0px) + 18px) 20px calc(var(--ion-safe-area-bottom, 0px) + 28px)',
</h1> minHeight: '100%',
<p className="muted-text"> display: 'flex',
Save your orders, addresses, and track deliveries securely. flexDirection: 'column',
</p> }}
>
{errorMessage && ( {/* Welcome header block */}
<IonText color="danger"> <div
<p>{errorMessage}</p> style={{
</IonText> background: 'transparent',
)} borderRadius: '0px',
{message && ( padding: '0px',
<IonText color="success"> margin: '0 0 24px 0',
<p>{message}</p> display: 'flex',
</IonText> flexDirection: 'column',
)} gap: '8px',
}}
<div className="auth-form"> >
<IonItem lines="none" className="auth-input-item auth-toggle-item"> <h1
<IonLabel>Demo quick access</IonLabel> style={{
<IonToggle margin: 0,
checked={demoMode} fontSize: '24px',
onIonChange={(e) => setDemoMode(e.detail.checked)} fontWeight: '700',
/> color: '#1f2937',
</IonItem> lineHeight: '1.2',
<IonText className="auth-helper-text"> }}
<p>
When enabled, Sign in opens the app immediately so you can
review the full experience without authentication.
</p>
</IonText>
<IonItem lines="none" className="auth-input-item">
<IonLabel position="stacked">Email</IonLabel>
<IonInput
value={email}
type="email"
disabled={demoMode && mode === 'login'}
onIonInput={(e) => setEmail(e.detail.value ?? '')}
/>
</IonItem>
<IonItem lines="none" className="auth-input-item">
<IonLabel position="stacked">Password</IonLabel>
<IonInput
value={password}
type="password"
disabled={demoMode && mode === 'login'}
onIonInput={(e) => setPassword(e.detail.value ?? '')}
/>
</IonItem>
<IonButton
expand="block"
onClick={handleSubmit}
disabled={isSubmitting}
> >
{mode === 'login' ? 'Sign in' : 'Create account'} EAGLES ASSEMBLY
</IonButton> </h1>
{mode === 'login' && ( <p
<IonButton style={{
fill="clear" margin: 0,
expand="block" fontSize: '14px',
onClick={handleResendConfirmation} fontWeight: '400',
disabled={isSubmitting} color: '#6b7280',
> lineHeight: '1.5',
Resend confirmation email }}
</IonButton>
)}
<IonButton
fill="clear"
expand="block"
onClick={() => setMode(mode === 'login' ? 'signup' : 'login')}
> >
{mode === 'login' Welcome back to our community app
? 'Need an account? Sign up' </p>
: 'Already have an account? Sign in'}
</IonButton>
</div> </div>
{/* Auth mode pill switcher */}
<div
style={{
background: '#ffffff',
borderRadius: '999px',
padding: '4px',
margin: '0 0 20px 0',
display: 'flex',
gap: '4px',
}}
>
<button
onClick={() => handleTabChange('login')}
style={{
flex: 1,
background: activeTab === 'login' ? '#2f6b4f' : 'transparent',
border: 'none',
borderRadius: '999px',
padding: '12px 18px',
fontSize: '14px',
fontWeight: '600',
color: activeTab === 'login' ? '#ffffff' : '#6b7280',
cursor: 'pointer',
}}
>
Login
</button>
<button
onClick={() => handleTabChange('register')}
style={{
flex: 1,
background:
activeTab === 'register' ? '#2f6b4f' : 'transparent',
border: 'none',
borderRadius: '999px',
padding: '12px 18px',
fontSize: '14px',
fontWeight: '600',
color: activeTab === 'register' ? '#ffffff' : '#6b7280',
cursor: 'pointer',
}}
>
Register
</button>
</div>
{/* Form card */}
<form
onSubmit={activeTab === 'login' ? handleSignIn : handleSignUp}
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '16px',
}}
>
<input
type="email"
placeholder="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
style={{
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
}}
/>
<input
type="password"
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
style={{
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
}}
/>
{activeTab === 'register' && (
<input
type="password"
placeholder="Confirm password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
style={{
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
}}
/>
)}
<button
type="submit"
disabled={loading}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
marginTop: '8px',
}}
>
{loading ? (
<IonSpinner name="dots" color="light" />
) : activeTab === 'login' ? (
'Sign In'
) : (
'Create Account'
)}
</button>
</form>
{/* Error area */}
{error && (
<div
style={{
background: 'rgba(190, 60, 60, 0.10)',
borderRadius: '12px',
padding: '12px 14px',
margin: '0',
display: 'flex',
}}
>
<p
style={{
margin: 0,
fontSize: '13px',
fontWeight: '500',
color: '#a33b32',
lineHeight: '1.4',
}}
>
{error}
</p>
</div>
)}
</div> </div>
</IonContent> </IonContent>
</IonPage> </IonPage>
-529
View File
@@ -1,529 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonLoading,
IonPage,
IonSelect,
IonSelectOption,
IonTextarea,
IonText,
IonTitle,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import {
addOutline,
bagHandleOutline,
chevronBackOutline,
removeOutline,
timeOutline,
trashOutline,
} from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import type { Tables, TablesInsert } from '../database.types';
import { useAuth } from '../context/AuthContext';
import { CartItem, LAST_ORDER_STORAGE_KEY, readCart, writeCart } from './Home';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Address = Tables<'addresses'>;
type CheckoutForm = {
customerName: string;
customerPhone: string;
deliveryAddress: string;
deliveryNotes: string;
addressId: string;
};
type FormErrors = Partial<Record<keyof CheckoutForm, string>>;
type SavedOrderInfo = {
id: string;
orderNumber: string;
total: number;
itemCount: number;
status: string;
customerName: string;
customerPhone: string;
deliveryAddress: string;
deliveryNotes: string;
};
const initialForm: CheckoutForm = {
customerName: '',
customerPhone: '',
deliveryAddress: '',
deliveryNotes: '',
addressId: '',
};
const Cart: React.FC = () => {
const history = useHistory();
const { user, profile } = useAuth();
const [cart, setCart] = useState<CartItem[]>([]);
const [addresses, setAddresses] = useState<Address[]>([]);
const [isSubmitting, setIsSubmitting] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [form, setForm] = useState<CheckoutForm>(initialForm);
const [formErrors, setFormErrors] = useState<FormErrors>({});
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Dark);
});
useEffect(() => {
setCart(readCart());
}, []);
useEffect(() => {
const syncCartFromStorage = () => setCart(readCart());
window.addEventListener('storage', syncCartFromStorage);
window.addEventListener(
'cart:updated',
syncCartFromStorage as EventListener
);
return () => {
window.removeEventListener('storage', syncCartFromStorage);
window.removeEventListener(
'cart:updated',
syncCartFromStorage as EventListener
);
};
}, []);
useEffect(() => {
const loadAddresses = async () => {
if (!user) {
setAddresses([]);
setForm((current) => ({
...current,
customerName: current.customerName || profile?.full_name || '',
customerPhone: current.customerPhone || profile?.phone || '',
addressId: '',
}));
return;
}
const { data } = await supabase
.from('addresses')
.select('*')
.eq('user_id', user.id)
.order('is_default', { ascending: false });
const nextAddresses = data ?? [];
setAddresses(nextAddresses);
const defaultAddress =
nextAddresses.find((address) => address.is_default) ?? nextAddresses[0];
setForm((current) => ({
...current,
customerName:
current.customerName ||
profile?.full_name ||
defaultAddress?.recipient_name ||
'',
customerPhone:
current.customerPhone ||
profile?.phone ||
defaultAddress?.phone ||
'',
deliveryAddress:
current.deliveryAddress || defaultAddress?.address_line || '',
deliveryNotes: current.deliveryNotes || defaultAddress?.notes || '',
addressId: defaultAddress?.id || '',
}));
};
void loadAddresses();
}, [user?.id, profile?.full_name, profile?.phone]);
const syncCart = (nextCart: CartItem[]) => {
setCart(nextCart);
writeCart(nextCart);
};
const showError = (message: string) => {
setErrorMessage(message);
window.setTimeout(() => setErrorMessage(''), 4000);
};
const handleFieldChange = (field: keyof CheckoutForm, value: string) => {
setForm((current) => ({ ...current, [field]: value }));
if (formErrors[field]) {
setFormErrors((current) => ({ ...current, [field]: undefined }));
}
};
const handleAddressSelect = (addressId: string) => {
const selected = addresses.find((address) => address.id === addressId);
if (!selected) return;
setForm((current) => ({
...current,
addressId,
customerName: selected.recipient_name,
customerPhone: selected.phone,
deliveryAddress: selected.address_line,
deliveryNotes: selected.notes || '',
}));
};
const validateForm = () => {
const nextErrors: FormErrors = {};
if (!form.customerName.trim()) {
nextErrors.customerName = 'Please enter the customer name.';
}
if (form.customerPhone.trim().replace(/\D/g, '').length < 7) {
nextErrors.customerPhone = 'Please enter a valid phone number.';
}
if (form.deliveryAddress.trim().length < 10) {
nextErrors.deliveryAddress =
'Please add a more complete delivery address.';
}
setFormErrors(nextErrors);
return Object.keys(nextErrors).length === 0;
};
const itemCount = useMemo(
() => cart.reduce((sum, item) => sum + item.quantity, 0),
[cart]
);
const subtotal = useMemo(
() => cart.reduce((sum, item) => sum + item.price * item.quantity, 0),
[cart]
);
const deliveryFee = cart.length > 0 ? 2.99 : 0;
const total = subtotal + deliveryFee;
const updateQuantity = (id: string, delta: number) =>
syncCart(
cart
.map((item) =>
item.id === id ? { ...item, quantity: item.quantity + delta } : item
)
.filter((item) => item.quantity > 0)
);
const removeItem = (id: string) =>
syncCart(cart.filter((item) => item.id !== id));
const placeOrder = async () => {
if (cart.length === 0 || isSubmitting) return;
if (!validateForm()) {
showError('Please complete the checkout form before placing the order.');
return;
}
setIsSubmitting(true);
const orderNumber = `QC-${Date.now().toString().slice(-6)}`;
const orderPayload: TablesInsert<'orders'> = {
order_number: orderNumber,
subtotal,
delivery_fee: deliveryFee,
total,
item_count: itemCount,
status: 'confirmed',
customer_name: form.customerName.trim(),
customer_phone: form.customerPhone.trim(),
delivery_address: form.deliveryAddress.trim(),
delivery_notes: form.deliveryNotes.trim() || null,
user_id: user?.id ?? null,
address_id: user ? form.addressId || null : null,
};
const { data: order, error: orderError } = await supabase
.from('orders')
.insert(orderPayload)
.select()
.single();
if (orderError || !order) {
setIsSubmitting(false);
showError('We could not place your order. Please try again.');
return;
}
const itemsPayload: TablesInsert<'order_items'>[] = cart.map((item) => ({
order_id: order.id,
product_id: item.id,
product_name: item.name,
unit_price: item.price,
quantity: item.quantity,
}));
const { error: itemsError } = await supabase
.from('order_items')
.insert(itemsPayload);
if (itemsError) {
await supabase.from('orders').delete().eq('id', order.id);
setIsSubmitting(false);
showError('We could not save your order items. Please try again.');
return;
}
const savedOrder: SavedOrderInfo = {
id: order.id,
orderNumber: order.order_number,
total: Number(order.total),
itemCount: order.item_count,
status: order.status,
customerName: order.customer_name ?? '',
customerPhone: order.customer_phone ?? '',
deliveryAddress: order.delivery_address ?? '',
deliveryNotes: order.delivery_notes ?? '',
};
localStorage.setItem(LAST_ORDER_STORAGE_KEY, JSON.stringify(savedOrder));
writeCart([]);
setCart([]);
setIsSubmitting(false);
history.replace('/order-confirmation');
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to home"
onClick={() => history.replace('/home')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Checkout</span>
<strong>Basket</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent fullscreen className="hybrid-page-surface ion-padding">
<IonLoading isOpen={isSubmitting} message="Placing your order..." />
{errorMessage && (
<IonText color="danger">
<p>{errorMessage}</p>
</IonText>
)}
{cart.length === 0 ? (
<div className="empty-state reference-empty-state cart-empty">
<IonIcon icon={bagHandleOutline} />
<h3>Your basket is empty</h3>
<p className="muted-text">
Add your first product to place an order.
</p>
<IonButton onClick={() => history.push('/home')}>
Browse products
</IonButton>
</div>
) : (
<div className="reference-cart-layout">
<div className="reference-cart-summary-strip">
<div>
<p className="overview-label">Items in basket</p>
<h2>
{itemCount} item{itemCount === 1 ? '' : 's'}
</h2>
</div>
<div className="summary-time-pill">
<IonIcon icon={timeOutline} />
<span>Arrives in 60 min</span>
</div>
</div>
<IonList lines="none" className="cart-list reference-cart-list">
{cart.map((item) => (
<IonItem
key={item.id}
className="cart-item reference-cart-item"
>
<IonLabel>
<h2>{item.name}</h2>
<p>${item.price.toFixed(2)} each</p>
<strong>${(item.price * item.quantity).toFixed(2)}</strong>
</IonLabel>
<div className="cart-actions reference-cart-actions">
<IonButton
fill="clear"
onClick={() => updateQuantity(item.id, -1)}
>
<IonIcon icon={removeOutline} />
</IonButton>
<span>{item.quantity}</span>
<IonButton
fill="clear"
onClick={() => updateQuantity(item.id, 1)}
>
<IonIcon icon={addOutline} />
</IonButton>
<IonButton
fill="clear"
color="danger"
onClick={() => removeItem(item.id)}
>
<IonIcon icon={trashOutline} />
</IonButton>
</div>
</IonItem>
))}
</IonList>
<div className="checkout-card reference-checkout-card">
<div className="section-heading checkout-heading">
<div>
<h2>Delivery details</h2>
<IonText color="medium">
<p>Complete this to confirm your order</p>
</IonText>
</div>
</div>
{user && addresses.length > 0 && (
<div className="form-field full-width">
<IonLabel position="stacked">Saved address</IonLabel>
<IonSelect
value={form.addressId}
placeholder="Choose a saved address"
className="checkout-input"
onIonChange={(e) => handleAddressSelect(e.detail.value)}
>
{addresses.map((address) => (
<IonSelectOption key={address.id} value={address.id}>
{address.label} · {address.address_line}
</IonSelectOption>
))}
</IonSelect>
</div>
)}
<div className="checkout-form-grid">
<div className="form-field">
<IonLabel position="stacked">Customer name</IonLabel>
<IonInput
value={form.customerName}
placeholder="Enter full name"
className="checkout-input"
onIonInput={(e) =>
handleFieldChange('customerName', e.detail.value ?? '')
}
/>
{formErrors.customerName && (
<IonText color="danger" className="field-error">
<p>{formErrors.customerName}</p>
</IonText>
)}
</div>
<div className="form-field">
<IonLabel position="stacked">Phone number</IonLabel>
<IonInput
value={form.customerPhone}
type="tel"
inputmode="tel"
placeholder="e.g. +263 77 123 4567"
className="checkout-input"
onIonInput={(e) =>
handleFieldChange('customerPhone', e.detail.value ?? '')
}
/>
{formErrors.customerPhone && (
<IonText color="danger" className="field-error">
<p>{formErrors.customerPhone}</p>
</IonText>
)}
</div>
<div className="form-field full-width">
<IonLabel position="stacked">Delivery address</IonLabel>
<IonTextarea
value={form.deliveryAddress}
autoGrow
rows={3}
placeholder="House number, street, suburb, city"
className="checkout-input checkout-textarea"
onIonInput={(e) =>
handleFieldChange('deliveryAddress', e.detail.value ?? '')
}
/>
{formErrors.deliveryAddress && (
<IonText color="danger" className="field-error">
<p>{formErrors.deliveryAddress}</p>
</IonText>
)}
</div>
<div className="form-field full-width">
<IonLabel position="stacked">Delivery notes</IonLabel>
<IonTextarea
value={form.deliveryNotes}
autoGrow
rows={3}
placeholder="Gate code, landmark, or helpful instructions"
className="checkout-input checkout-textarea"
onIonInput={(e) =>
handleFieldChange('deliveryNotes', e.detail.value ?? '')
}
/>
</div>
</div>
{user && (
<IonButton
fill="outline"
expand="block"
className="detail-secondary-button"
onClick={() => history.push('/addresses')}
>
Manage saved addresses
</IonButton>
)}
</div>
<div className="summary-card reference-order-total-card">
<div className="summary-row">
<IonText color="medium">Items</IonText>
<strong>{itemCount}</strong>
</div>
<div className="summary-row">
<IonText color="medium">Subtotal</IonText>
<strong>${subtotal.toFixed(2)}</strong>
</div>
<div className="summary-row">
<IonText color="medium">Delivery</IonText>
<strong>${deliveryFee.toFixed(2)}</strong>
</div>
<div className="summary-row total-row">
<span>Total</span>
<strong>${total.toFixed(2)}</strong>
</div>
<IonButton
expand="block"
className="reference-place-order-button"
onClick={placeOrder}
disabled={isSubmitting}
>
Place order
</IonButton>
</div>
</div>
)}
</IonContent>
</IonPage>
);
};
export default Cart;
+380
View File
@@ -0,0 +1,380 @@
import React, { useState, useEffect } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonButtons,
IonButton,
IonIcon,
IonSpinner,
} from '@ionic/react';
import { useHistory, useParams } from 'react-router-dom';
import { supabase } from '../supabase';
import { ChurchEvent } from '../types';
import { useAuth } from '../contexts/AuthContext';
import {
chevronBackOutline,
createOutline,
timeOutline,
locationOutline,
calendarOutline,
} from 'ionicons/icons';
const EventDetail: React.FC = () => {
const [event, setEvent] = useState<ChurchEvent | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const { id } = useParams<{ id: string }>();
const history = useHistory();
const { profile } = useAuth();
const loadEvent = async () => {
setLoading(true);
setError(null);
const { data, error: fetchError } = await supabase
.from('events')
.select('*, event_categories(*)')
.eq('id', id)
.single();
if (fetchError) {
setError(fetchError.message);
setEvent(null);
} else {
setEvent(data as ChurchEvent);
}
setLoading(false);
};
useEffect(() => {
loadEvent();
}, [id]);
const goToEdit = () => {
if (!event) return;
history.push(`/admin/events/${event.id}/edit`);
};
const isAdmin = profile?.role === 'admin';
return (
<IonPage style={{ background: '#f5f7f4' }}>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon
icon={chevronBackOutline}
style={{ color: '#1f2937' }}
slot="icon-only"
/>
</IonButton>
</IonButtons>
<IonTitle
style={{ fontSize: '18px', fontWeight: '700', color: '#1f2937' }}
>
Event Detail
</IonTitle>
{isAdmin && (
<IonButtons slot="end">
<IonButton onClick={goToEdit}>
<IonIcon
icon={createOutline}
style={{ color: '#2f6b4f', fontSize: '20px' }}
slot="icon-only"
/>
</IonButton>
</IonButtons>
)}
</IonToolbar>
</IonHeader>
<IonContent
style={{
'--background': '#f5f7f4',
'--padding-start': '20px',
'--padding-end': '20px',
'--padding-top': '16px',
'--padding-bottom': '24px',
}}
>
{loading ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
padding: '40px 0',
}}
>
<IonSpinner name="crescent" color="primary" />
</div>
) : error || !event ? (
<div
style={{
padding: '12px',
background: 'rgba(190,60,60,0.1)',
borderRadius: '12px',
color: '#a33b32',
fontSize: '13px',
}}
>
{error || 'Event not found'}
</div>
) : (
<>
{/* Header Detail Card */}
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '10px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<div style={{ display: 'flex' }}>
<div
style={{
background: 'rgba(47, 107, 79, 0.10)',
color: '#2f6b4f',
borderRadius: '999px',
padding: '5px 12px',
fontSize: '12px',
fontWeight: '600',
}}
>
{event.event_categories?.name || 'Event'}
</div>
</div>
<h1
style={{
margin: 0,
fontSize: '24px',
fontWeight: '700',
color: '#1f2937',
}}
>
{event.title}
</h1>
</div>
{/* Info Rows Card */}
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '20px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '14px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
{/* Date Row */}
<div
style={{ display: 'flex', alignItems: 'center', gap: '12px' }}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: 'rgba(47, 107, 79, 0.12)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={calendarOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div>
<div
style={{
fontSize: '12px',
fontWeight: '600',
color: '#7a847f',
}}
>
Date
</div>
<div
style={{
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
marginTop: '2px',
}}
>
{new Date(event.start_at).toLocaleDateString(undefined, {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
})}
</div>
</div>
</div>
{/* Time Row */}
{(() => {
const date = new Date(event.start_at);
const hasTime =
date.getHours() !== 0 || date.getMinutes() !== 0;
if (!hasTime) return null;
return (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: '12px',
}}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: 'rgba(47, 107, 79, 0.12)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={timeOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div>
<div
style={{
fontSize: '12px',
fontWeight: '600',
color: '#7a847f',
}}
>
Time
</div>
<div
style={{
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
marginTop: '2px',
}}
>
{date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
})}
{event.end_at &&
` - ${new Date(event.end_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
</div>
</div>
</div>
);
})()}
{/* Location Row */}
<div
style={{ display: 'flex', alignItems: 'center', gap: '12px' }}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: 'rgba(47, 107, 79, 0.12)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={locationOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div>
<div
style={{
fontSize: '12px',
fontWeight: '600',
color: '#7a847f',
}}
>
Location
</div>
<div
style={{
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
marginTop: '2px',
}}
>
{event.venue}
</div>
</div>
</div>
</div>
{/* About Card */}
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '20px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '10px',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<h3
style={{
margin: 0,
fontSize: '16px',
fontWeight: '700',
color: '#1f2937',
}}
>
About
</h3>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#4b5563',
lineHeight: '1.6',
whiteSpace: 'pre-wrap',
}}
>
{event.description}
</p>
</div>
</>
)}
</IonContent>
</IonPage>
);
};
export default EventDetail;
+350
View File
@@ -0,0 +1,350 @@
import React, { useState } from 'react';
import {
IonPage,
IonContent,
IonSpinner,
useIonViewWillEnter,
IonIcon,
IonRefresher,
IonRefresherContent,
} from '@ionic/react';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { ChurchEvent } from '../types';
import EventListCard from '../components/EventListCard';
import {
searchOutline,
filterOutline,
calendarClearOutline,
} from 'ionicons/icons';
const Events: React.FC = () => {
const [allEvents, setAllEvents] = useState<ChurchEvent[]>([]);
const [events, setEvents] = useState<ChurchEvent[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [searchTerm, setSearchTerm] = useState('');
const [activeCategory, setActiveCategory] = useState<
'all' | 'weekly' | 'youth' | 'sunday-school'
>('all');
const history = useHistory();
const loadEvents = async (event?: any) => {
if (!event) setLoading(true);
setError(null);
const now = new Date();
now.setDate(now.getDate() - 1);
const dateString = now.toISOString();
const { data, error: fetchError } = await supabase
.from('events')
.select('*, event_categories(*)')
.gte('start_at', dateString)
.order('start_at', { ascending: true });
if (fetchError) {
setError(fetchError.message);
setAllEvents([]);
setEvents([]);
} else {
const fetched = data as ChurchEvent[];
setAllEvents(fetched);
applyFilters(fetched, activeCategory, searchTerm);
}
setLoading(false);
if (event) {
event.detail.complete();
}
};
useIonViewWillEnter(() => {
loadEvents();
});
const applyFilters = (
source: ChurchEvent[],
category: 'all' | 'weekly' | 'youth' | 'sunday-school',
search: string
) => {
let filtered = [...source];
if (category === 'weekly') {
filtered = filtered.filter((e) => e.event_categories?.slug === 'weekly');
} else if (category === 'youth') {
filtered = filtered.filter(
(e) => e.event_categories?.slug === 'youth' || e.audience === 'youth'
);
} else if (category === 'sunday-school') {
filtered = filtered.filter(
(e) => e.event_categories?.slug === 'sunday-school'
);
}
if (search.trim()) {
const term = search.toLowerCase();
filtered = filtered.filter(
(e) =>
e.title.toLowerCase().includes(term) ||
e.description.toLowerCase().includes(term) ||
e.venue.toLowerCase().includes(term)
);
}
setEvents(filtered);
};
const handleCategoryChange = (
category: 'all' | 'weekly' | 'youth' | 'sunday-school'
) => {
setActiveCategory(category);
applyFilters(allEvents, category, searchTerm);
};
const handleSearchChange = (val: string) => {
setSearchTerm(val);
applyFilters(allEvents, activeCategory, val);
};
const openEvent = (id: string) => {
history.push(`/event/${id}`);
};
return (
<IonPage style={{ background: '#f5f7f4' }}>
<IonContent
style={{
'--background': '#f5f7f4',
'--padding-start': '0px',
'--padding-end': '0px',
'--padding-top': '0px',
'--padding-bottom': '24px',
}}
>
<IonRefresher slot="fixed" onIonRefresh={loadEvents}>
<IonRefresherContent />
</IonRefresher>
{/* Top Title Row */}
<div
style={{
padding: 'calc(16px + var(--ion-safe-area-top)) 20px 8px',
margin: '0',
background: 'transparent',
display: 'flex',
flexDirection: 'column',
gap: '6px',
}}
>
<h1
style={{
margin: 0,
fontSize: '24px',
fontWeight: '700',
color: '#1f2937',
}}
>
Events
</h1>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
Discover what's happening at church
</p>
</div>
{/* Search Row */}
<div style={{ display: 'flex', gap: '8px', margin: '0 20px 12px' }}>
<div
style={{
flex: 1,
background: '#ffffff',
borderRadius: '24px',
height: '44px',
display: 'flex',
alignItems: 'center',
padding: '0 16px',
gap: '10px',
}}
>
<IonIcon
icon={searchOutline}
style={{ color: '#9aa3a0', fontSize: '18px', flexShrink: 0 }}
/>
<input
type="text"
placeholder="Search events..."
value={searchTerm}
onChange={(e) => handleSearchChange(e.target.value)}
style={{
flex: 1,
border: 'none',
background: 'transparent',
outline: 'none',
fontSize: '15px',
color: '#1f2937',
}}
/>
</div>
<div
onClick={() => handleCategoryChange('all')}
style={{
width: '44px',
height: '44px',
background: '#ffffff',
borderRadius: '12px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
cursor: 'pointer',
}}
>
<IonIcon
icon={filterOutline}
style={{ color: '#2f6b4f', fontSize: '20px' }}
/>
</div>
</div>
{/* Category Chips */}
<div
style={{
display: 'flex',
gap: '8px',
margin: '0 20px 12px',
overflowX: 'auto',
paddingBottom: '4px',
WebkitOverflowScrolling: 'touch',
scrollbarWidth: 'none',
}}
>
{['all', 'weekly', 'youth', 'sunday-school'].map((cat) => (
<button
key={cat}
onClick={() => handleCategoryChange(cat as any)}
style={{
background: activeCategory === cat ? '#2f6b4f' : '#ffffff',
color: activeCategory === cat ? '#ffffff' : '#4b5563',
border: 'none',
borderRadius: '999px',
padding: '8px 14px',
fontSize: '13px',
fontWeight: '600',
cursor: 'pointer',
whiteSpace: 'nowrap',
boxShadow:
activeCategory === cat
? 'none'
: '0 1px 2px rgba(0,0,0,0.02)',
}}
>
{cat === 'all'
? 'All Events'
: cat === 'sunday-school'
? 'Sunday School'
: cat.charAt(0).toUpperCase() + cat.slice(1)}
</button>
))}
</div>
{/* Main Content */}
{loading ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
padding: '40px 0',
}}
>
<IonSpinner name="crescent" color="primary" />
</div>
) : error ? (
<div
style={{
margin: '0 20px',
padding: '12px',
background: 'rgba(190,60,60,0.1)',
borderRadius: '12px',
color: '#a33b32',
fontSize: '13px',
}}
>
{error}
</div>
) : events.length > 0 ? (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: '12px',
margin: '0 20px',
}}
>
{events.map((event) => (
<EventListCard
key={event.id}
event={event}
onClick={() => openEvent(event.id)}
/>
))}
</div>
) : (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: '60px 20px',
textAlign: 'center',
gap: '12px',
}}
>
<IonIcon
icon={calendarClearOutline}
style={{ fontSize: '44px', color: '#7a847f' }}
/>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
No events match this filter.
</p>
<button
onClick={() => {
setSearchTerm('');
handleCategoryChange('all');
}}
style={{
background: 'transparent',
border: 'none',
fontSize: '14px',
fontWeight: '600',
color: '#2f6b4f',
cursor: 'pointer',
marginTop: '4px',
}}
>
Show all events
</button>
</div>
)}
</IonContent>
</IonPage>
);
};
export default Events;
+549 -800
View File
File diff suppressed because it is too large Load Diff
-197
View File
@@ -1,197 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonList,
IonPage,
IonRefresher,
IonRefresherContent,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import {
chevronBackOutline,
chevronForwardOutline,
receiptOutline,
} from 'ionicons/icons';
import { RefresherEventDetail } from '@ionic/core';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import type { Tables } from '../database.types';
import { useAuth } from '../context/AuthContext';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Order = Tables<'orders'>;
const statusCopy: Record<string, string> = {
confirmed: 'Confirmed',
packed: 'Packed',
out_for_delivery: 'Out for delivery',
delivered: 'Delivered',
};
const MyOrders: React.FC = () => {
const history = useHistory();
const { user } = useAuth();
const [orders, setOrders] = useState<Order[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [errorMessage, setErrorMessage] = useState('');
useIonViewWillEnter(() => {
void setStatusBarStyle(Style.Dark);
});
const loadOrders = async () => {
if (!user) {
setOrders([]);
setErrorMessage('');
setIsLoading(false);
return;
}
try {
setErrorMessage('');
const { data, error } = await supabase
.from('orders')
.select('*')
.eq('user_id', user.id)
.order('created_at', { ascending: false });
if (error) {
throw error;
}
setOrders(data ?? []);
} catch (error) {
console.error('Failed to load orders', error);
setOrders([]);
setErrorMessage('We could not load your orders right now.');
window.setTimeout(() => setErrorMessage(''), 4000);
} finally {
setIsLoading(false);
}
};
useEffect(() => {
if (!user) {
setOrders([]);
setErrorMessage('');
setIsLoading(false);
return;
}
setIsLoading(true);
void loadOrders();
}, [user?.id]);
const handleRefresh = async (event: CustomEvent<RefresherEventDetail>) => {
await loadOrders();
event.detail.complete();
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to home"
onClick={() => history.replace('/home')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Tracking</span>
<strong>My Orders</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<IonRefresher slot="fixed" onIonRefresh={handleRefresh}>
<IonRefresherContent />
</IonRefresher>
{errorMessage && (
<IonText color="danger">
<p>{errorMessage}</p>
</IonText>
)}
{!user ? (
<div className="empty-state cart-empty">
<IonIcon icon={receiptOutline} />
<h3>No tracked orders yet</h3>
<p className="muted-text">
Sign in later to sync orders, or place an order now and track it
from the confirmation screen.
</p>
<IonButton onClick={() => history.push('/home')}>
Continue shopping
</IonButton>
</div>
) : isLoading ? (
<div className="empty-state cart-empty">
<IonIcon icon={receiptOutline} />
<h3>Loading your orders</h3>
<p className="muted-text">
We are fetching your latest order updates.
</p>
</div>
) : orders.length === 0 ? (
<div className="empty-state cart-empty">
<IonIcon icon={receiptOutline} />
<h3>No orders yet</h3>
<p className="muted-text">
Your placed orders will appear here so you can track their status.
</p>
<IonButton onClick={() => history.push('/home')}>
Start shopping
</IonButton>
</div>
) : (
<IonList lines="none" className="orders-list">
{orders.map((order) => (
<button
key={order.id}
type="button"
className="order-card"
onClick={() => history.push(`/orders/${order.id}`)}
>
<div className="order-card-top">
<div>
<span className="order-label">Order</span>
<h3>{order.order_number}</h3>
</div>
<IonIcon icon={chevronForwardOutline} />
</div>
<div className="order-card-row">
<span>Status</span>
<strong>{statusCopy[order.status] ?? order.status}</strong>
</div>
<div className="order-card-row">
<span>Items</span>
<strong>{order.item_count}</strong>
</div>
<div className="order-card-row">
<span>Total</span>
<strong>${Number(order.total).toFixed(2)}</strong>
</div>
<div className="order-card-date">
{new Date(order.created_at).toLocaleString()}
</div>
</button>
))}
</IonList>
)}
</IonContent>
</IonPage>
);
};
export default MyOrders;
+229
View File
@@ -0,0 +1,229 @@
import React, { useState } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonSpinner,
useIonViewWillEnter,
IonRefresher,
IonRefresherContent,
IonButtons,
IonButton,
IonIcon,
} from '@ionic/react';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../contexts/AuthContext';
import { NewsItem } from '../types';
import { addOutline, newspaperOutline } from 'ionicons/icons';
const News: React.FC = () => {
const history = useHistory();
const { profile } = useAuth();
const [news, setNews] = useState<NewsItem[]>([]);
const [loading, setLoading] = useState(true);
const fetchNews = async () => {
try {
const { data, error } = await supabase
.from('news')
.select('*')
.order('created_at', { ascending: false });
if (error) throw error;
setNews(data || []);
} catch (err) {
console.error('Error fetching news:', err);
} finally {
setLoading(false);
}
};
useIonViewWillEnter(() => {
fetchNews();
});
const doRefresh = async (event: any) => {
await fetchNews();
event.detail.complete();
};
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonTitle
style={{ fontWeight: '700', fontSize: '24px', color: '#1f2937' }}
>
News
</IonTitle>
{profile?.role === 'admin' && (
<IonButtons slot="end">
<IonButton onClick={() => history.push('/admin/news/new')}>
<IonIcon icon={addOutline} style={{ color: '#2f6b4f' }} />
</IonButton>
</IonButtons>
)}
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<IonRefresher slot="fixed" onIonRefresh={doRefresh}>
<IonRefresherContent />
</IonRefresher>
<div style={{ padding: '0 20px 20px' }}>
{loading ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '40px',
}}
>
<IonSpinner name="crescent" />
</div>
) : news.length === 0 ? (
<div
style={{
textAlign: 'center',
padding: '60px 20px',
color: '#6b7280',
}}
>
<IonIcon
icon={newspaperOutline}
style={{
fontSize: '48px',
color: '#cbd5e1',
marginBottom: '16px',
}}
/>
<p style={{ margin: 0, fontSize: '16px', fontWeight: '500' }}>
No news yet.
</p>
{profile?.role === 'admin' && (
<button
onClick={() => history.push('/admin/news/new')}
style={{
background: '#2f6b4f',
color: '#fff',
border: 'none',
borderRadius: '999px',
padding: '10px 20px',
fontWeight: '600',
marginTop: '20px',
cursor: 'pointer',
}}
>
Create Post
</button>
)}
</div>
) : (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: '16px',
paddingTop: '8px',
}}
>
{news.map((item) => (
<div
key={item.id}
onClick={() => history.push(`/news/${item.id}`)}
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '16px',
display: 'flex',
gap: '16px',
cursor: 'pointer',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
alignItems: 'center',
}}
>
{item.image_url ? (
<img
src={item.image_url}
alt=""
style={{
width: '80px',
height: '80px',
borderRadius: '16px',
objectFit: 'cover',
flexShrink: 0,
background: '#f1f5f9',
}}
/>
) : (
<div
style={{
width: '80px',
height: '80px',
borderRadius: '16px',
background: 'rgba(47, 107, 79, 0.1)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={newspaperOutline}
style={{ color: '#2f6b4f', fontSize: '28px' }}
/>
</div>
)}
<div
style={{
flex: 1,
minWidth: 0,
display: 'flex',
flexDirection: 'column',
gap: '6px',
}}
>
<div
style={{
fontSize: '12px',
fontWeight: '600',
color: '#9ca3af',
}}
>
{new Date(item.created_at).toLocaleDateString(undefined, {
month: 'short',
day: 'numeric',
year: 'numeric',
})}
</div>
<div
style={{
fontSize: '16px',
fontWeight: '700',
color: '#1f2937',
lineHeight: '1.3',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
}}
>
{item.title}
</div>
</div>
</div>
))}
</div>
)}
</div>
</IonContent>
</IonPage>
);
};
export default News;
+187
View File
@@ -0,0 +1,187 @@
import React, { useState } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonButtons,
IonButton,
IonIcon,
IonSpinner,
useIonViewWillEnter,
} from '@ionic/react';
import { useHistory, useParams } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../contexts/AuthContext';
import { NewsItem } from '../types';
import { chevronBackOutline, createOutline } from 'ionicons/icons';
const NewsDetail: React.FC = () => {
const history = useHistory();
const { id } = useParams<{ id: string }>();
const { profile } = useAuth();
const [news, setNews] = useState<NewsItem | null>(null);
const [loading, setLoading] = useState(true);
useIonViewWillEnter(() => {
fetchNewsItem();
});
const fetchNewsItem = async () => {
try {
const { data, error } = await supabase
.from('news')
.select('*')
.eq('id', id)
.single();
if (error) throw error;
setNews(data);
} catch (err) {
console.error('Error fetching news:', err);
} finally {
setLoading(false);
}
};
if (loading) {
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
</IonButtons>
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '40px',
}}
>
<IonSpinner name="crescent" />
</div>
</IonContent>
</IonPage>
);
}
if (!news) {
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
</IonButtons>
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<div
style={{ textAlign: 'center', marginTop: '60px', color: '#6b7280' }}
>
News item not found.
</div>
</IonContent>
</IonPage>
);
}
return (
<IonPage>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonButtons slot="start">
<IonButton onClick={() => history.goBack()}>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
</IonButtons>
{profile?.role === 'admin' && (
<IonButtons slot="end">
<IonButton onClick={() => history.push(`/admin/news/${news.id}`)}>
<IonIcon
icon={createOutline}
slot="icon-only"
style={{ color: '#2f6b4f' }}
/>
</IonButton>
</IonButtons>
)}
</IonToolbar>
</IonHeader>
<IonContent style={{ '--background': '#f5f7f4' }}>
<div
style={{
padding: '0 20px 40px',
maxWidth: '600px',
margin: '0 auto',
}}
>
{news.image_url && (
<div style={{ marginBottom: '24px' }}>
<img
src={news.image_url}
alt=""
style={{
width: '100%',
height: '240px',
objectFit: 'cover',
borderRadius: '24px',
background: '#eef2ec',
}}
/>
</div>
)}
<div
style={{
fontSize: '14px',
fontWeight: '600',
color: '#2f6b4f',
marginBottom: '12px',
}}
>
{new Date(news.created_at).toLocaleDateString(undefined, {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
})}
</div>
<h1
style={{
margin: '0 0 24px',
fontSize: '28px',
fontWeight: '800',
color: '#1f2937',
lineHeight: '1.2',
}}
>
{news.title}
</h1>
<div
style={{
fontSize: '16px',
color: '#4b5563',
lineHeight: '1.6',
whiteSpace: 'pre-wrap',
}}
>
{news.content}
</div>
</div>
</IonContent>
</IonPage>
);
};
export default NewsDetail;
-163
View File
@@ -1,163 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonPage,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { checkmarkCircle, chevronBackOutline } from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { LAST_ORDER_STORAGE_KEY } from './Home';
import {
setStatusBarBackground,
setStatusBarStyle,
Style,
} from '../utils/statusBar';
type OrderInfo = {
id: string;
orderNumber: string;
total: number;
itemCount: number;
status: string;
customerName: string;
customerPhone: string;
deliveryAddress: string;
deliveryNotes: string;
};
const OrderConfirmation: React.FC = () => {
const history = useHistory();
const [order, setOrder] = useState<OrderInfo | null>(null);
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Dark);
setStatusBarBackground('#ffffff');
});
useEffect(() => {
try {
const savedOrder = localStorage.getItem(LAST_ORDER_STORAGE_KEY);
if (!savedOrder) {
setOrder(null);
return;
}
setOrder(JSON.parse(savedOrder) as OrderInfo);
} catch {
setOrder(null);
}
}, []);
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to home"
onClick={() => history.replace('/home')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Success</span>
<strong>Order placed</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<div className="confirmation-card">
<IonIcon icon={checkmarkCircle} color="success" />
<h1>Thanks for your order!</h1>
<p className="muted-text">
Your order has been placed successfully and is now being prepared.
</p>
{order ? (
<>
<div className="confirmation-details">
<div>
<span>Order number</span>
<strong>{order.orderNumber}</strong>
</div>
<div>
<span>Status</span>
<strong>{order.status.replaceAll('_', ' ')}</strong>
</div>
<div>
<span>Items</span>
<strong>{order.itemCount}</strong>
</div>
<div>
<span>Total paid</span>
<strong>${order.total.toFixed(2)}</strong>
</div>
</div>
<div className="delivery-details-card">
<h2>Delivery information</h2>
<div className="delivery-detail-row">
<span>Customer</span>
<strong>{order.customerName}</strong>
</div>
<div className="delivery-detail-row">
<span>Phone</span>
<strong>{order.customerPhone}</strong>
</div>
<div className="delivery-detail-row delivery-detail-block">
<span>Address</span>
<strong>{order.deliveryAddress}</strong>
</div>
{order.deliveryNotes && (
<div className="delivery-detail-row delivery-detail-block">
<span>Notes</span>
<strong>{order.deliveryNotes}</strong>
</div>
)}
</div>
</>
) : (
<p className="muted-text">
We could not load the order summary, but your next browse session
is ready.
</p>
)}
{order && (
<IonButton
expand="block"
onClick={() => history.replace(`/orders/${order.id}`)}
>
Track this order
</IonButton>
)}
<IonButton
fill="outline"
expand="block"
onClick={() => history.replace('/orders')}
>
View all orders
</IonButton>
<IonButton
fill="clear"
expand="block"
onClick={() => history.replace('/home')}
>
Continue shopping
</IonButton>
</div>
</IonContent>
</IonPage>
);
};
export default OrderConfirmation;
-246
View File
@@ -1,246 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react';
import {
IonButton,
IonContent,
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonList,
IonLoading,
IonPage,
IonRefresher,
IonRefresherContent,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { RefresherEventDetail } from '@ionic/core';
import { chevronBackOutline } from 'ionicons/icons';
import { RouteComponentProps, useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import type { Tables } from '../database.types';
import { useAuth } from '../context/AuthContext';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Props = RouteComponentProps<{ id: string }>;
type Order = Tables<'orders'>;
type OrderItem = Tables<'order_items'>;
const statusSteps = [
'confirmed',
'packed',
'out_for_delivery',
'delivered',
] as const;
const statusTitles: Record<(typeof statusSteps)[number], string> = {
confirmed: 'Confirmed',
packed: 'Packed',
out_for_delivery: 'Out for delivery',
delivered: 'Delivered',
};
const OrderDetail: React.FC<Props> = ({ match }) => {
const history = useHistory();
const { user } = useAuth();
const [order, setOrder] = useState<Order | null>(null);
const [items, setItems] = useState<OrderItem[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [errorMessage, setErrorMessage] = useState('');
useIonViewWillEnter(() => {
void setStatusBarStyle(Style.Dark);
});
const loadOrder = async () => {
if (!user) {
setIsLoading(false);
return;
}
setIsLoading(true);
const [
{ data: orderData, error: orderError },
{ data: itemData, error: itemError },
] = await Promise.all([
supabase
.from('orders')
.select('*')
.eq('id', match.params.id)
.eq('user_id', user.id)
.single(),
supabase
.from('order_items')
.select('*')
.eq('order_id', match.params.id)
.order('created_at', { ascending: true }),
]);
if (orderError || itemError || !orderData) {
setErrorMessage('We could not load this order.');
window.setTimeout(() => setErrorMessage(''), 4000);
setOrder(null);
setItems([]);
setIsLoading(false);
return;
}
setOrder(orderData);
setItems(itemData ?? []);
setIsLoading(false);
};
useEffect(() => {
void loadOrder();
}, [match.params.id, user?.id]);
const activeStepIndex = useMemo(
() =>
order
? Math.max(
statusSteps.indexOf(order.status as (typeof statusSteps)[number]),
0
)
: 0,
[order]
);
const handleRefresh = async (event: CustomEvent<RefresherEventDetail>) => {
await loadOrder();
event.detail.complete();
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to orders"
onClick={() => history.replace('/orders')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Tracking</span>
<strong>Order details</strong>
</div>
<span className="wallet-toolbar-placeholder" />
</div>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<IonRefresher slot="fixed" onIonRefresh={handleRefresh}>
<IonRefresherContent />
</IonRefresher>
<IonLoading isOpen={isLoading} message="Loading order details..." />
{errorMessage && (
<IonText color="danger">
<p>{errorMessage}</p>
</IonText>
)}
{!user ? (
<div className="empty-state cart-empty">
<h3>Sign in to view order details</h3>
<IonButton onClick={() => history.replace('/auth')}>
Sign in
</IonButton>
</div>
) : !isLoading && !order ? (
<div className="empty-state cart-empty">
<h3>Order not found</h3>
<p className="muted-text">
We could not find that order. Try returning to your order list.
</p>
<IonButton onClick={() => history.replace('/orders')}>
Back to orders
</IonButton>
</div>
) : (
order && (
<>
<div className="tracking-summary-card">
<span className="order-label">Order number</span>
<h1>{order.order_number}</h1>
<p className="muted-text">
Placed on {new Date(order.created_at).toLocaleString()}
</p>
<div className="order-card-row">
<span>Current status</span>
<strong>
{statusTitles[
order.status as (typeof statusSteps)[number]
] ?? order.status}
</strong>
</div>
<div className="order-card-row">
<span>Total</span>
<strong>${Number(order.total).toFixed(2)}</strong>
</div>
</div>
<div className="timeline-card">
<h2>Delivery progress</h2>
<div className="tracking-timeline">
{statusSteps.map((step, index) => (
<div
key={step}
className={`timeline-step ${index <= activeStepIndex ? 'active' : ''}`}
>
<div className="timeline-dot" />
<div>
<strong>{statusTitles[step]}</strong>
<p className="muted-text">
{index < activeStepIndex
? 'Completed'
: index === activeStepIndex
? 'Current step'
: 'Up next'}
</p>
</div>
</div>
))}
</div>
</div>
<div className="timeline-card delivery-details-card">
<h2>Delivery details</h2>
<div className="delivery-detail-row">
<span>Customer</span>
<strong>{order.customer_name || '—'}</strong>
</div>
<div className="delivery-detail-row">
<span>Phone</span>
<strong>{order.customer_phone || '—'}</strong>
</div>
<div className="delivery-detail-row delivery-detail-block">
<span>Address</span>
<strong>{order.delivery_address || '—'}</strong>
</div>
{order.delivery_notes && (
<div className="delivery-detail-row delivery-detail-block">
<span>Notes</span>
<strong>{order.delivery_notes}</strong>
</div>
)}
</div>
<div className="timeline-card">
<h2>Items in this order</h2>
<IonList lines="none" className="cart-list">
{items.map((item) => (
<IonItem key={item.id} className="cart-item">
<IonLabel>
<h2>{item.product_name}</h2>
<p>${Number(item.unit_price).toFixed(2)} each</p>
<strong>
Qty {item.quantity} · $
{(Number(item.unit_price) * item.quantity).toFixed(2)}
</strong>
</IonLabel>
</IonItem>
))}
</IonList>
</div>
</>
)
)}
</IonContent>
</IonPage>
);
};
export default OrderDetail;
-352
View File
@@ -1,352 +0,0 @@
import React, { useEffect, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonLoading,
IonPage,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import {
addOutline,
cardOutline,
checkmarkCircleOutline,
chevronBackOutline,
trashOutline,
} from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../context/AuthContext';
import type { Tables } from '../database.types';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type PaymentMethodRow = Tables<'payment_methods'>;
type DisplayPaymentMethod = Pick<
PaymentMethodRow,
| 'id'
| 'brand'
| 'last4'
| 'expiry_month'
| 'expiry_year'
| 'is_default'
| 'cardholder_name'
>;
const formatExpiry = (month: number, year: number) =>
`${String(month).padStart(2, '0')}/${String(year).slice(-2)}`;
const PaymentMethods: React.FC = () => {
const history = useHistory();
const { user } = useAuth();
const [methods, setMethods] = useState<PaymentMethodRow[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [message, setMessage] = useState('');
const [error, setError] = useState('');
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Light);
});
const showMessage = (text: string) => {
setMessage(text);
window.setTimeout(() => setMessage(''), 4000);
};
const loadMethods = async () => {
if (!user) {
setMethods([]);
setIsLoading(false);
return;
}
setIsLoading(true);
setError('');
const { data, error: loadError } = await supabase
.from('payment_methods')
.select('*')
.eq('user_id', user.id)
.order('is_default', { ascending: false })
.order('created_at', { ascending: false });
if (loadError) {
setError('Unable to load your payment methods.');
}
setMethods(data ?? []);
setIsLoading(false);
};
useEffect(() => {
void loadMethods();
}, [user]);
const setDefaultMethod = async (methodId: string) => {
if (!user) return;
await supabase
.from('payment_methods')
.update({ is_default: false })
.eq('user_id', user.id);
const { error: updateError } = await supabase
.from('payment_methods')
.update({ is_default: true })
.eq('id', methodId)
.eq('user_id', user.id);
if (updateError) {
setError('Could not update your default payment method.');
return;
}
showMessage('Default payment method updated.');
void loadMethods();
};
const renderCardVisual = (method: DisplayPaymentMethod) => (
<div className="payment-method-visual-card">
<div className="wallet-card-top-row">
<div className="wallet-card-chip" />
<span className="wallet-card-brand">{method.brand.toUpperCase()}</span>
</div>
<div className="wallet-card-number"> {method.last4}</div>
<div className="wallet-card-meta-row">
<div>
<span>Cardholder</span>
<strong>{method.cardholder_name || 'Saved Card'}</strong>
</div>
<div className="wallet-card-meta-right">
<span>Valid Thru</span>
<strong>
{formatExpiry(method.expiry_month, method.expiry_year)}
</strong>
</div>
</div>
</div>
);
const removeMethod = async (method: PaymentMethodRow) => {
const { error: deleteError } = await supabase
.from('payment_methods')
.delete()
.eq('id', method.id)
.eq('user_id', method.user_id);
if (deleteError) {
setError('Could not remove that payment method.');
return;
}
if (method.is_default && user) {
const { data: remaining } = await supabase
.from('payment_methods')
.select('id')
.eq('user_id', user.id)
.order('created_at', { ascending: false })
.limit(1);
const nextId = remaining?.[0]?.id;
if (nextId) {
await supabase
.from('payment_methods')
.update({ is_default: true })
.eq('id', nextId)
.eq('user_id', user.id);
}
}
showMessage('Payment method removed.');
void loadMethods();
};
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to wallet"
onClick={() => history.replace('/wallet')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Wallet</span>
<strong>Payment methods</strong>
</div>
<IonButton
fill="clear"
className="wallet-header-add-button"
aria-label="Add payment method"
onClick={() => history.push('/wallet/payment-methods/add')}
>
<IonIcon icon={addOutline} slot="icon-only" />
</IonButton>
</div>
</IonToolbar>
</IonHeader>
<IonContent
fullscreen
className="wallet-page wallet-page-vibrant payment-methods-page ion-padding"
>
<IonLoading isOpen={isLoading} message="Loading payment methods..." />
{!user ? (
<>
<div className="payment-methods-hero-card">
<span>Cards & checkout</span>
<h1>Payment methods</h1>
<p>
Review saved cards, choose the checkout default, and keep wallet
payments ready for faster ordering.
</p>
</div>
<div className="payment-method-grid">
{[
{
id: 'demo-visa',
brand: 'visa',
last4: '4242',
expiry_month: 8,
expiry_year: 2028,
is_default: true,
cardholder_name: 'Demo User',
},
{
id: 'demo-mastercard',
brand: 'mastercard',
last4: '1881',
expiry_month: 11,
expiry_year: 2027,
is_default: false,
cardholder_name: 'Demo User',
},
].map((method) => (
<div
key={method.id}
className="payment-method-detail-card-modern"
>
{renderCardVisual(method)}
<div className="payment-method-card-footer">
<div>
{method.is_default ? (
<span className="payment-status-pill active">
<IonIcon icon={checkmarkCircleOutline} />
Checkout card
</span>
) : (
<span className="payment-status-pill">Backup card</span>
)}
</div>
<div className="payment-method-modern-actions">
{!method.is_default && (
<IonButton fill="outline" size="small" disabled>
Set default
</IonButton>
)}
<IonButton fill="clear" color="medium" disabled>
<IonIcon icon={trashOutline} slot="icon-only" />
</IonButton>
</div>
</div>
</div>
))}
</div>
</>
) : (
<>
<div className="payment-methods-hero-card">
<span>Cards & checkout</span>
<h1>Payment methods</h1>
<p>
Store masked card details so checkout is quicker next time. You
can choose one card as your checkout default.
</p>
</div>
{message && (
<IonText color="success">
<p className="wallet-inline-message">{message}</p>
</IonText>
)}
{error && (
<IonText color="danger">
<p className="wallet-inline-message">{error}</p>
</IonText>
)}
{methods.length === 0 ? (
<div className="wallet-surface-card wallet-empty-block">
<IonIcon icon={cardOutline} />
<div>
<h3>No payment methods yet</h3>
<p>Add your first card to make repeat ordering faster.</p>
</div>
<IonButton
expand="block"
onClick={() => history.push('/wallet/payment-methods/add')}
>
<IonIcon icon={addOutline} slot="start" />
Add your first card
</IonButton>
</div>
) : (
<div className="payment-method-grid">
{methods.map((method) => (
<div
key={method.id}
className="payment-method-detail-card-modern"
>
{renderCardVisual(method)}
<div className="payment-method-card-footer">
<div>
{method.is_default ? (
<span className="payment-status-pill active">
<IonIcon icon={checkmarkCircleOutline} />
Checkout card
</span>
) : (
<span className="payment-status-pill">
Backup card
</span>
)}
</div>
<div className="payment-method-modern-actions">
{!method.is_default && (
<IonButton
fill="outline"
size="small"
onClick={() => setDefaultMethod(method.id)}
>
Set default
</IonButton>
)}
<IonButton
fill="clear"
color="danger"
aria-label="Remove payment method"
onClick={() => removeMethod(method)}
>
<IonIcon icon={trashOutline} slot="icon-only" />
</IonButton>
</div>
</div>
</div>
))}
</div>
)}
</>
)}
</IonContent>
</IonPage>
);
};
export default PaymentMethods;
-205
View File
@@ -1,205 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonIcon,
IonPage,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { cartOutline, chevronBackOutline } from 'ionicons/icons';
import { RouteComponentProps, useHistory } from 'react-router-dom';
import { CartItem, products, readCart, writeCart } from './Home';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type Props = RouteComponentProps<{ id: string }>;
const ProductDetail: React.FC<Props> = ({ match }) => {
const history = useHistory();
const [quantity, setQuantity] = useState(1);
const [message, setMessage] = useState('');
const [cartCount, setCartCount] = useState(0);
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Light);
const count = readCart().reduce((sum, item) => sum + item.quantity, 0);
setCartCount(count);
});
useEffect(() => {
const syncCount = () => {
const count = readCart().reduce((sum, item) => sum + item.quantity, 0);
setCartCount(count);
};
syncCount();
window.addEventListener('storage', syncCount);
window.addEventListener('cart:updated', syncCount as EventListener);
return () => {
window.removeEventListener('storage', syncCount);
window.removeEventListener('cart:updated', syncCount as EventListener);
};
}, []);
const product = useMemo(
() => products.find((item) => item.id === match.params.id),
[match.params.id]
);
const showMessage = (text: string) => {
setMessage(text);
window.setTimeout(() => setMessage(''), 4000);
};
const addToCart = () => {
if (!product) return;
const cart: CartItem[] = readCart();
const existing = cart.find((item) => item.id === product.id);
const nextCart = existing
? cart.map((item) =>
item.id === product.id
? { ...item, quantity: item.quantity + quantity }
: item
)
: [
...cart,
{
id: product.id,
name: product.name,
price: product.price,
quantity,
},
];
writeCart(nextCart);
showMessage('Added to basket');
};
if (!product) {
return (
<IonPage>
<IonHeader className="hybrid-subpage-header ion-no-border">
<IonToolbar className="hybrid-subpage-toolbar">
<IonButtons slot="start">
<IonButton fill="clear" onClick={() => history.replace('/home')}>
<IonIcon icon={chevronBackOutline} />
</IonButton>
</IonButtons>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding reference-surface">
<div className="empty-state reference-empty-state">
<h3>Product not found</h3>
<p className="muted-text">This product is no longer available.</p>
<IonButton onClick={() => history.replace('/home')}>
Browse products
</IonButton>
</div>
</IonContent>
</IonPage>
);
}
return (
<IonPage>
<IonContent
fullscreen
className="product-detail-page-surface premium-product-surface"
>
<div className="premium-product-shell">
<div className="premium-product-actions">
<button
type="button"
className="premium-back-circle"
aria-label="Back to products"
onClick={() => history.replace('/home')}
>
<IonIcon icon={chevronBackOutline} />
</button>
<button
type="button"
className="premium-cart-tile"
aria-label="Open basket"
onClick={() => history.push('/cart')}
>
<span className="premium-cart-tile-inner">
<IonIcon icon={cartOutline} />
</span>
{cartCount > 0 && (
<span className="premium-cart-count-bubble">{cartCount}</span>
)}
</button>
</div>
<section className="premium-product-intro">
<h1>{product.name}</h1>
<div className="premium-product-meta-row">
<span className="premium-product-badge">{product.category}</span>
<span>High quality</span>
<span>In stock</span>
</div>
</section>
<section className="premium-product-image-panel">
<img src={product.image} alt={product.imageAlt} />
</section>
<section className="premium-product-details-card">
<div className="premium-details-header">
<h2>Details</h2>
</div>
<p>{product.description}</p>
<div className="premium-buy-row">
<div className="premium-price-block">
<strong>${product.price.toFixed(2)}</strong>
<span>each</span>
</div>
<div className="premium-quantity-control" aria-label="Quantity">
<IonButton
fill="clear"
aria-label="Decrease quantity"
onClick={() => setQuantity((value) => Math.max(1, value - 1))}
>
<span aria-hidden="true"></span>
</IonButton>
<strong>{quantity}</strong>
<IonButton
fill="clear"
aria-label="Increase quantity"
onClick={() => setQuantity((value) => value + 1)}
>
<span aria-hidden="true">+</span>
</IonButton>
</div>
</div>
</section>
{message && (
<IonText color="success" className="premium-product-message">
<p>{message}</p>
</IonText>
)}
</div>
<div className="premium-product-cta">
<div>
<span>Total</span>
<strong>${(product.price * quantity).toFixed(2)}</strong>
</div>
<IonButton onClick={addToCart}>Add to basket</IonButton>
</div>
</IonContent>
</IonPage>
);
};
export default ProductDetail;
+498 -124
View File
@@ -1,144 +1,518 @@
import React, { useEffect, useState } from 'react'; import React, { useRef, useState } from 'react';
import { import { IonPage, IonContent, IonIcon, IonSpinner } from '@ionic/react';
IonButton,
IonContent,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonPage,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import { chevronBackOutline } from 'ionicons/icons';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase'; import { supabase } from '../supabase';
import { useAuth } from '../context/AuthContext'; import { useAuth } from '../contexts/AuthContext';
import { setStatusBarStyle, Style } from '../utils/statusBar'; import {
cameraOutline,
personOutline,
chevronForwardOutline,
settingsOutline,
helpCircleOutline,
} from 'ionicons/icons';
const Profile: React.FC = () => { const Profile: React.FC = () => {
const [signingOut, setSigningOut] = useState(false);
const [uploadingAvatar, setUploadingAvatar] = useState(false);
const [error, setError] = useState<string | null>(null);
const { user, profile, refreshProfile } = useAuth();
const history = useHistory(); const history = useHistory();
const { user, profile, refreshProfile, signOut } = useAuth(); const fileInputRef = useRef<HTMLInputElement | null>(null);
const [fullName, setFullName] = useState('');
const [phone, setPhone] = useState('');
const [message, setMessage] = useState('');
useIonViewWillEnter(() => { const handleSignOut = async () => {
setStatusBarStyle(Style.Dark); setSigningOut(true);
}); setError(null);
const { error: signOutError } = await supabase.auth.signOut();
useEffect(() => { if (signOutError) {
setFullName(profile?.full_name ?? ''); setError(signOutError.message);
setPhone(profile?.phone ?? ''); setSigningOut(false);
}, [profile]); return;
}
const showMessage = (msg: string) => { history.replace('/auth');
setMessage(msg);
window.setTimeout(() => setMessage(''), 4000);
}; };
const saveProfile = async () => { const goToCreateEvent = () => {
if (!user) return; history.push('/admin/events/new');
const { error } = await supabase.from('profiles').upsert({ };
id: user.id,
full_name: fullName.trim() || null,
phone: phone.trim() || null,
updated_at: new Date().toISOString(),
});
if (!error) { const initials = profile?.full_name
await refreshProfile(); ? profile.full_name
showMessage('Profile saved.'); .split(' ')
.map((n) => n[0])
.join('')
.substring(0, 2)
.toUpperCase()
: 'U';
const isAdmin = profile?.role === 'admin';
const avatarUrl = profile?.avatar_url
? `${supabase.storage.from('avatars').getPublicUrl(profile.avatar_url).data.publicUrl}?t=${Date.now()}`
: null;
const showError = (message: string) => {
setError(message);
setTimeout(() => setError(null), 4000);
};
const handleAvatarSelect = async (
event: React.ChangeEvent<HTMLInputElement>
) => {
const file = event.target.files?.[0];
if (!file || !user) {
return;
} }
setUploadingAvatar(true);
setError(null);
const extension = file.name.split('.').pop()?.toLowerCase() || 'jpg';
const filePath = `${user.id}/avatar-${Date.now()}.${extension}`;
const { error: uploadError } = await supabase.storage
.from('avatars')
.upload(filePath, file);
if (uploadError) {
showError(uploadError.message);
setUploadingAvatar(false);
event.target.value = '';
return;
}
const { error: profileError } = await supabase
.from('profiles')
.update({ avatar_url: filePath, updated_at: new Date().toISOString() })
.eq('id', user.id);
if (profileError) {
showError(profileError.message);
setUploadingAvatar(false);
event.target.value = '';
return;
}
await refreshProfile();
setUploadingAvatar(false);
event.target.value = '';
}; };
return ( return (
<IonPage> <IonPage style={{ background: '#f5f7f4' }}>
<IonHeader className="ion-no-border wallet-header wallet-header-modern"> <IonContent
<IonToolbar> style={{
<div className="wallet-toolbar-inner wallet-toolbar-inner-single-action"> '--background': '#f5f7f4',
<IonButton '--padding-start': '0px',
fill="clear" '--padding-end': '0px',
className="wallet-back-button wallet-back-button-modern" '--padding-top': '0px',
aria-label="Back to home" '--padding-bottom': '24px',
onClick={() => history.replace('/home')} }}
> >
<IonIcon icon={chevronBackOutline} slot="icon-only" /> {/* Top Title Row */}
</IonButton> <div
<div className="wallet-toolbar-title-block"> style={{
<span>Account</span> padding: 'calc(16px + var(--ion-safe-area-top)) 20px 8px',
<strong>Profile</strong> margin: '0',
</div> background: 'transparent',
<span className="wallet-toolbar-placeholder" /> display: 'flex',
</div> flexDirection: 'column',
</IonToolbar> gap: '6px',
</IonHeader> }}
<IonContent className="ion-padding"> >
<div className="auth-card"> <h1
<h1>Your account</h1> style={{
<p className="muted-text">Signed in as {user?.email}</p> margin: 0,
{message && ( fontSize: '24px',
<IonText color="success"> fontWeight: '700',
<p>{message}</p> color: '#1f2937',
</IonText> }}
)} >
<div className="auth-form"> Profile
<IonItem lines="none" className="auth-input-item"> </h1>
<IonLabel position="stacked">Full name</IonLabel> <p
<IonInput style={{
value={fullName} margin: 0,
onIonInput={(e) => setFullName(e.detail.value ?? '')} fontSize: '14px',
/> fontWeight: '400',
</IonItem> color: '#6b7280',
<IonItem lines="none" className="auth-input-item"> }}
<IonLabel position="stacked">Phone</IonLabel> >
<IonInput Manage your account
value={phone} </p>
type="tel" </div>
onIonInput={(e) => setPhone(e.detail.value ?? '')}
/> {/* Profile Summary Card */}
</IonItem> <div
<IonButton expand="block" onClick={saveProfile}> style={{
Save profile background: '#ffffff',
</IonButton> borderRadius: '24px',
<IonButton padding: '20px',
expand="block" margin: '0 20px 12px',
fill="outline" display: 'flex',
onClick={() => history.push('/addresses')} alignItems: 'center',
> gap: '12px',
Saved addresses }}
</IonButton> >
<IonButton <div
expand="block" style={{
fill="outline" position: 'relative',
onClick={() => history.push('/wallet')} width: '52px',
> height: '52px',
Wallet & payment methods flexShrink: 0,
</IonButton> }}
{profile?.is_admin && ( >
<IonButton <button
expand="block" onClick={() => fileInputRef.current?.click()}
fill="outline" disabled={uploadingAvatar}
onClick={() => history.push('/admin/orders')} style={{
> width: '52px',
Admin workflow height: '52px',
</IonButton> borderRadius: '16px',
)} background: 'rgba(47, 107, 79, 0.12)',
<IonButton display: 'flex',
color="medium" alignItems: 'center',
expand="block" justifyContent: 'center',
fill="clear" fontSize: '18px',
onClick={async () => { fontWeight: '700',
await signOut(); color: '#2f6b4f',
history.replace('/auth'); flexShrink: 0,
border: 'none',
padding: 0,
overflow: 'hidden',
cursor: uploadingAvatar ? 'default' : 'pointer',
}} }}
> >
Sign out {avatarUrl ? (
</IonButton> <img
src={avatarUrl}
alt={profile?.full_name || 'Profile'}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : (
initials
)}
</button>
<button
onClick={() => fileInputRef.current?.click()}
disabled={uploadingAvatar}
style={{
position: 'absolute',
right: '-4px',
bottom: '-4px',
width: '24px',
height: '24px',
borderRadius: '12px',
border: 'none',
background: '#2f6b4f',
color: '#ffffff',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: uploadingAvatar ? 'default' : 'pointer',
padding: 0,
}}
>
{uploadingAvatar ? (
<IonSpinner
name="crescent"
color="light"
style={{ width: '14px', height: '14px' }}
/>
) : (
<IonIcon icon={cameraOutline} style={{ fontSize: '13px' }} />
)}
</button>
<input
ref={fileInputRef}
type="file"
accept="image/jpeg,image/png,image/webp"
onChange={handleAvatarSelect}
style={{ display: 'none' }}
/>
</div>
<div
style={{
flex: 1,
minWidth: 0,
display: 'flex',
flexDirection: 'column',
gap: '4px',
}}
>
<div
style={{
fontSize: '18px',
fontWeight: '700',
color: '#1f2937',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{profile?.full_name || 'Member'}
</div>
<div
style={{
fontSize: '13px',
fontWeight: '400',
color: '#6b7280',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{profile?.email || ''}
</div>
</div>
{profile?.ministry_group && (
<div
style={{
background: '#eef2ec',
color: '#4b5563',
borderRadius: '999px',
padding: '4px 10px',
fontSize: '12px',
fontWeight: '600',
}}
>
{profile.ministry_group}
</div>
)}
</div>
{/* Settings / Action List Card */}
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '8px 18px',
margin: '0 20px 12px',
display: 'flex',
flexDirection: 'column',
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
}}
>
<div
style={{
minHeight: '56px',
display: 'flex',
alignItems: 'center',
gap: '12px',
}}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: '#eef2ec',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={personOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div
style={{
flex: 1,
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
}}
>
Personal Info
</div>
<IonIcon
icon={chevronForwardOutline}
style={{ color: '#9aa3a0', fontSize: '18px' }}
/>
</div>
<div
style={{
minHeight: '56px',
display: 'flex',
alignItems: 'center',
gap: '12px',
}}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: '#eef2ec',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={settingsOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div
style={{
flex: 1,
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
}}
>
Account Settings
</div>
<IonIcon
icon={chevronForwardOutline}
style={{ color: '#9aa3a0', fontSize: '18px' }}
/>
</div>
<div
style={{
minHeight: '56px',
display: 'flex',
alignItems: 'center',
gap: '12px',
}}
>
<div
style={{
width: '36px',
height: '36px',
borderRadius: '12px',
background: '#eef2ec',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={helpCircleOutline}
style={{ color: '#2f6b4f', fontSize: '18px' }}
/>
</div>
<div
style={{
flex: 1,
fontSize: '15px',
fontWeight: '600',
color: '#1f2937',
}}
>
Help & Support
</div>
<IonIcon
icon={chevronForwardOutline}
style={{ color: '#9aa3a0', fontSize: '18px' }}
/>
</div> </div>
</div> </div>
{/* Admin Shortcut Card */}
{isAdmin && (
<div
style={{
background: 'rgba(47, 107, 79, 0.08)',
borderRadius: '24px',
padding: '18px',
margin: '0 20px 12px',
display: 'flex',
flexDirection: 'column',
gap: '12px',
}}
>
<div
style={{ fontSize: '14px', fontWeight: '600', color: '#2f6b4f' }}
>
Admin Tools
</div>
<button
onClick={goToCreateEvent}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '14px 16px',
fontSize: '14px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
}}
>
Create New Event
</button>
<button
onClick={() => history.push('/admin/news/new')}
style={{
background: 'rgba(47, 107, 79, 0.1)',
border: 'none',
borderRadius: '999px',
padding: '14px 16px',
fontSize: '14px',
fontWeight: '600',
color: '#2f6b4f',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
}}
>
Manage News
</button>
</div>
)}
{/* Sign Out Button */}
<div style={{ margin: '0 20px 24px 20px' }}>
<button
onClick={handleSignOut}
disabled={signingOut}
style={{
background: '#a33b32',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
}}
>
{signingOut ? <IonSpinner name="dots" color="light" /> : 'Sign Out'}
</button>
</div>
{error && (
<div
style={{
margin: '0 20px',
padding: '12px',
background: 'rgba(190,60,60,0.1)',
borderRadius: '12px',
color: '#a33b32',
fontSize: '13px',
}}
>
{error}
</div>
)}
</IonContent> </IonContent>
</IonPage> </IonPage>
); );
+250
View File
@@ -0,0 +1,250 @@
import React, { useState } from 'react';
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonSpinner,
IonSelect,
IonSelectOption,
IonIcon,
} from '@ionic/react';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../contexts/AuthContext';
import { personAddOutline } from 'ionicons/icons';
const SetupProfile: React.FC = () => {
const [fullName, setFullName] = useState('');
const [ministryGroup, setMinistryGroup] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const history = useHistory();
const { user, refreshProfile } = useAuth();
const showError = (msg: string) => {
setError(msg);
setTimeout(() => setError(null), 4000);
};
const handleProfileSetup = async (e: React.FormEvent) => {
e.preventDefault();
if (!fullName.trim()) {
showError('Please enter your name');
return;
}
if (!user) {
showError('No user session found. Please log in again.');
return;
}
setLoading(true);
setError(null);
const { error: insertError } = await supabase.from('profiles').insert({
id: user.id,
email: user.email ?? '',
full_name: fullName.trim(),
role: 'member',
ministry_group: ministryGroup || null,
});
if (insertError) {
showError(insertError.message);
setLoading(false);
return;
}
await refreshProfile();
history.replace('/home');
setLoading(false);
};
return (
<IonPage style={{ background: '#f5f7f4' }}>
<IonHeader className="ion-no-border">
<IonToolbar style={{ '--background': '#f5f7f4' }}>
<IonTitle
style={{ fontSize: '18px', fontWeight: '700', color: '#1f2937' }}
>
Setup Profile
</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent
style={{
'--background': '#f5f7f4',
'--padding-start': '20px',
'--padding-end': '20px',
'--padding-top': '16px',
'--padding-bottom': '20px',
}}
>
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '12px',
}}
>
<div
style={{
background: 'rgba(47, 107, 79, 0.12)',
borderRadius: '12px',
width: '44px',
height: '44px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<IonIcon
icon={personAddOutline}
style={{ fontSize: '20px', color: '#2f6b4f' }}
/>
</div>
<h2
style={{
margin: 0,
fontSize: '20px',
fontWeight: '700',
color: '#1f2937',
}}
>
Welcome to EAGLES ASSEMBLY
</h2>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
Please let us know who you are so we can personalize your
experience.
</p>
</div>
<form
onSubmit={handleProfileSetup}
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '0 0 16px 0',
display: 'flex',
flexDirection: 'column',
gap: '16px',
}}
>
<input
type="text"
placeholder="Full Name (e.g. John Doe)"
value={fullName}
onChange={(e) => setFullName(e.target.value)}
required
style={{
background: '#eef2ec',
border: 'none',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
fontSize: '15px',
color: '#1f2937',
outline: 'none',
}}
/>
<div
style={{
background: '#eef2ec',
borderRadius: '12px',
padding: '0 14px',
height: '48px',
display: 'flex',
alignItems: 'center',
}}
>
<IonSelect
value={ministryGroup}
placeholder="Select Ministry Group (Optional)"
onIonChange={(e) => setMinistryGroup(e.detail.value)}
interface="popover"
style={{
width: '100%',
color: '#1f2937',
fontSize: '15px',
'--placeholder-color': '#9aa3a0',
'--placeholder-opacity': '1',
}}
>
<IonSelectOption value="Youth">Youth</IonSelectOption>
<IonSelectOption value="Choir">Choir</IonSelectOption>
<IonSelectOption value="Ushering">Ushering</IonSelectOption>
<IonSelectOption value="Media">Media</IonSelectOption>
</IonSelect>
</div>
<button
type="submit"
disabled={loading}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
marginTop: '8px',
}}
>
{loading ? (
<IonSpinner name="dots" color="light" />
) : (
'Complete Setup'
)}
</button>
</form>
{error && (
<div
style={{
background: 'rgba(190, 60, 60, 0.10)',
borderRadius: '12px',
padding: '12px 14px',
margin: '0',
}}
>
<p
style={{
margin: 0,
fontSize: '13px',
fontWeight: '500',
color: '#a33b32',
lineHeight: '1.4',
}}
>
{error}
</p>
</div>
)}
</IonContent>
</IonPage>
);
};
export default SetupProfile;
+296
View File
@@ -0,0 +1,296 @@
import React, { useState, useEffect, useRef } from 'react';
import { IonPage, IonContent, IonSpinner, IonIcon } from '@ionic/react';
import { useHistory, useLocation } from 'react-router-dom';
import { supabase } from '../supabase';
import OtpInputRow from '../components/OtpInputRow';
import { checkmarkCircleOutline } from 'ionicons/icons';
const VerifyEmail: React.FC = () => {
const [digits, setDigits] = useState<string[]>(Array(6).fill(''));
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [cooldown, setCooldown] = useState(0);
const [verified, setVerified] = useState(false);
const history = useHistory();
const location = useLocation<{ email?: string; resent?: boolean }>();
const email = location.state?.email || '';
const resent = location.state?.resent || false;
const inputRefs = [
useRef<HTMLIonInputElement>(null),
useRef<HTMLIonInputElement>(null),
useRef<HTMLIonInputElement>(null),
useRef<HTMLIonInputElement>(null),
useRef<HTMLIonInputElement>(null),
useRef<HTMLIonInputElement>(null),
];
useEffect(() => {
if (!email) {
history.replace('/auth');
}
if (resent) {
setCooldown(60);
}
}, [email, resent, history]);
useEffect(() => {
if (cooldown > 0) {
const timer = setTimeout(() => setCooldown(cooldown - 1), 1000);
return () => clearTimeout(timer);
}
}, [cooldown]);
const handleDigitChange = (index: number, value: string) => {
const sanitized = value.replace(/[^0-9]/g, '').slice(-1);
const newDigits = [...digits];
newDigits[index] = sanitized;
setDigits(newDigits);
if (sanitized && index < 5) {
inputRefs[index + 1].current?.setFocus();
}
};
const handleKeyDown = (
index: number,
e: React.KeyboardEvent<HTMLIonInputElement>
) => {
if (e.key === 'Backspace') {
if (!digits[index] && index > 0) {
inputRefs[index - 1].current?.setFocus();
}
}
};
const handleVerifyOtp = async () => {
const code = digits.join('');
if (code.length !== 6) {
setError('Please enter all 6 digits');
return;
}
setLoading(true);
setError(null);
const { error } = await supabase.auth.verifyOtp({
email,
token: code,
type: 'email',
});
if (error) {
setError(error.message);
setLoading(false);
return;
}
setVerified(true);
setLoading(false);
};
const handleResend = async () => {
if (cooldown > 0) return;
setLoading(true);
setError(null);
const { error } = await supabase.auth.resend({ type: 'signup', email });
if (error) {
setError(error.message);
setLoading(false);
return;
}
setCooldown(60);
setLoading(false);
};
const goBackToAuth = () => {
history.replace('/auth');
};
return (
<IonPage style={{ background: '#f6f1e8' }}>
<IonContent
style={{
'--background': 'linear-gradient(180deg, #f9f5ee 0%, #f3ede3 100%)',
'--padding-start': '0px',
'--padding-end': '0px',
'--padding-top': '0px',
'--padding-bottom': '0px',
}}
>
<div
style={{
padding:
'calc(var(--ion-safe-area-top, 0px) + 18px) 20px calc(var(--ion-safe-area-bottom, 0px) + 28px)',
minHeight: '100%',
display: 'flex',
flexDirection: 'column',
}}
>
<div
style={{
background: 'transparent',
borderRadius: '0px',
padding: '0px',
margin: '0 0 24px 0',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
<h1
style={{
margin: 0,
fontSize: '24px',
fontWeight: '700',
color: '#1f2937',
}}
>
Check your email
</h1>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
We sent a 6-digit code to {email}.
</p>
</div>
{!verified ? (
<>
<OtpInputRow
digits={digits}
onChange={handleDigitChange}
onKeyDown={handleKeyDown}
inputRefs={inputRefs}
/>
<button
onClick={handleVerifyOtp}
disabled={loading}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
margin: '0 0 16px 0',
}}
>
{loading ? <IonSpinner name="dots" color="light" /> : 'Verify'}
</button>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<button
onClick={handleResend}
disabled={cooldown > 0 || loading}
style={{
background: 'transparent',
border: 'none',
borderRadius: '999px',
padding: '10px 14px',
fontSize: '14px',
fontWeight: '600',
color: cooldown > 0 ? '#9aa3a0' : '#2f6b4f',
cursor: cooldown > 0 ? 'default' : 'pointer',
}}
>
{cooldown > 0 ? `Resend code in ${cooldown}s` : 'Resend code'}
</button>
</div>
{error && (
<div
style={{
background: 'rgba(190, 60, 60, 0.10)',
borderRadius: '12px',
padding: '12px 14px',
margin: '16px 0 0 0',
}}
>
<p
style={{
margin: 0,
fontSize: '13px',
fontWeight: '500',
color: '#a33b32',
lineHeight: '1.4',
}}
>
{error}
</p>
</div>
)}
</>
) : (
<div
style={{
background: '#ffffff',
borderRadius: '24px',
padding: '24px',
margin: '24px 0 0 0',
display: 'flex',
flexDirection: 'column',
gap: '12px',
alignItems: 'center',
textAlign: 'center',
}}
>
<IonIcon
icon={checkmarkCircleOutline}
style={{ fontSize: '36px', color: '#2f6b4f' }}
/>
<h2
style={{
margin: 0,
fontSize: '18px',
fontWeight: '700',
color: '#1f2937',
}}
>
Email confirmed
</h2>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: '400',
color: '#6b7280',
}}
>
You can now sign in to your account.
</p>
<button
onClick={goBackToAuth}
style={{
background: '#2f6b4f',
border: 'none',
borderRadius: '999px',
padding: '16px',
fontSize: '15px',
fontWeight: '600',
color: '#ffffff',
cursor: 'pointer',
width: '100%',
marginTop: '12px',
}}
>
Back to Sign In
</button>
</div>
)}
</div>
</IonContent>
</IonPage>
);
};
export default VerifyEmail;
-458
View File
@@ -1,458 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react';
import {
IonButton,
IonContent,
IonHeader,
IonIcon,
IonLoading,
IonPage,
IonText,
IonToolbar,
useIonViewWillEnter,
} from '@ionic/react';
import {
addOutline,
arrowDownCircleOutline,
cardOutline,
chevronBackOutline,
chevronForwardOutline,
walletOutline,
} from 'ionicons/icons';
import { useHistory } from 'react-router-dom';
import { supabase } from '../supabase';
import { useAuth } from '../context/AuthContext';
import type { Tables } from '../database.types';
import { setStatusBarStyle, Style } from '../utils/statusBar';
type WalletRow = Tables<'wallets'>;
type PaymentMethodRow = Tables<'payment_methods'>;
type WalletTransactionRow = Tables<'wallet_transactions'>;
const formatMoney = (amount: number, currency: string) =>
new Intl.NumberFormat('en-US', {
style: 'currency',
currency,
minimumFractionDigits: 2,
}).format(amount);
const Wallet: React.FC = () => {
const history = useHistory();
const { user } = useAuth();
const [wallet, setWallet] = useState<WalletRow | null>(null);
const [methods, setMethods] = useState<PaymentMethodRow[]>([]);
const [transactions, setTransactions] = useState<WalletTransactionRow[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState('');
useIonViewWillEnter(() => {
setStatusBarStyle(Style.Light);
});
useEffect(() => {
const loadWallet = async () => {
if (!user) {
setWallet(null);
setMethods([]);
setTransactions([]);
setIsLoading(false);
return;
}
setIsLoading(true);
setError('');
const { data: walletData, error: walletError } = await supabase
.from('wallets')
.select('*')
.eq('user_id', user.id)
.maybeSingle();
if (walletError) {
setError('Unable to load your wallet right now.');
setIsLoading(false);
return;
}
setWallet(walletData ?? null);
const [
{ data: methodData, error: methodError },
{ data: txData, error: txError },
] = await Promise.all([
supabase
.from('payment_methods')
.select('*')
.eq('user_id', user.id)
.order('is_default', { ascending: false })
.order('created_at', { ascending: false })
.limit(3),
walletData
? supabase
.from('wallet_transactions')
.select('*')
.eq('wallet_id', walletData.id)
.order('created_at', { ascending: false })
.limit(5)
: Promise.resolve({ data: [], error: null }),
]);
if (methodError || txError) {
setError('Some wallet details could not be loaded.');
}
setMethods(methodData ?? []);
setTransactions(txData ?? []);
setIsLoading(false);
};
void loadWallet();
}, [user]);
const balanceLabel = useMemo(() => {
if (!wallet) return '$0.00';
return formatMoney(wallet.balance, wallet.currency);
}, [wallet]);
return (
<IonPage>
<IonHeader className="ion-no-border wallet-header wallet-header-modern">
<IonToolbar>
<div className="wallet-toolbar-inner">
<IonButton
fill="clear"
className="wallet-back-button wallet-back-button-modern"
aria-label="Back to profile"
onClick={() => history.replace('/profile')}
>
<IonIcon icon={chevronBackOutline} slot="icon-only" />
</IonButton>
<div className="wallet-toolbar-title-block">
<span>Payments</span>
<strong>Wallet</strong>
</div>
<IonButton
fill="clear"
className="wallet-header-add-button"
aria-label="Add payment method"
onClick={() => history.push('/wallet/payment-methods/add')}
>
<IonIcon icon={addOutline} slot="icon-only" />
</IonButton>
</div>
</IonToolbar>
</IonHeader>
<IonContent
fullscreen
className="wallet-page wallet-page-vibrant ion-padding"
>
<IonLoading isOpen={isLoading} message="Loading wallet..." />
{!user ? (
<>
<div className="wallet-balance-card wallet-balance-card-vibrant">
<div>
<span className="wallet-balance-label">Available balance</span>
<h1>$48.50</h1>
<p>Refund credits ready for your next basket.</p>
<div className="wallet-balance-actions">
<span>Refund wallet</span>
<span>Instant checkout</span>
</div>
</div>
<div className="wallet-balance-icon">
<IonIcon icon={walletOutline} />
</div>
</div>
<div className="wallet-insight-strip">
<div>
<span>Refunds</span>
<strong>Instant</strong>
</div>
<div>
<span>Checkout</span>
<strong>Faster</strong>
</div>
<div>
<span>Security</span>
<strong>Masked</strong>
</div>
</div>
<div className="wallet-section-heading">
<h2>Saved payment methods</h2>
<IonButton
fill="clear"
onClick={() => history.push('/wallet/payment-methods')}
>
See all
</IonButton>
</div>
<div className="wallet-method-stack">
{[
{
id: 'demo-visa',
brand: 'visa',
last4: '4242',
expiry_month: 8,
expiry_year: 2028,
is_default: true,
cardholder_name: 'Demo User',
},
].map((method) => (
<button
key={method.id}
type="button"
className="wallet-method-card wallet-method-preview-card"
onClick={() => history.push('/wallet/payment-methods')}
>
<div className="wallet-card-visual wallet-card-visual-demo">
<div className="wallet-card-top-row">
<div className="wallet-card-chip" />
<span className="wallet-card-brand">
{method.brand.toUpperCase()}
</span>
</div>
<div className="wallet-card-number">
{method.last4}
</div>
<div className="wallet-card-meta-row">
<div>
<span>Cardholder</span>
<strong>{method.cardholder_name}</strong>
</div>
<div className="wallet-card-meta-right">
<span>Valid Thru</span>
<strong>
{String(method.expiry_month).padStart(2, '0')}/
{String(method.expiry_year).slice(-2)}
</strong>
</div>
</div>
</div>
<div className="wallet-method-preview-footer wallet-method-preview-footer-end">
<IonIcon icon={chevronForwardOutline} />
</div>
</button>
))}
</div>
<div className="wallet-section-heading wallet-section-spacing">
<h2>Recent wallet activity</h2>
</div>
<div className="wallet-activity-list">
{[
{
id: 'txn-1',
title: 'Refund from cancelled order',
description: 'Order QC-481920 refund credited to wallet',
amount: 18.5,
created_at: new Date().toISOString(),
},
{
id: 'txn-2',
title: 'Promotional wallet credit',
description: 'Welcome bonus added to your balance',
amount: 30,
created_at: new Date(Date.now() - 86400000).toISOString(),
},
].map((transaction) => (
<div key={transaction.id} className="wallet-activity-card">
<div>
<strong>{transaction.title}</strong>
<p>{transaction.description}</p>
</div>
<div className="wallet-activity-right">
<span className="wallet-positive">
{formatMoney(transaction.amount, 'USD')}
</span>
<small>
{new Date(transaction.created_at).toLocaleDateString()}
</small>
</div>
</div>
))}
</div>
<div className="wallet-refund-card">
<h3>How refunds work</h3>
<p>
In demo mode, this wallet preview shows how refund credits and
saved payment methods will appear for signed-in users.
</p>
</div>
</>
) : (
<>
<div className="wallet-balance-card wallet-balance-card-vibrant">
<div>
<span className="wallet-balance-label">Available balance</span>
<h1>{balanceLabel}</h1>
<p>Refunds and credits ready for your next basket.</p>
<div className="wallet-balance-actions">
<span>Refund wallet</span>
<span>Instant checkout</span>
</div>
</div>
<div className="wallet-balance-icon">
<IonIcon icon={walletOutline} />
</div>
</div>
{error && (
<IonText color="danger">
<p className="wallet-inline-message">{error}</p>
</IonText>
)}
<div className="wallet-insight-strip">
<div>
<span>Refunds</span>
<strong>Instant</strong>
</div>
<div>
<span>Checkout</span>
<strong>Faster</strong>
</div>
<div>
<span>Security</span>
<strong>Masked</strong>
</div>
</div>
<div className="wallet-section-heading">
<h2>Saved payment methods</h2>
<IonButton
fill="clear"
onClick={() => history.push('/wallet/payment-methods')}
>
See all
</IonButton>
</div>
{methods.length === 0 ? (
<div className="wallet-surface-card wallet-empty-block">
<IonIcon icon={cardOutline} />
<div>
<h3>No saved payment methods</h3>
<p>Add a card once so future checkouts feel faster.</p>
</div>
<IonButton
expand="block"
onClick={() => history.push('/wallet/payment-methods/add')}
>
<IonIcon icon={addOutline} slot="start" />
Add payment method
</IonButton>
</div>
) : (
<div className="wallet-method-stack">
{(() => {
const method =
methods.find((entry) => entry.is_default) ?? methods[0];
if (!method) return null;
return (
<button
key={method.id}
type="button"
className="wallet-method-card wallet-method-preview-card"
onClick={() => history.push('/wallet/payment-methods')}
>
<div className="wallet-card-visual">
<div className="wallet-card-top-row">
<div className="wallet-card-chip" />
<span className="wallet-card-brand">
{method.brand.toUpperCase()}
</span>
</div>
<div className="wallet-card-number">
{method.last4}
</div>
<div className="wallet-card-meta-row">
<div>
<span>Cardholder</span>
<strong>
{method.cardholder_name || 'Saved Card'}
</strong>
</div>
<div className="wallet-card-meta-right">
<span>Valid Thru</span>
<strong>
{String(method.expiry_month).padStart(2, '0')}/
{String(method.expiry_year).slice(-2)}
</strong>
</div>
</div>
</div>
<div className="wallet-method-preview-footer wallet-method-preview-footer-end">
<IonIcon icon={chevronForwardOutline} />
</div>
</button>
);
})()}
</div>
)}
<div className="wallet-section-heading wallet-section-spacing">
<h2>Recent wallet activity</h2>
</div>
{transactions.length === 0 ? (
<div className="wallet-surface-card wallet-empty-block compact-empty-block">
<IonIcon icon={arrowDownCircleOutline} />
<div>
<h3>No wallet activity yet</h3>
<p>
Refund credits and manual wallet adjustments will appear
here.
</p>
</div>
</div>
) : (
<div className="wallet-activity-list">
{transactions.map((transaction) => (
<div key={transaction.id} className="wallet-activity-card">
<div>
<strong>{transaction.title}</strong>
<p>{transaction.description || 'Wallet transaction'}</p>
</div>
<div className="wallet-activity-right">
<span
className={
transaction.amount >= 0
? 'wallet-positive'
: 'wallet-negative'
}
>
{formatMoney(
transaction.amount,
wallet?.currency || 'USD'
)}
</span>
<small>
{new Date(transaction.created_at).toLocaleDateString()}
</small>
</div>
</div>
))}
</div>
)}
<div className="wallet-refund-card">
<h3>How refunds work</h3>
<p>
When a refund is approved, the credited amount will appear in
your wallet balance and in the activity list above.
</p>
</div>
</>
)}
</IonContent>
</IonPage>
);
};
export default Wallet;
+2 -2
View File
@@ -2,6 +2,6 @@ import { createClient } from '@supabase/supabase-js';
import type { Database } from './database.types'; import type { Database } from './database.types';
export const supabase = createClient<Database>( export const supabase = createClient<Database>(
'https://ztrqscwsjnfvcuaakqus.supabase.co', 'https://kxejpmyjfdrbaupauexc.supabase.co',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp0cnFzY3dzam5mdmN1YWFrcXVzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzk4ODk5MzEsImV4cCI6MjA5NTQ2NTkzMX0.htIOqPM90Uk0dYIdD8X8_tLfq5URcSvmCArfVRF4jeQ', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt4ZWpwbXlqZmRyYmF1cGF1ZXhjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODM2OTkzMzksImV4cCI6MjA5OTI3NTMzOX0.FteANsPY4x605R26bxC6sR4iiYbw_nwG4zrcDYEH83Y',
); );
+51
View File
@@ -0,0 +1,51 @@
// Ambient test globals for optional *.test.* files in the editor / tsc.
// No test runner is installed in the template; stubs avoid spurious TS errors.
interface Matchers<R = void> {
toBeDefined(): R;
toBe(expected: unknown): R;
toEqual(expected: unknown): R;
toBeTruthy(): R;
toBeFalsy(): R;
toBeNull(): R;
toContain(item: unknown): R;
toHaveLength(length: number): R;
toMatch(expected: string | RegExp): R;
toThrow(expected?: string | RegExp | Error): R;
not: Matchers<R>;
}
interface Expect {
<T = unknown>(actual: T): Matchers;
}
declare const expect: Expect;
type TestCaseFn = (
name: string,
fn?: () => void | Promise<void>,
timeout?: number,
) => void;
declare const test: TestCaseFn;
declare const it: TestCaseFn;
declare const describe: TestCaseFn;
declare function beforeEach(fn: () => void | Promise<void>): void;
declare function afterEach(fn: () => void | Promise<void>): void;
declare function beforeAll(fn: () => void | Promise<void>): void;
declare function afterAll(fn: () => void | Promise<void>): void;
declare module "@testing-library/react" {
export function render(
ui: unknown,
options?: object,
): {
baseElement: Element;
container: Element;
unmount(): void;
rerender(ui: unknown): void;
};
export const screen: Record<string, (...args: unknown[]) => Element>;
export function cleanup(): void;
}
+58 -3982
View File
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
export interface EventCategory {
id: string;
slug: string;
name: string;
accent_color: string;
created_at: string;
}
export interface ChurchEvent {
id: string;
title: string;
description: string;
category_id: string;
audience: 'all' | 'youth' | 'children';
venue: string;
start_at: string;
end_at: string | null;
day_label: string;
is_featured: boolean;
created_by: string;
created_at: string;
updated_at: string;
event_categories?: EventCategory; // Relation
}
export interface NewsItem {
id: string;
title: string;
content: string;
image_url: string | null;
created_at: string;
updated_at: string;
created_by: string;
}
+5 -14
View File
@@ -1,18 +1,14 @@
import { StatusBar, Style } from '@capacitor/status-bar'; import { StatusBar, Style } from '@capacitor/status-bar';
export { Style }; export { Style };
``
const _origin = (() => { const _origin = (() => {
try { try { if (document.referrer) return new URL(document.referrer).origin; } catch {}
if (document.referrer) return new URL(document.referrer).origin;
} catch {}
return window.location.origin; return window.location.origin;
})(); })();
/** Set status bar icon/text colour. Use instead of StatusBar.setStyle directly. */ /** Set status bar icon/text colour. Use instead of StatusBar.setStyle directly. */
export async function setStatusBarStyle(style: Style): Promise<void> { export async function setStatusBarStyle(style: Style): Promise<void> {
try { try { await StatusBar.setStyle({ style }); } catch {}
await StatusBar.setStyle({ style });
} catch {}
if (window.parent !== window) { if (window.parent !== window) {
window.parent.postMessage({ type: '__apsuite_statusbar', style }, _origin); window.parent.postMessage({ type: '__apsuite_statusbar', style }, _origin);
} }
@@ -20,13 +16,8 @@ export async function setStatusBarStyle(style: Style): Promise<void> {
/** Set status bar background colour (Android). Use instead of StatusBar.setBackgroundColor directly. */ /** Set status bar background colour (Android). Use instead of StatusBar.setBackgroundColor directly. */
export async function setStatusBarBackground(color: string): Promise<void> { export async function setStatusBarBackground(color: string): Promise<void> {
try { try { await (StatusBar as any).setBackgroundColor({ color }); } catch {}
await (StatusBar as any).setBackgroundColor({ color });
} catch {}
if (window.parent !== window) { if (window.parent !== window) {
window.parent.postMessage( window.parent.postMessage({ type: '__apsuite_statusbar_bg', color }, _origin);
{ type: '__apsuite_statusbar_bg', color },
_origin
);
} }
} }
+14 -1
View File
@@ -1,3 +1,6 @@
// NOTE: @ionic/react and @ionic/react-router are pinned to 8.8.7 in package.json.
// 8.8.8 introduced a regression that breaks IonRouterOutlet page transition animations.
// Do not upgrade until the upstream fix is confirmed.
import { defineConfig, type Plugin } from 'vite'; import { defineConfig, type Plugin } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
@@ -14,8 +17,18 @@ const injectRouterBasename: Plugin = {
}, },
}; };
const hideScrollbars: Plugin = {
name: 'hide-scrollbars',
transformIndexHtml(html) {
return html.replace(
'</head>',
'<style>*{scrollbar-width:none!important;-ms-overflow-style:none!important}*::-webkit-scrollbar{display:none!important}</style></head>',
);
},
};
export default defineConfig({ export default defineConfig({
plugins: [injectRouterBasename, react()], plugins: [injectRouterBasename, hideScrollbars, react()],
server: { server: {
host: '0.0.0.0', host: '0.0.0.0',
port: 8100, port: 8100,
+101 -98
View File
@@ -324,6 +324,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@capacitor/preferences@npm:^8.0.1":
version: 8.0.1
resolution: "@capacitor/preferences@npm:8.0.1"
peerDependencies:
"@capacitor/core": ">=8.0.0"
checksum: 10c0/cbed0229a685f484c396fd043354688fdeec69264f322180b62c5adb0322561b288a63eb38ee9b38cf78ea7dbc3b9dc8dd8c2e52b54a7f752a1b2f07bfd29f0d
languageName: node
linkType: hard
"@capacitor/push-notifications@npm:^8.1.1": "@capacitor/push-notifications@npm:^8.1.1":
version: 8.1.1 version: 8.1.1
resolution: "@capacitor/push-notifications@npm:8.1.1" resolution: "@capacitor/push-notifications@npm:8.1.1"
@@ -1043,11 +1052,11 @@ __metadata:
linkType: hard linkType: hard
"@googlemaps/js-api-loader@npm:^2.0.2": "@googlemaps/js-api-loader@npm:^2.0.2":
version: 2.1.0 version: 2.1.1
resolution: "@googlemaps/js-api-loader@npm:2.1.0" resolution: "@googlemaps/js-api-loader@npm:2.1.1"
dependencies: dependencies:
"@types/google.maps": "npm:^3.53.1" "@types/google.maps": "npm:^3.53.1"
checksum: 10c0/dc9593252f59af6c8af0056d1045bc6ce8335962fde51b4e294b864f47d3c640c4259c3afedfb9c0f60b62f76d9c8786062888c6f22518ce88f2e0d95dc6b510 checksum: 10c0/06cb6eaf686b838be51efd8293010b7bee42e341e9ad41b42a0ee8909cf06cc5711ba6cfdbcd0c62ff05c8ba35d8622c34130e738bc5844011c8bc457d14de64
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1086,6 +1095,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@hookform/resolvers@npm:^3.9.0":
version: 3.10.0
resolution: "@hookform/resolvers@npm:3.10.0"
peerDependencies:
react-hook-form: ^7.0.0
checksum: 10c0/7ee44533b4cdc28c4fa2a94894c735411e5a1f830f4a617c580533321a9b901df0cc8c1e2fad81ad8d55154ebc5cb844cf9c116a3148ffae2bc48758c33cbb8e
languageName: node
linkType: hard
"@ionic/cli-framework-output@npm:^2.2.8": "@ionic/cli-framework-output@npm:^2.2.8":
version: 2.2.8 version: 2.2.8
resolution: "@ionic/cli-framework-output@npm:2.2.8" resolution: "@ionic/cli-framework-output@npm:2.2.8"
@@ -1108,17 +1126,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ionic/core@npm:8.8.8":
version: 8.8.8
resolution: "@ionic/core@npm:8.8.8"
dependencies:
"@stencil/core": "npm:4.43.0"
ionicons: "npm:^8.0.13"
tslib: "npm:^2.1.0"
checksum: 10c0/fea32925aaebec558c1c3bb9c30f8c0806d3480a67936e63cdcce8846138688d9b6b5b853ebe771132f0f79efef16568b17d11495f7997ea325a265a7e7d7af3
languageName: node
linkType: hard
"@ionic/pwa-elements@npm:^3.0.0": "@ionic/pwa-elements@npm:^3.0.0":
version: 3.4.0 version: 3.4.0
resolution: "@ionic/pwa-elements@npm:3.4.0" resolution: "@ionic/pwa-elements@npm:3.4.0"
@@ -1126,36 +1133,22 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ionic/react-router@npm:^8.5.0": "@ionic/react-router@npm:8.8.7":
version: 8.8.8 version: 8.8.7
resolution: "@ionic/react-router@npm:8.8.8" resolution: "@ionic/react-router@npm:8.8.7"
dependencies: dependencies:
"@ionic/react": "npm:8.8.8" "@ionic/react": "npm:8.8.7"
tslib: "npm:*" tslib: "npm:*"
peerDependencies: peerDependencies:
react: ">=16.8.6" react: ">=16.8.6"
react-dom: ">=16.8.6" react-dom: ">=16.8.6"
react-router: ^5.0.1 react-router: ^5.0.1
react-router-dom: ^5.0.1 react-router-dom: ^5.0.1
checksum: 10c0/be9555ec4dbfd0565cada39d42236eb0b9e2283a13f500b42d5c0c06d6198c17a7be385cfb2ce4f9e89236c71992c30169328b861943a3fe7344c672ad94ae0c checksum: 10c0/302d6ad9c0d450cf6466ff18622aa7708af77c1c4a676d2ff39eca6add440fe96d36a157feae146c3da460c32e7799357320b3270740b050ab040a664b9f0ff2
languageName: node languageName: node
linkType: hard linkType: hard
"@ionic/react@npm:8.8.8": "@ionic/react@npm:8.8.7":
version: 8.8.8
resolution: "@ionic/react@npm:8.8.8"
dependencies:
"@ionic/core": "npm:8.8.8"
ionicons: "npm:^8.0.13"
tslib: "npm:*"
peerDependencies:
react: ">=16.8.6"
react-dom: ">=16.8.6"
checksum: 10c0/b1b8888f487dc564735adde57ef3cd054e6c9bc38601f133823e69cb98d8e51c99c8902fe48fdd11ee5521ae58b322f110a1fbc8b8fd9bc62e27fc0b806bddd0
languageName: node
linkType: hard
"@ionic/react@npm:^8.5.0":
version: 8.8.7 version: 8.8.7
resolution: "@ionic/react@npm:8.8.7" resolution: "@ionic/react@npm:8.8.7"
dependencies: dependencies:
@@ -1365,13 +1358,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@protobufjs/inquire@npm:^1.1.2":
version: 1.1.2
resolution: "@protobufjs/inquire@npm:1.1.2"
checksum: 10c0/af69597818a14cac6a00a74cd5b3fb85aa96658b9dbbae73e6d907cb154ebf470953a8c537b3e6095a43de565ec4e6c5b40227c72f4a7d762d34fbec7ac179e7
languageName: node
linkType: hard
"@protobufjs/path@npm:^1.1.2": "@protobufjs/path@npm:^1.1.2":
version: 1.1.2 version: 1.1.2
resolution: "@protobufjs/path@npm:1.1.2" resolution: "@protobufjs/path@npm:1.1.2"
@@ -1387,9 +1373,9 @@ __metadata:
linkType: hard linkType: hard
"@protobufjs/utf8@npm:^1.1.1": "@protobufjs/utf8@npm:^1.1.1":
version: 1.1.1 version: 1.1.2
resolution: "@protobufjs/utf8@npm:1.1.1" resolution: "@protobufjs/utf8@npm:1.1.2"
checksum: 10c0/641fc145f00626405e8984b6e90b9edcbcc072ffc82d0647ca3176e09c730b2d022f988e65f011a7a17e2e4d77cde7733643aa10d8ac2bfa30f134dbcad553fd checksum: 10c0/975c6e2c0319bd50c17531d186b537a88cb4d3205e3ca9297cd842b631d341da0ee3ff16be8656cd2660756dc753b29c8a6a14c0ad8ed602c1f91ddf22e7b3f3
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1757,70 +1743,70 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/auth-js@npm:2.106.2": "@supabase/auth-js@npm:2.110.2":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/auth-js@npm:2.106.2" resolution: "@supabase/auth-js@npm:2.110.2"
dependencies: dependencies:
tslib: "npm:2.8.1" tslib: "npm:2.8.1"
checksum: 10c0/dc82807064bcf751c5378a9cc08a77d3732505434847af8c323355b63d417bfbfaa0e807c17eea7d0b7e022c8dadd7c9aa4c886554d60c599298e928d1035a98 checksum: 10c0/3cb1bd3e78498c964ed897032fc09e19a5d8640c1d6b0edbf66a9cad5884547b9107d769f327a556ffab848656fca0de405ba9b961f38b71d44870c28d7b3bd6
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/functions-js@npm:2.106.2": "@supabase/functions-js@npm:2.110.2":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/functions-js@npm:2.106.2" resolution: "@supabase/functions-js@npm:2.110.2"
dependencies: dependencies:
tslib: "npm:2.8.1" tslib: "npm:2.8.1"
checksum: 10c0/256ca5134b22b90edab4c7c1f3c5db3ba8e80adbb15c3725e5ed2456a39fe21af5b7cacb2966590f6fbd17812761d2086fcad5db09eba90490911d2a66f880f1 checksum: 10c0/1e6de0a6e6304b1c2593d5ddf232a996688f8c442eb00a704f6b20d2042ae0246240f93c9dc1f5e2a936602c7b9f1ffcdd95921672d2790b30882baa24406b9d
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/phoenix@npm:^0.4.2": "@supabase/phoenix@npm:0.4.4":
version: 0.4.2 version: 0.4.4
resolution: "@supabase/phoenix@npm:0.4.2" resolution: "@supabase/phoenix@npm:0.4.4"
checksum: 10c0/7d426ea70715539d76ef09a5d2364b335f848ffc32cefdc07b67707a9415c654d3f82ebf611851fceb987bdde31f1f77c088a05c40e372b65221801ca502945c checksum: 10c0/b4ba930c82b20d412358826aa87ce0735147fd168efb817bfc34e31d78605220947dc7c5844726268ac6bf338f0cd081f9908a7bab87aaff4058cb80bf71ab5b
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/postgrest-js@npm:2.106.2": "@supabase/postgrest-js@npm:2.110.2":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/postgrest-js@npm:2.106.2" resolution: "@supabase/postgrest-js@npm:2.110.2"
dependencies: dependencies:
tslib: "npm:2.8.1" tslib: "npm:2.8.1"
checksum: 10c0/57c1a78428d59dfa7a89ef7901f28f756068ce9dd27ff97bf133be6ba77a4a1f13dab38bfa1a2e40cf5fab5c9d84bea394aff73514da0d6062b5b10732631127 checksum: 10c0/d08f91dbd924d39ce194a7a698ce0a56b61208efd5642368ede0ff9c419cff026da477293b11870c02850bf8e31f69148fce71a051794af83f1175c12b951d9c
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/realtime-js@npm:2.106.2": "@supabase/realtime-js@npm:2.110.2":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/realtime-js@npm:2.106.2" resolution: "@supabase/realtime-js@npm:2.110.2"
dependencies: dependencies:
"@supabase/phoenix": "npm:^0.4.2" "@supabase/phoenix": "npm:0.4.4"
tslib: "npm:2.8.1" tslib: "npm:2.8.1"
checksum: 10c0/18cb4015e26e6eb10c45b8546c02eefdae0461123f05ff614d49107f97560b12c6e87a7cb810bc1a5e4618ad5286cc9cc5283800285e94356ea8e38a69910c10 checksum: 10c0/3b6bca9a6e629293b3e41be467a99ac311ebd1ff581979abbd91da646312e7f1f6a2b944ff6d9c409532aa4271f8ad5b23a028546c14d3c0fadcc0a76799af69
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/storage-js@npm:2.106.2": "@supabase/storage-js@npm:2.110.2":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/storage-js@npm:2.106.2" resolution: "@supabase/storage-js@npm:2.110.2"
dependencies: dependencies:
iceberg-js: "npm:^0.8.1" iceberg-js: "npm:^0.8.1"
tslib: "npm:2.8.1" tslib: "npm:2.8.1"
checksum: 10c0/efb0904f1311d568c6b75336771933eb9f4bea93a1cb0f90fe54422d00162d5793e404974eefc509c93dba3f337d9d6897d6ed228657590150a1346eae8f01f7 checksum: 10c0/a672ac600a5f37ccc196b3a5e8e17f6d57d142b8bed7ab979d69d664d4782dd050e5c3166280b5f1753b18911de7529d43487c02c1e1d1efef20c0b53deb503d
languageName: node languageName: node
linkType: hard linkType: hard
"@supabase/supabase-js@npm:^2.0.0": "@supabase/supabase-js@npm:^2.108.1":
version: 2.106.2 version: 2.110.2
resolution: "@supabase/supabase-js@npm:2.106.2" resolution: "@supabase/supabase-js@npm:2.110.2"
dependencies: dependencies:
"@supabase/auth-js": "npm:2.106.2" "@supabase/auth-js": "npm:2.110.2"
"@supabase/functions-js": "npm:2.106.2" "@supabase/functions-js": "npm:2.110.2"
"@supabase/postgrest-js": "npm:2.106.2" "@supabase/postgrest-js": "npm:2.110.2"
"@supabase/realtime-js": "npm:2.106.2" "@supabase/realtime-js": "npm:2.110.2"
"@supabase/storage-js": "npm:2.106.2" "@supabase/storage-js": "npm:2.110.2"
checksum: 10c0/3d9418360b43cdf950c4d7496b368dd1c526cfc717dd3016ac032b904367476f31495c75c6ae905ef49e8b5b375416cb5cc354fb888d1e2fc596611824df2e97 checksum: 10c0/5ec5432898bc801e871b7aa700429f6e97a77fb70b61de456b6d1e6f84feccab689fdbc4efdfc44fb4c74d48bcde3446c4cf26fcbfa72c787005efe4a72981c2
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1889,9 +1875,9 @@ __metadata:
linkType: hard linkType: hard
"@types/google.maps@npm:^3.53.1, @types/google.maps@npm:^3.58.1": "@types/google.maps@npm:^3.53.1, @types/google.maps@npm:^3.58.1":
version: 3.65.0 version: 3.65.2
resolution: "@types/google.maps@npm:3.65.0" resolution: "@types/google.maps@npm:3.65.2"
checksum: 10c0/d41bc1ed2c63f297a8956b097953515e87aa21d25ef918102067efa97113ea558bb42be521337af93698b36d4c6283439b3e087b4b57c7033f59128cdc7159cb checksum: 10c0/790aed74128385bfa6c8b41c6bf18b8f1901e6c7b7c806615e904e9093703a8238f8b2504027ebe714e95f9cd5b2a94fd63306f8b71907a23ba24673754843ea
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1909,7 +1895,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:>=12.12.47, @types/node@npm:>=13.7.0": "@types/node@npm:*":
version: 25.9.1 version: 25.9.1
resolution: "@types/node@npm:25.9.1" resolution: "@types/node@npm:25.9.1"
dependencies: dependencies:
@@ -1918,6 +1904,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:>=12.12.47, @types/node@npm:>=13.7.0":
version: 26.1.1
resolution: "@types/node@npm:26.1.1"
dependencies:
undici-types: "npm:~8.3.0"
checksum: 10c0/25ac5093195736dd074d5027adbba85617bc951d5a41506ebd3b9073048acb7233613f3822d5f9b9447f9c0841c91f6387c46283916767e3ef79f23917452c46
languageName: node
linkType: hard
"@types/react-dom@npm:^19.0.0": "@types/react-dom@npm:^19.0.0":
version: 19.2.3 version: 19.2.3
resolution: "@types/react-dom@npm:19.2.3" resolution: "@types/react-dom@npm:19.2.3"
@@ -2041,12 +2036,14 @@ __metadata:
"@capacitor/haptics": "npm:8.0.2" "@capacitor/haptics": "npm:8.0.2"
"@capacitor/ios": "npm:8.3.4" "@capacitor/ios": "npm:8.3.4"
"@capacitor/keyboard": "npm:8.0.3" "@capacitor/keyboard": "npm:8.0.3"
"@capacitor/preferences": "npm:^8.0.1"
"@capacitor/push-notifications": "npm:^8.1.1" "@capacitor/push-notifications": "npm:^8.1.1"
"@capacitor/status-bar": "npm:8.0.2" "@capacitor/status-bar": "npm:8.0.2"
"@hookform/resolvers": "npm:^3.9.0"
"@ionic/pwa-elements": "npm:^3.0.0" "@ionic/pwa-elements": "npm:^3.0.0"
"@ionic/react": "npm:^8.5.0" "@ionic/react": "npm:8.8.7"
"@ionic/react-router": "npm:^8.5.0" "@ionic/react-router": "npm:8.8.7"
"@supabase/supabase-js": "npm:^2.0.0" "@supabase/supabase-js": "npm:^2.108.1"
"@types/katex": "npm:^0.16.0" "@types/katex": "npm:^0.16.0"
"@types/react": "npm:^19.0.0" "@types/react": "npm:^19.0.0"
"@types/react-dom": "npm:^19.0.0" "@types/react-dom": "npm:^19.0.0"
@@ -2392,9 +2389,9 @@ __metadata:
linkType: hard linkType: hard
"fast-equals@npm:^5.2.2": "fast-equals@npm:^5.2.2":
version: 5.4.0 version: 5.4.1
resolution: "fast-equals@npm:5.4.0" resolution: "fast-equals@npm:5.4.1"
checksum: 10c0/4fdce3a8f814e78af7296ca4ebe82f4765074a6dfe557ee98c18f5d2958c3de59025fbff7556d65f250165ccef424d37f9952ee159400f8ebe5f2edb704ec80e checksum: 10c0/18faf5894c39591d61e802b2f574cbc57d2ff2530c71b8cd4e2b4f3c250174002a9aa0b5f4d6f61073a9942a96d71bc7f36514a9b0dc9a2a5cc3395b2a910dbf
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2994,8 +2991,8 @@ __metadata:
linkType: hard linkType: hard
"protobufjs@npm:^7.2.5": "protobufjs@npm:^7.2.5":
version: 7.6.1 version: 7.6.5
resolution: "protobufjs@npm:7.6.1" resolution: "protobufjs@npm:7.6.5"
dependencies: dependencies:
"@protobufjs/aspromise": "npm:^1.1.2" "@protobufjs/aspromise": "npm:^1.1.2"
"@protobufjs/base64": "npm:^1.1.2" "@protobufjs/base64": "npm:^1.1.2"
@@ -3003,13 +3000,12 @@ __metadata:
"@protobufjs/eventemitter": "npm:^1.1.1" "@protobufjs/eventemitter": "npm:^1.1.1"
"@protobufjs/fetch": "npm:^1.1.1" "@protobufjs/fetch": "npm:^1.1.1"
"@protobufjs/float": "npm:^1.0.2" "@protobufjs/float": "npm:^1.0.2"
"@protobufjs/inquire": "npm:^1.1.2"
"@protobufjs/path": "npm:^1.1.2" "@protobufjs/path": "npm:^1.1.2"
"@protobufjs/pool": "npm:^1.1.0" "@protobufjs/pool": "npm:^1.1.0"
"@protobufjs/utf8": "npm:^1.1.1" "@protobufjs/utf8": "npm:^1.1.1"
"@types/node": "npm:>=13.7.0" "@types/node": "npm:>=13.7.0"
long: "npm:^5.3.2" long: "npm:^5.3.2"
checksum: 10c0/364c6914facac19ace915e353f71c5d5996bfa8177a3a68c09bd2513a3ecf780538aca06cb3439237f50489db2fae321c4a4db60fd7f9ec65315b7ad66bea029 checksum: 10c0/863eaca9c6f45bfcfb8787c545f53e9c6696507e328e3981b4643c12d35df7f2826021c10e3fd30bef342c13a8e9d306547bac9c0849ee3bf50f770a12f01dc5
languageName: node languageName: node
linkType: hard linkType: hard
@@ -3493,6 +3489,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~8.3.0":
version: 8.3.0
resolution: "undici-types@npm:8.3.0"
checksum: 10c0/c8aa7e2fbebfce519654dafadc0ece59be888d2ccaf180fb4495da875e7b536d2456345c384069c7e6f3e9c9ab7435f074957da306f142343eee86ff8048855a
languageName: node
linkType: hard
"undici@npm:^6.25.0": "undici@npm:^6.25.0":
version: 6.25.0 version: 6.25.0
resolution: "undici@npm:6.25.0" resolution: "undici@npm:6.25.0"
@@ -3593,13 +3596,13 @@ __metadata:
linkType: hard linkType: hard
"websocket-driver@npm:>=0.5.1": "websocket-driver@npm:>=0.5.1":
version: 0.7.4 version: 0.7.5
resolution: "websocket-driver@npm:0.7.4" resolution: "websocket-driver@npm:0.7.5"
dependencies: dependencies:
http-parser-js: "npm:>=0.5.1" http-parser-js: "npm:>=0.5.1"
safe-buffer: "npm:>=5.1.0" safe-buffer: "npm:>=5.1.0"
websocket-extensions: "npm:>=0.1.1" websocket-extensions: "npm:>=0.1.1"
checksum: 10c0/5f09547912b27bdc57bac17b7b6527d8993aa4ac8a2d10588bb74aebaf785fdcf64fea034aae0c359b7adff2044dd66f3d03866e4685571f81b13e548f9021f1 checksum: 10c0/843a3c9f529ce07f2721829f70f62986247525ab22625e857b69da13dc90967bacfe57b85e196801b565cd797e309ddd5b06fa8435732e34e8a8ab6201d7abed
languageName: node languageName: node
linkType: hard linkType: hard
@@ -3696,8 +3699,8 @@ __metadata:
linkType: hard linkType: hard
"yargs@npm:^17.7.2": "yargs@npm:^17.7.2":
version: 17.7.2 version: 17.7.3
resolution: "yargs@npm:17.7.2" resolution: "yargs@npm:17.7.3"
dependencies: dependencies:
cliui: "npm:^8.0.1" cliui: "npm:^8.0.1"
escalade: "npm:^3.1.1" escalade: "npm:^3.1.1"
@@ -3706,7 +3709,7 @@ __metadata:
string-width: "npm:^4.2.3" string-width: "npm:^4.2.3"
y18n: "npm:^5.0.5" y18n: "npm:^5.0.5"
yargs-parser: "npm:^21.1.1" yargs-parser: "npm:^21.1.1"
checksum: 10c0/ccd7e723e61ad5965fffbb791366db689572b80cca80e0f96aad968dfff4156cd7cd1ad18607afe1046d8241e6fb2d6c08bf7fa7bfb5eaec818735d8feac8f05 checksum: 10c0/7a28572f7e785a57886e34fdbddb9b28756dec552e1453d5f6e7cdd00ad8721a4e8c4321d33683f5e61cacb36ad43258adbb48396b71ec4ed14abee0fc0d0c1f
languageName: node languageName: node
linkType: hard linkType: hard