Skip to content

Commit 9f6a1eb

Browse files
committed
WorkLog-Mobile 1.0
1 parent 71e0a00 commit 9f6a1eb

14 files changed

Lines changed: 2725 additions & 1754 deletions

README.md

Lines changed: 135 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2,136 +2,126 @@
22

33
# WorkLog Mobile
44

5-
📱 Cross-platform mobile app (React Native + Expo) for employers and workers to track work hours, projects, and attendance.
6-
Backend powered by **Supabase**.
7-
Supports **offline mode**, **local storage with AsyncStorage**, and **media saved locally in the app sandbox**.
5+
📱 Cross-platform mobile app (React Native + Expo) for **employers and workers** to track work hours, manage projects, and handle attendance — all powered by **Supabase**.
6+
🎉 Version **1.0** – Official Release
87

9-
---
10-
11-
## ✨ Features
12-
13-
- **Employer & Worker accounts**
14-
- Secure login & password management
15-
- Unique IDs per user (no duplicate employers/workers allowed) ✅
16-
17-
- **Attendance clock**
18-
- Punch **in/out** with real GPS validation (haversine distance check, accuracy filter)
19-
- Shift duration tracking in real time
20-
- Offline punches are queued and synced later
8+
Data (employers, workers, projects, punches) is synced with Supabase, while media files are stored locally on the device sandbox.
219

22-
- **Projects**
23-
- Employers can create and manage projects
24-
- Projects stored in Supabase (with local fallback)
25-
- Media (photos, videos, files) saved locally per project
26-
27-
- **Workers**
28-
- Employers can see all workers and their total hours
29-
- Sorted by seniority
30-
31-
- **Personal totals**
32-
- Monthly summary per employer
33-
- Worker total hours across all time
34-
35-
- **Dark mode support**
36-
- Auto-adapted using `useColorScheme`
37-
- Panels and text styled for light/dark themes
10+
---
3811

39-
- **Bigger app logo**
40-
- Central reusable component `WLLogo` in `components/`
41-
- Easy to resize globally or per screen
12+
## ✨ Features (v1.0)
13+
14+
### 👥 Employer & Worker Accounts
15+
- Separate **sign-in and registration** for employers and workers
16+
- Automatic employer ID assignment (`employer_no`)
17+
- Worker registration linked to an existing employer
18+
- Password reset flow with clipboard copy
19+
- Prevents duplicate IDs in the cloud (unique per table)
20+
21+
### 🕒 Attendance Clock
22+
- Employers can punch **in/out from anywhere** (location always logged)
23+
- Real-time shift timer display
24+
- Stored in Supabase table `punches` via RPC calls
25+
- Location accuracy + haversine validation
26+
- Offline punches queued and synced automatically
27+
28+
### 👷 Worker Management
29+
- View all workers and their total hours (calculated server-side)
30+
- Each worker has an individual **attendance policy**:
31+
- “From workplace only” (default)
32+
- “From anywhere”
33+
- Policy changes update instantly in Supabase (`workers.punch_mode`)
34+
- Floating “Monthly Summary” button on workers page
35+
36+
### 🧱 Projects
37+
- Employers can **create / view / delete** projects
38+
- Stored in Supabase (`projects` table)
39+
- Local fallback with offline cache
40+
- Add media (photos, videos, files) — saved locally, not in the cloud
41+
- Project details open in a centered modal card
42+
- Delete confirmation dialog with Supabase policy check
43+
44+
### 🌓 Theming
45+
- Auto light/dark mode using `useColorScheme`
46+
- Manual theme toggle (☀️ / 🌙) on login screen and personal info page
47+
- All buttons styled consistently:
48+
- 🟢 Green → main action (login / clock in)
49+
- 🔵 Blue → secondary actions (register / update)
50+
- 🔴 Red → destructive (delete / logout)
4251

4352
---
4453

4554
## 🏗️ Tech Stack
4655

47-
- [Expo](https://expo.dev) (React Native runtime)
48-
- [expo-router](https://expo.github.io/router/docs)
49-
- [Supabase](https://supabase.com) (Postgres + auth + API)
50-
- AsyncStorage for offline/local data
51-
- Jest + jest-expo for testing
52-
- TypeScript for type safety
56+
- **Expo** (React Native runtime)
57+
- **expo-router** for file-based navigation
58+
- **Supabase** for backend (Postgres + RLS + RPC)
59+
- **AsyncStorage** for offline/local data
60+
- **expo-file-system** for local project media
61+
- **expo-clipboard** for password recovery
62+
- **TypeScript** for full type safety
5363

5464
---
5565

5666
## 🔑 Environment Variables
5767

58-
All secrets are **kept outside the repo**.
59-
Create `.env` files (or use EAS Secrets in CI/CD):
68+
Create a `.env` file at the root (never commit real keys):
6069

6170
```env
6271
EXPO_PUBLIC_SUPABASE_URL="https://xxxx.supabase.co"
6372
EXPO_PUBLIC_SUPABASE_ANON_KEY="your-anon-key"
64-
65-
# For CI tests only (not bundled into the app)
66-
SUPABASE_SERVICE_ROLE_KEY="service-role-key"
6773
```
6874

69-
- Local dev: `.env.test.local`
70-
- CI: GitHub Actions secrets → EAS env variables
71-
- **Never commit real keys** 🚫
72-
73-
---
74-
75-
## 🧪 Testing
76-
77-
Run coverage tests:
78-
79-
```bash
80-
npm run test:cov
81-
```
82-
83-
- Integration tests run against a **Supabase CI database**
84-
- Local media tests run against Expo FileSystem sandbox
85-
- Coverage currently ~80%+
75+
For CI/CD (EAS build):
76+
Use **Expo Secrets** or GitHub Actions secrets to inject these values securely.
8677

8778
---
8879

8980
## 📂 Project Structure
9081

9182
```
9283
WorkLog-mobile/
93-
├── app/ # Screens (expo-router)
94-
│ ├── _layout.tsx
95-
│ ├── auth.tsx
96-
│ ├── employer-home.tsx
97-
│ ├── employer-project.tsx
98-
│ └── worker-home.tsx
99-
├── components/ # Shared UI components
100-
│ └── WLLogo.tsx
84+
├── app/
85+
│ ├── _layout.tsx # Root layout (theme, router)
86+
│ ├── auth.tsx # Worker login & registration
87+
│ ├── employer-auth.tsx # Employer login, registration, password reset
88+
│ ├── employer-home.tsx # Main employer panel (menu, clock, workers, projects)
89+
│ ├── employer-project.tsx # Project modal view + file/media upload + delete
90+
│ └── employer-workers.tsx # Monthly summary per worker
91+
├── components/
92+
│ └── WLLogo.tsx # Reusable large logo component
10193
├── src/
10294
│ ├── data/
103-
│ │ └── repo.ts # Supabase + offline repo logic
95+
│ │ └── repo.ts # Supabase & offline repository logic
10496
│ ├── lib/
105-
│ │ ├── storage.ts # Local-only data
106-
│ │ ├── location.ts # GPS + geocode helpers
107-
│ │ └── supabase.ts # Supabase client
108-
├── __tests__/ # Jest tests
97+
│ │ ├── supabase.ts # Supabase client
98+
│ │ ├── location.ts # GPS + geocode helpers
99+
│ │ └── storage.ts # Local storage for media
109100
├── assets/
110101
│ └── logo.png
111-
├── .env.test.local # Local test env
112102
└── README.md
113103
```
114104

115105
---
116106

117107
## 🚀 Running Locally
118108

119-
1. Install deps
109+
1. **Install dependencies**
120110
```bash
121111
npm install
122112
```
123113

124-
2. Set up environment
114+
2. **Configure environment**
125115
```bash
126116
cp .env.test.local .env
127117
```
128118

129-
3. Start dev server
119+
3. **Start development server**
130120
```bash
131121
npx expo start
132122
```
133123

134-
4. Run tests
124+
4. **Run tests**
135125
```bash
136126
npm run test:cov
137127
```
@@ -140,27 +130,82 @@ WorkLog-mobile/
140130

141131
## 📦 Building (EAS)
142132

143-
Make sure you have an Expo account and EAS CLI:
144-
145133
```bash
146134
eas build --platform ios
147135
eas build --platform android
148136
```
149137

150-
Secrets are managed in Expo → Project → Secrets.
138+
Secrets are managed via **Expo → Project → Secrets**.
139+
Ensure your `.env` is not committed to git.
151140

152141
---
153142

154-
## ✅ Recent Changes
143+
## 🧩 Supabase Setup Notes
144+
145+
To allow deleting projects directly from the app, make sure you add this policy:
146+
147+
```sql
148+
alter table public.projects enable row level security;
149+
150+
drop policy if exists projects_delete_all on public.projects;
151+
152+
create policy projects_delete_all
153+
on public.projects
154+
for delete
155+
using (true);
156+
```
157+
158+
If you prefer owner-based deletion:
159+
```sql
160+
create policy projects_delete_own
161+
on public.projects
162+
for delete
163+
using (auth.role() = 'authenticated' OR true)
164+
with check (true);
165+
```
166+
167+
---
168+
169+
## 🧪 Testing Checklist (before release)
170+
171+
✅ Register employer → verify appears in Supabase
172+
✅ Register worker → verify linked employer_no
173+
✅ Change punch policy → test from worker app
174+
✅ Clock-in/out → validate GPS stored
175+
✅ Create project → verify in DB
176+
✅ Delete project → ensure removed after SQL policy
177+
✅ Light/dark toggle → persists correctly
178+
✅ Logout → returns to login screen
179+
180+
---
155181

156-
- Added **WLLogo** reusable component → logo now **larger across the app**
157-
- Enforced **unique employer & worker IDs** (no duplicates)
158-
- Fixed **Supabase CI schema setup** for tests
159-
- Improved **offline queue sync** logic
160-
- Strengthened **dark mode UI** consistency
182+
## 📱 Running on Android (Mac)
183+
184+
If Android Studio emulator fails to connect:
185+
186+
### Option 1 – Expo Go on real Android phone
187+
1. Install **Expo Go** from Play Store.
188+
2. Run `npx expo start` on your Mac.
189+
3. Scan the QR code with the Android device (same Wi-Fi).
190+
✅ Easiest and most reliable.
191+
192+
### Option 2 – Android Emulator
193+
- Open AVD from Android Studio (API 33+).
194+
- In the Expo CLI window press:
195+
```bash
196+
a
197+
```
198+
- If bundler not loading, run:
199+
```bash
200+
adb reverse tcp:8081 tcp:8081
201+
```
202+
or start Expo in tunnel mode:
203+
```bash
204+
npx expo start --tunnel
205+
```
161206

162207
---
163208

164209
## 📝 License
165210

166-
MIT
211+
MIT © 2025 WorkLog Team

Rifles_-_Calibers___Velocities.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Name,Model,Caliber,Muzzle Velocity (m/s),Notes
2+
AK-47 (Type 1),AK-47,7.62×39mm,715,"Reliable, intermediate cartridge"
3+
SKS,SKS,7.62×39mm,740,Semi-auto carbine
4+
AR-15 (M4 style),M4/AR-15,5.56×45mm NATO,920,Common modern service round
5+
HK416,HK416,5.56×45mm NATO,920,Piston-driven AR variant
6+
Remington 700 (.308),Remington 700,.308 Winchester (7.62×51mm NATO),820,Bolt-action sniper/hunting
7+
M14,M14,7.62×51mm NATO,853,Battle rifle / designated marksman
8+
Dragunov SVD,SVD Dragunov,7.62×54mmR,830,Semi-auto designated marksman rifle
9+
Mosin–Nagant,Mosin–Nagant M1891,7.62×54mmR,853,Historic bolt-action rifle
10+
FN SCAR-H,SCAR-H (Mk 17),7.62×51mm NATO,790,Modular battle rifle
11+
Barrett M82,M82,.50 BMG (12.7×99mm),850,Anti-material / long-range sniper rifle

Savanna_-_Animals.csv

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Common Name,Scientific Name,Average Length (m),Average Height (m),Avg Weight (kg),Top Speed (km/h),Aggressiveness (1-10),Habitat,Rarity,Spawn Rate (per km^2),Drops,Notes
2+
African Elephant,Loxodonta africana,6.0,3.3,6000,40,6,"Open savanna, woodland",Uncommon,0.02,"Meat, Tusk (ivory) - game-only","Large, slow turning, can push trees"
3+
Lion,Panthera leo,2.5,1.2,190,80,8,"Grassland, near water",Rare,0.05,"Meat, Hide",Packs (pride) behavior possible
4+
Giraffe,Giraffa camelopardalis,5.5,5.0,1200,60,3,"Open savanna, acacia stands",Uncommon,0.08,"Meat, Hide",Tall — can see players from far
5+
Plains Zebra,Equus quagga,2.4,1.4,350,65,2,Grassland,Common,2.0,"Meat, Hide","Herds, migratory"
6+
African Buffalo,Syncerus caffer,2.7,1.7,700,57,9,"Grassland, near water",Uncommon,0.5,"Meat, Horns",Very dangerous — high aggro
7+
Cheetah,Acinonyx jubatus,1.6,0.9,72,120,5,Open plains,Rare,0.03,"Meat, Hide",Fast predator — short sprint bursts
8+
Spotted Hyena,Crocuta crocuta,1.8,0.9,60,60,7,"Savanna, woodland edges",Uncommon,0.2,"Meat, Hide",Scavenger and pack hunter
9+
Wildebeest (Blue),Connochaetes taurinus,2.2,1.4,260,80,3,Open plains,Common,3.0,"Meat, Hide",Large herds; migrations
10+
Ostrich,Struthio camelus,2.1,2.0,100,70,4,Open plains,Common,1.0,"Meat, Feathers","Fast runner, can kick"
11+
Warthog,Phacochoerus africanus,1.3,0.6,80,48,4,"Grassland, burrows",Common,1.5,"Meat, Tusks","Burrowing, quick turns"
12+
Impala,Aepyceros melampus,1.6,1.0,60,80,2,"Savanna, woodland edges",Common,4.0,"Meat, Hide","Agile, good jumpers"
13+
Black Rhinoceros,Diceros bicornis,3.5,1.6,1400,50,9,"Shrubland, woodland",Very Rare,0.005,"Meef (rare), Horn - game-only",Very territorial — high aggro

app/_layout.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1+
// app/_layout.tsx
12
import { Stack } from 'expo-router';
2-
import { useEffect } from 'react';
3-
import { flushPending } from '../src/data/repo';
3+
import React from 'react';
44

55
export default function RootLayout() {
6-
useEffect(() => {
7-
(async () => { await flushPending(); })();
8-
}, []);
9-
106
return (
11-
<Stack>
12-
{/* מסכי כניסה ללא Header */}
13-
<Stack.Screen name="auth" options={{ headerShown: false }} />
14-
<Stack.Screen name="employer-auth" options={{ headerShown: false }} />
15-
16-
{/* מסכים פנימיים - מציירים Header ידני ו-SafeArea בכל מסך */}
17-
<Stack.Screen name="employer-home" options={{ headerShown: false }} />
18-
<Stack.Screen name="clock" options={{ headerShown: false }} />
19-
<Stack.Screen name="profile" options={{ headerShown: false }} />
20-
<Stack.Screen name="employer-project" options={{ headerShown: false }} />
21-
22-
{/* אם קיימים טאבים מהתבנית */}
23-
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
24-
25-
{/* כדי שלא תופיע אזהרה על not-found */}
26-
<Stack.Screen name="+not-found" options={{ headerShown: false }} />
27-
</Stack>
7+
<Stack
8+
screenOptions={{
9+
headerShown: false,
10+
// הכי חשוב בשבילך:
11+
gestureEnabled: false, // מבטל החלקה אחורה בכל המסכים
12+
}}
13+
/>
2814
);
2915
}

0 commit comments

Comments
 (0)