diff --git a/apps/mana/apps/web/SETUP.md b/apps/mana/apps/web/SETUP.md deleted file mode 100644 index e26263f92..000000000 --- a/apps/mana/apps/web/SETUP.md +++ /dev/null @@ -1,364 +0,0 @@ -# Mana Web - Setup Guide - -## π Project Created Successfully! - -A brand new SvelteKit application has been created in the `mana-web` folder, separate from the existing React Native `mana_app`. - -## β What's Been Implemented - -### Core Infrastructure - -- β SvelteKit 2.x with Svelte 5 (Runes) -- β TypeScript configuration -- β Tailwind CSS styling -- β Supabase authentication integration -- β Server-side hooks for auth management -- β Environment configuration - -### Authentication System - -- β Login page (`/login`) -- β Registration page (`/register`) -- β Protected routes with automatic redirects -- β Server-side session management -- β SSR-safe Supabase client setup - -### Dashboard - -- β Main dashboard with stats display -- β Available mana/credits tracking -- β Organization and team counts -- β Quick action links -- β Responsive design - -### UI Components - -- β Button component (primary, secondary, danger, ghost variants) -- β Card component -- β Input component with validation -- β Responsive navigation with mobile menu - -## π Project Structure - -``` -mana-web/ -βββ src/ -β βββ routes/ -β β βββ (auth)/ # Public auth routes -β β β βββ login/ # Login page -β β β βββ register/ # Registration page -β β βββ (app)/ # Protected app routes -β β β βββ dashboard/ # Main dashboard -β β βββ +layout.svelte # Root layout -β β βββ +layout.ts # Client-side layout load -β β βββ +layout.server.ts # Server-side layout load -β β βββ +page.svelte # Home page (redirects) -β βββ lib/ -β β βββ components/ -β β β βββ ui/ # Reusable UI components -β β βββ server/ # Server-only utilities -β β βββ stores/ # Svelte stores -β β βββ types/ # TypeScript types -β β βββ utils/ # Utility functions -β βββ hooks.server.ts # Server hooks (auth middleware) -β βββ app.css # Global Tailwind styles -β βββ app.d.ts # TypeScript declarations -β βββ app.html # HTML template -βββ static/ # Static assets -βββ tests/ # Test files (future) -βββ .env # Environment variables -βββ .env.example # Environment template -βββ svelte.config.js # SvelteKit configuration -βββ vite.config.ts # Vite configuration -βββ tsconfig.json # TypeScript configuration -βββ package.json # Dependencies -``` - -## π Getting Started - -### 1. Configure Environment Variables - -Update `.env` with your actual Supabase credentials: - -```bash -# Get these from your Supabase project settings -PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co -PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here -``` - -### 2. Install Dependencies (if not already done) - -```bash -cd mana-web -pnpm install -``` - -### 3. Start Development Server - -```bash -pnpm dev -``` - -Visit `http://localhost:5173` - -### 4. Database Setup - -The app expects the same Supabase database schema as the React Native app. Ensure you have these tables: - -- `profiles` - User profile data -- `organizations` - Organization entities -- `teams` - Team entities -- `team_members` - Team membership -- `user_roles` - Role assignments -- `roles` - Role definitions -- `credit_transactions` - Credit history - -## π Next Steps - -### Immediate (Must Do) - -1. **Update .env file** with real Supabase credentials -2. **Test login/registration** flow -3. **Verify database schema** matches expected structure - -### Short-Term Features to Add - -1. **Organizations Management** - - List organizations page - - Organization detail page - - Create organization form - -2. **Teams Management** - - List teams page - - Team detail page with members - - Create team form - - Add/remove team members - -3. **Credit/Mana Transfer** - - Send mana page - - Credit transaction history - - Balance tracking - -4. **Settings Page** - - Profile management - - Theme toggle (light/dark) - - Account settings - -### Medium-Term Enhancements - -1. **Real-time Updates** - - Supabase realtime subscriptions - - Live credit balance updates - - Team activity notifications - -2. **Enhanced UI/UX** - - Loading skeletons - - Error boundaries - - Toast notifications - - Optimistic UI updates - -3. **Testing** - - Vitest unit tests - - Playwright E2E tests - - Component testing - -4. **Performance** - - Image optimization - - Code splitting - - Caching strategies - - Performance monitoring - -## π§ Available Scripts - -```bash -# Development -pnpm dev # Start dev server - -# Building -pnpm build # Build for production -pnpm preview # Preview production build - -# Type Checking -pnpm check # Run TypeScript checks -pnpm check:watch # Watch mode - -# Code Quality -pnpm format # Format code with Prettier -pnpm lint # Lint code - -# Testing -pnpm test # Run unit tests -pnpm test:ui # Run tests with UI -pnpm test:e2e # Run E2E tests -``` - -## π¨ Design System - -### Colors - -- Primary: `#0055FF` (blue-600) -- Background Light: `#FFFFFF` -- Background Dark: `#121212` -- Text Light: `#1F2937` -- Text Dark: `#F9FAFB` - -### Components - -All components support: - -- Dark mode (automatic via system preference) -- TypeScript props -- Tailwind CSS classes -- Accessibility features - -### Responsive Breakpoints - -- `sm`: 640px -- `md`: 768px -- `lg`: 1024px -- `xl`: 1280px -- `2xl`: 1536px - -## π Authentication Flow - -``` -βββββββββββββββββββββββββββββββββββββββ -β User visits site β -β β β -β hooks.server.ts checks session β -β β β -β Has session? β Go to /dashboard β -β β β -β No session? β Go to /login β -β β β -β User logs in β -β β β -β Supabase creates session β -β β β -β Redirect to /dashboard β -βββββββββββββββββββββββββββββββββββββββ -``` - -## π Key Technologies - -| Technology | Version | Purpose | -| ------------ | ------- | ------------- | -| SvelteKit | 2.48.4 | Web framework | -| Svelte | 5.43.3 | UI components | -| TypeScript | 5.9.3 | Type safety | -| Tailwind CSS | 3.4.18 | Styling | -| Supabase | 2.79.0 | Backend/Auth | -| Vite | 6.4.1 | Build tool | -| Playwright | 1.56.1 | E2E testing | -| Vitest | 3.2.4 | Unit testing | - -## π Comparison: React Native vs SvelteKit - -| Feature | React Native (mana_app) | SvelteKit (mana-web) | -| ---------- | ----------------------- | -------------------- | -| Platform | Mobile (iOS/Android) | Web (Browser) | -| Routing | Expo Router | File-based routing | -| State | useState/Context | Svelte Runes/$state | -| Styling | NativeWind | Tailwind CSS | -| Auth | Supabase | Supabase (same) | -| Database | Supabase | Supabase (same) | -| Build | Expo | Vite | -| Deployment | App Stores | Vercel/Netlify | - -## π¨ Common Issues & Solutions - -### Issue: Type errors on first run - -**Solution**: Run `pnpm run check` to sync types - -### Issue: Port already in use - -**Solution**: Change port in `vite.config.ts` or kill process on port 5173 - -### Issue: Supabase auth not working - -**Solution**: - -1. Check `.env` variables are correct -2. Verify Supabase project is active -3. Check browser console for errors - -### Issue: Dark mode not switching - -**Solution**: Check system dark mode preference, or implement manual toggle - -## π Documentation & Resources - -### SvelteKit - -- [SvelteKit Docs](https://svelte.dev/docs/kit) -- [Svelte 5 Tutorial](https://svelte.dev/tutorial/svelte/welcome) - -### Supabase - -- [Supabase Docs](https://supabase.com/docs) -- [Supabase Auth](https://supabase.com/docs/guides/auth) - -### Tailwind CSS - -- [Tailwind Docs](https://tailwindcss.com/docs) -- [Tailwind UI](https://tailwindui.com) - -## π‘ Development Tips - -1. **Use Runes ($state, $derived, $effect)** - Modern Svelte 5 reactivity -2. **Server-side data loading** - Use `+page.server.ts` for secure data fetching -3. **Progressive enhancement** - Forms work without JavaScript -4. **Type safety** - Leverage generated types from SvelteKit -5. **Component composition** - Use snippets for flexible component APIs - -## β¨ What Makes This Different - -Unlike a migration, this is a **clean, modern implementation** that: - -- β Follows 2025 SvelteKit best practices -- β Uses latest Svelte 5 features (Runes) -- β Implements SSR-safe authentication -- β Provides better developer experience -- β Enables easy deployment to web platforms -- β Maintains compatibility with same backend - -## π― Success Criteria - -The project is ready for development when: - -- [x] Project structure created -- [x] Dependencies installed -- [x] TypeScript configured -- [x] Tailwind CSS working -- [x] Authentication pages created -- [x] Dashboard implemented -- [ ] Environment variables configured with real credentials -- [ ] Database schema verified -- [ ] First successful login completed - -## π€ Contributing - -When adding new features: - -1. Create components in `src/lib/components/` -2. Add pages in appropriate route groups -3. Use server-side data loading for security -4. Follow existing code patterns -5. Test in both light and dark modes -6. Add TypeScript types - -## π Support - -For issues or questions: - -- Check SvelteKit docs -- Review Supabase documentation -- Check browser console for errors -- Verify environment variables - ---- - -**Status**: β Core application structure complete and ready for feature development! - -**Next**: Configure Supabase credentials and start building organization/team management features. diff --git a/apps/mana/apps/web/src/lib/components/ToastContainer.svelte b/apps/mana/apps/web/src/lib/components/ToastContainer.svelte new file mode 100644 index 000000000..c0d481427 --- /dev/null +++ b/apps/mana/apps/web/src/lib/components/ToastContainer.svelte @@ -0,0 +1,85 @@ + + +{#if toast.toasts.length > 0} +