Compare commits
14 Commits
d0694df12a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
29d6ab3d80
|
|||
|
429eb07291
|
|||
|
092d537180
|
|||
|
61c1f47409
|
|||
|
0247f6ed9d
|
|||
|
ba1433b192
|
|||
|
0e485aacee
|
|||
|
106f15205c
|
|||
|
dd41da5b0a
|
|||
|
8b0ba77b63
|
|||
|
83c209117e
|
|||
|
ea2d620c7a
|
|||
|
43b733b439
|
|||
|
621e478705
|
16
.gitignore
vendored
@ -35,3 +35,19 @@ yarn-error.log*
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# android
|
||||
/android/.gradle
|
||||
/android/build
|
||||
/android/app/build
|
||||
/android/local.properties
|
||||
/android/.idea
|
||||
|
||||
# capacitor
|
||||
/ios
|
||||
/android/.cxx
|
||||
|
||||
# data storage (ne pas commit les données clients)
|
||||
/data/clients.json
|
||||
|
||||
# APK
|
||||
/dist/*.apk
|
||||
|
||||
437
ADMIN_DEPLOY.md
Normal file
@ -0,0 +1,437 @@
|
||||
# 🖥️ Guide de déploiement de l'interface Admin
|
||||
|
||||
Ce guide explique comment déployer l'interface d'administration sur votre serveur **marama.syoul.fr**.
|
||||
|
||||
---
|
||||
|
||||
## 📋 Vue d'ensemble
|
||||
|
||||
```
|
||||
┌─────────────────────┐ ┌──────────────────────────┐
|
||||
│ APK Client │ │ Admin Web │
|
||||
│ (Statique) │ │ marama.syoul.fr │
|
||||
│ │ │ │
|
||||
│ • Accueil │ │ • Login admin │
|
||||
│ • Explorer │ ←────│ • Gestion clients │
|
||||
│ • Mana Tracker │ │ • Génération tokens │
|
||||
│ • Infos │ │ • QR codes │
|
||||
└─────────────────────┘ └──────────────────────────┘
|
||||
Voyageurs Gérant (vous)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Déploiement en 5 étapes
|
||||
|
||||
### Étape 1 : Build de l'application admin
|
||||
|
||||
```bash
|
||||
cd "/home/syoul/Ccompagnon Marama"
|
||||
./scripts/build-server.sh
|
||||
```
|
||||
|
||||
Ce script va :
|
||||
- ✅ Configurer Next.js en mode serveur (avec API routes)
|
||||
- ✅ Build l'application
|
||||
- ✅ Préparer les fichiers dans `deploy/`
|
||||
- ✅ Créer les scripts de lancement
|
||||
|
||||
**⏱️ Durée :** 2-3 minutes
|
||||
|
||||
---
|
||||
|
||||
### Étape 2 : Transférer sur votre serveur
|
||||
|
||||
```bash
|
||||
# Depuis votre machine locale
|
||||
rsync -avz --delete deploy/ user@marama.syoul.fr:/var/www/pension-admin/
|
||||
|
||||
# Remplacez 'user' par votre nom d'utilisateur SSH
|
||||
```
|
||||
|
||||
**Alternative avec SCP :**
|
||||
```bash
|
||||
scp -r deploy/* user@marama.syoul.fr:/var/www/pension-admin/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Étape 3 : Configuration sur le serveur
|
||||
|
||||
```bash
|
||||
# Se connecter au serveur
|
||||
ssh user@marama.syoul.fr
|
||||
|
||||
# Aller dans le dossier
|
||||
cd /var/www/pension-admin
|
||||
|
||||
# Configurer le mot de passe admin
|
||||
cp .env.example .env
|
||||
nano .env
|
||||
```
|
||||
|
||||
**Contenu de `.env` :**
|
||||
```bash
|
||||
# ⚠️ IMPORTANT : Changez ce mot de passe !
|
||||
ADMIN_PASSWORD=votre_mot_de_passe_tres_securise
|
||||
|
||||
# Port (optionnel)
|
||||
PORT=3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Étape 4 : Installer et démarrer
|
||||
|
||||
#### Option A : Lancement simple (test)
|
||||
|
||||
```bash
|
||||
chmod +x start.sh
|
||||
./start.sh
|
||||
```
|
||||
|
||||
L'admin sera accessible sur `http://marama.syoul.fr:3000`
|
||||
|
||||
#### Option B : Avec PM2 (production, recommandé ⭐)
|
||||
|
||||
```bash
|
||||
# Installer PM2 (si pas déjà fait)
|
||||
npm install -g pm2
|
||||
|
||||
# Démarrer l'application
|
||||
pm2 start npm --name "pension-admin" -- start
|
||||
|
||||
# Sauvegarder la config PM2
|
||||
pm2 save
|
||||
|
||||
# Configurer le démarrage auto
|
||||
pm2 startup
|
||||
# Suivre les instructions affichées
|
||||
|
||||
# Commandes utiles PM2
|
||||
pm2 status # Voir le statut
|
||||
pm2 logs pension-admin # Voir les logs
|
||||
pm2 restart pension-admin # Redémarrer
|
||||
pm2 stop pension-admin # Arrêter
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Étape 5 : Configuration Nginx (reverse proxy)
|
||||
|
||||
#### A. Créer la configuration Nginx
|
||||
|
||||
```bash
|
||||
sudo nano /etc/nginx/sites-available/pension-admin
|
||||
```
|
||||
|
||||
**Contenu du fichier :**
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name admin.marama.syoul.fr;
|
||||
|
||||
# Logs
|
||||
access_log /var/log/nginx/pension-admin-access.log;
|
||||
error_log /var/log/nginx/pension-admin-error.log;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### B. Activer la configuration
|
||||
|
||||
```bash
|
||||
# Créer le lien symbolique
|
||||
sudo ln -s /etc/nginx/sites-available/pension-admin /etc/nginx/sites-enabled/
|
||||
|
||||
# Tester la configuration
|
||||
sudo nginx -t
|
||||
|
||||
# Recharger Nginx
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
#### C. Configurer SSL (HTTPS) avec Let's Encrypt
|
||||
|
||||
```bash
|
||||
# Installer Certbot (si pas déjà fait)
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtenir le certificat SSL
|
||||
sudo certbot --nginx -d admin.marama.syoul.fr
|
||||
|
||||
# Le renouvellement est automatique !
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Configuration DNS
|
||||
|
||||
Ajoutez un enregistrement A ou CNAME dans votre DNS :
|
||||
|
||||
```
|
||||
Type: A
|
||||
Nom: admin.marama.syoul.fr (ou juste "admin")
|
||||
Valeur: [IP de votre serveur]
|
||||
TTL: 3600
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Utilisation de l'interface admin
|
||||
|
||||
### 1. Se connecter
|
||||
|
||||
```
|
||||
URL: https://admin.marama.syoul.fr
|
||||
Mot de passe: celui défini dans .env
|
||||
```
|
||||
|
||||
### 2. Ajouter un client
|
||||
|
||||
1. Cliquer sur **"Nouveau client"**
|
||||
2. Remplir le formulaire :
|
||||
- **Email** : email du voyageur
|
||||
- **N° Bungalow** : 1, 2, 3, etc.
|
||||
- **WiFi** : nom et mot de passe
|
||||
- **Message du gérant** : message personnalisé
|
||||
|
||||
3. Cliquer sur **"Créer"**
|
||||
4. Un **QR code** et un **lien unique** sont générés automatiquement
|
||||
|
||||
### 3. Partager avec le client
|
||||
|
||||
**Option A : QR Code** (recommandé)
|
||||
- Afficher le QR code
|
||||
- Le voyageur scan avec son téléphone
|
||||
- L'app se configure automatiquement
|
||||
|
||||
**Option B : Lien**
|
||||
- Copier le lien unique
|
||||
- L'envoyer par email/SMS au client
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Mise à jour de l'application
|
||||
|
||||
Quand vous modifiez le code :
|
||||
|
||||
```bash
|
||||
# Sur votre machine locale
|
||||
cd "/home/syoul/Ccompagnon Marama"
|
||||
./scripts/build-server.sh
|
||||
|
||||
# Transférer
|
||||
rsync -avz --delete deploy/ user@marama.syoul.fr:/var/www/pension-admin/
|
||||
|
||||
# Sur le serveur
|
||||
ssh user@marama.syoul.fr
|
||||
cd /var/www/pension-admin
|
||||
pm2 restart pension-admin
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📂 Structure des fichiers sur le serveur
|
||||
|
||||
```
|
||||
/var/www/pension-admin/
|
||||
├── .next/ # Application Next.js compilée
|
||||
├── public/ # Assets statiques
|
||||
├── data/
|
||||
│ └── clients.json # Base de données des clients (créé auto)
|
||||
├── package.json # Dépendances
|
||||
├── next.config.js # Config Next.js
|
||||
├── .env # Variables d'environnement (mot de passe)
|
||||
├── start.sh # Script de lancement
|
||||
└── DEPLOY.md # Documentation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔒 Sécurité
|
||||
|
||||
### Recommandations importantes
|
||||
|
||||
1. **Mot de passe fort**
|
||||
```bash
|
||||
# Générer un mot de passe sécurisé
|
||||
openssl rand -base64 32
|
||||
```
|
||||
|
||||
2. **Permissions fichiers**
|
||||
```bash
|
||||
chmod 600 /var/www/pension-admin/.env
|
||||
chmod 600 /var/www/pension-admin/data/clients.json
|
||||
```
|
||||
|
||||
3. **Firewall**
|
||||
```bash
|
||||
# Autoriser uniquement HTTP/HTTPS
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
4. **Sauvegarde des données**
|
||||
```bash
|
||||
# Créer un cron job pour sauvegarder clients.json
|
||||
0 2 * * * cp /var/www/pension-admin/data/clients.json /backup/clients-$(date +\%Y\%m\%d).json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Dépannage
|
||||
|
||||
### L'application ne démarre pas
|
||||
|
||||
```bash
|
||||
# Vérifier les logs
|
||||
pm2 logs pension-admin
|
||||
|
||||
# Vérifier que Node.js est installé
|
||||
node --version # doit être >= 18
|
||||
|
||||
# Réinstaller les dépendances
|
||||
cd /var/www/pension-admin
|
||||
rm -rf node_modules
|
||||
npm ci --production
|
||||
pm2 restart pension-admin
|
||||
```
|
||||
|
||||
### Erreur 502 Bad Gateway
|
||||
|
||||
```bash
|
||||
# Vérifier que l'app tourne
|
||||
pm2 status
|
||||
|
||||
# Vérifier les logs Nginx
|
||||
sudo tail -f /var/log/nginx/pension-admin-error.log
|
||||
|
||||
# Redémarrer Nginx
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
|
||||
### Les clients ne peuvent pas se connecter
|
||||
|
||||
```bash
|
||||
# Vérifier les permissions du fichier data
|
||||
ls -la /var/www/pension-admin/data/
|
||||
|
||||
# Vérifier le contenu
|
||||
cat /var/www/pension-admin/data/clients.json
|
||||
|
||||
# Si le fichier n'existe pas, l'app le créera automatiquement
|
||||
```
|
||||
|
||||
### Changer le mot de passe admin
|
||||
|
||||
```bash
|
||||
# Sur le serveur
|
||||
cd /var/www/pension-admin
|
||||
nano .env
|
||||
# Modifier ADMIN_PASSWORD
|
||||
|
||||
# Redémarrer
|
||||
pm2 restart pension-admin
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
### Voir les statistiques avec PM2
|
||||
|
||||
```bash
|
||||
pm2 monit # Monitoring en temps réel
|
||||
pm2 logs # Voir tous les logs
|
||||
pm2 status # Statut de toutes les apps
|
||||
```
|
||||
|
||||
### Logs Nginx
|
||||
|
||||
```bash
|
||||
# Logs d'accès
|
||||
sudo tail -f /var/log/nginx/pension-admin-access.log
|
||||
|
||||
# Logs d'erreurs
|
||||
sudo tail -f /var/log/nginx/pension-admin-error.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎓 Commandes utiles
|
||||
|
||||
```bash
|
||||
# Redémarrer l'application
|
||||
pm2 restart pension-admin
|
||||
|
||||
# Voir les logs en direct
|
||||
pm2 logs pension-admin --lines 100
|
||||
|
||||
# Recharger l'app (sans downtime)
|
||||
pm2 reload pension-admin
|
||||
|
||||
# Arrêter l'application
|
||||
pm2 stop pension-admin
|
||||
|
||||
# Démarrer l'application
|
||||
pm2 start pension-admin
|
||||
|
||||
# Supprimer de PM2
|
||||
pm2 delete pension-admin
|
||||
|
||||
# Sauvegarder la config PM2
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Conseils
|
||||
|
||||
1. **Tester localement d'abord**
|
||||
```bash
|
||||
# Sur votre machine
|
||||
npm run dev
|
||||
# Ouvrir http://localhost:3000/admin
|
||||
```
|
||||
|
||||
2. **Utiliser un sous-domaine dédié**
|
||||
- `admin.marama.syoul.fr` (recommandé)
|
||||
- Plutôt que `marama.syoul.fr/admin`
|
||||
|
||||
3. **Configurer les sauvegardes automatiques**
|
||||
- Le fichier `data/clients.json` contient toutes vos données
|
||||
- Sauvegardez-le régulièrement
|
||||
|
||||
4. **Monitoring avec Uptime Robot**
|
||||
- Gratuit
|
||||
- Vous alerte si le site est down
|
||||
|
||||
---
|
||||
|
||||
## 📞 Support
|
||||
|
||||
Si vous rencontrez des problèmes :
|
||||
|
||||
1. Vérifier les logs : `pm2 logs pension-admin`
|
||||
2. Vérifier Nginx : `sudo nginx -t`
|
||||
3. Vérifier les permissions : `ls -la data/`
|
||||
|
||||
---
|
||||
|
||||
**Version** : 1.0.0 - Novembre 2025
|
||||
**Serveur** : marama.syoul.fr
|
||||
**URL Admin** : https://admin.marama.syoul.fr
|
||||
|
||||
161
GUIDE_APK.md
Normal file
@ -0,0 +1,161 @@
|
||||
# 📱 Guide de génération de l'APK Android
|
||||
|
||||
Ce guide explique comment générer l'APK de **Compagnon du Lagon** pour la distribution aux bêta-testeurs.
|
||||
|
||||
## 🚀 Méthode rapide (Recommandée)
|
||||
|
||||
### 1. Lancer le script automatisé
|
||||
|
||||
```bash
|
||||
cd "/home/syoul/Ccompagnon Marama"
|
||||
./scripts/build-apk-simple.sh
|
||||
```
|
||||
|
||||
Le script va :
|
||||
- ✅ Installer automatiquement SDKMAN si nécessaire
|
||||
- ✅ Installer Java 21 (requis par Capacitor)
|
||||
- ✅ Installer Android SDK (cmdline-tools)
|
||||
- ✅ Build Next.js en mode export statique
|
||||
- ✅ Configurer Capacitor
|
||||
- ✅ Générer l'APK Android
|
||||
|
||||
**⏱️ Durée :** ~15-20 minutes la première fois (téléchargement SDK), puis 2-3 minutes pour les builds suivants.
|
||||
|
||||
### 2. Récupérer l'APK
|
||||
|
||||
L'APK sera disponible dans :
|
||||
```
|
||||
dist/compagnon-lagon-beta.apk
|
||||
```
|
||||
|
||||
**📊 Taille :** ~4,5 MB
|
||||
|
||||
## 📤 Distribution aux bêta-testeurs
|
||||
|
||||
### Option 1 : Envoi direct du fichier
|
||||
|
||||
1. **Envoyer par email/messagerie**
|
||||
- Envoyez le fichier `dist/compagnon-lagon-beta.apk`
|
||||
- Via Email, WhatsApp, Telegram, etc.
|
||||
|
||||
2. **Instructions pour les testeurs**
|
||||
```
|
||||
1. Télécharger le fichier APK
|
||||
2. Ouvrir les Paramètres Android
|
||||
3. Sécurité > Activer "Sources inconnues"
|
||||
4. Ouvrir le fichier APK téléchargé
|
||||
5. Appuyer sur "Installer"
|
||||
```
|
||||
|
||||
### Option 2 : Hébergement web temporaire
|
||||
|
||||
1. **Via transfert.sh** (gratuit, temporaire)
|
||||
```bash
|
||||
curl --upload-file dist/compagnon-lagon-beta.apk https://transfer.sh/compagnon.apk
|
||||
```
|
||||
Vous recevrez un lien à partager (valide 14 jours).
|
||||
|
||||
2. **Via Google Drive/Dropbox**
|
||||
- Upload `dist/compagnon-lagon-beta.apk`
|
||||
- Partager le lien public
|
||||
- Les testeurs téléchargent et installent
|
||||
|
||||
### Option 3 : Serveur local (testeurs sur même réseau)
|
||||
|
||||
```bash
|
||||
cd dist
|
||||
python3 -m http.server 8080
|
||||
```
|
||||
|
||||
Les testeurs peuvent télécharger à l'adresse :
|
||||
```
|
||||
http://[VOTRE_IP]:8080/compagnon-lagon-beta.apk
|
||||
```
|
||||
|
||||
## 🔄 Mettre à jour l'APK
|
||||
|
||||
Pour générer une nouvelle version après des modifications :
|
||||
|
||||
```bash
|
||||
# 1. Modifier le code
|
||||
# 2. Relancer le build
|
||||
./scripts/build-apk-simple.sh
|
||||
|
||||
# 3. L'APK sera mis à jour dans dist/
|
||||
```
|
||||
|
||||
## 🛠️ Configuration requise (Installation automatique)
|
||||
|
||||
Le script installe automatiquement :
|
||||
- ✅ **SDKMAN** : Gestionnaire de SDK Java
|
||||
- ✅ **Java 21** : Requis par Capacitor
|
||||
- ✅ **Android SDK** : Platform-tools, Build-tools 34.0.0
|
||||
- ✅ **Node.js packages** : Capacitor, dépendances
|
||||
|
||||
**Note :** Pas besoin de sudo, tout s'installe dans `~/.sdkman` et `~/Android/Sdk`.
|
||||
|
||||
## 📝 Notes importantes
|
||||
|
||||
### Données statiques
|
||||
L'APK contient toutes les données en **statique** (JSON dans `public/data/`).
|
||||
Pour mettre à jour les données :
|
||||
1. Modifier les fichiers JSON
|
||||
2. Rebuild l'APK
|
||||
3. Redistribuer la nouvelle version
|
||||
|
||||
### Signature APK (Debug vs Release)
|
||||
|
||||
**APK Debug** (actuel) :
|
||||
- ✅ Parfait pour les bêta-tests
|
||||
- ✅ Signature automatique
|
||||
- ❌ Ne peut pas être publié sur Play Store
|
||||
|
||||
**APK Release** (pour production) :
|
||||
```bash
|
||||
# Générer un keystore
|
||||
keytool -genkey -v -keystore compagnon-release.keystore \
|
||||
-alias compagnon -keyalg RSA -keysize 2048 -validity 10000
|
||||
|
||||
# Builder en mode release
|
||||
cd android
|
||||
./gradlew assembleRelease
|
||||
```
|
||||
|
||||
## 🐛 Dépannage
|
||||
|
||||
### Erreur "Java not found"
|
||||
```bash
|
||||
source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
sdk use java 21.0.1-tem
|
||||
```
|
||||
|
||||
### Erreur "ANDROID_HOME not set"
|
||||
```bash
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
```
|
||||
|
||||
### Erreur "Gradle daemon stopped"
|
||||
```bash
|
||||
cd android
|
||||
./gradlew --stop
|
||||
./gradlew clean assembleDebug
|
||||
```
|
||||
|
||||
### APK vide / sans contenu
|
||||
- Vérifier que `out/` contient les fichiers HTML
|
||||
- Vérifier `public/data/*.json` sont présents
|
||||
- Rebuild avec `npm run build` avant Capacitor
|
||||
|
||||
## 📞 Support
|
||||
|
||||
En cas de problème, vérifier :
|
||||
1. Les logs du script : `./scripts/build-apk-simple.sh`
|
||||
2. Les logs Gradle : `android/build/reports/`
|
||||
3. Le contenu de `out/` après build Next.js
|
||||
|
||||
---
|
||||
|
||||
**Version** : 1.0.0 - Novembre 2025
|
||||
**App ID** : `com.pensionmarama.app`
|
||||
**Nom** : Compagnon du Lagon - Pension Marama
|
||||
|
||||
101
android/.gitignore
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
|
||||
|
||||
# Built application files
|
||||
*.apk
|
||||
*.aar
|
||||
*.ap_
|
||||
*.aab
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
# Uncomment the following line in case you need and you don't have the release build type files in your app
|
||||
# release/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||
.idea/navEditor.xml
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||
#*.jks
|
||||
#*.keystore
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
.cxx/
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
# google-services.json
|
||||
|
||||
# Freeline
|
||||
freeline.py
|
||||
freeline/
|
||||
freeline_project_description.json
|
||||
|
||||
# fastlane
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
fastlane/readme.md
|
||||
|
||||
# Version control
|
||||
vcs.xml
|
||||
|
||||
# lint
|
||||
lint/intermediates/
|
||||
lint/generated/
|
||||
lint/outputs/
|
||||
lint/tmp/
|
||||
# lint/reports/
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
# Cordova plugins for Capacitor
|
||||
capacitor-cordova-android-plugins
|
||||
|
||||
# Copied web assets
|
||||
app/src/main/assets/public
|
||||
|
||||
# Generated Config files
|
||||
app/src/main/assets/capacitor.config.json
|
||||
app/src/main/assets/capacitor.plugins.json
|
||||
app/src/main/res/xml/config.xml
|
||||
2
android/app/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/build/*
|
||||
!/build/.npmkeep
|
||||
58
android/app/build.gradle
Normal file
@ -0,0 +1,58 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
namespace "com.pensionmarama.app"
|
||||
compileSdk rootProject.ext.compileSdkVersion
|
||||
defaultConfig {
|
||||
applicationId "com.pensionmarama.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir{
|
||||
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||
implementation project(':capacitor-android')
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
||||
implementation project(':capacitor-cordova-android-plugins')
|
||||
}
|
||||
|
||||
apply from: 'capacitor.build.gradle'
|
||||
|
||||
try {
|
||||
def servicesJSON = file('google-services.json')
|
||||
if (servicesJSON.text) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||
}
|
||||
19
android/app/capacitor.build.gradle
Normal file
@ -0,0 +1,19 @@
|
||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||
|
||||
android {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||
dependencies {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (hasProperty('postBuildExtras')) {
|
||||
postBuildExtras()
|
||||
}
|
||||
21
android/app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -0,0 +1,26 @@
|
||||
package com.getcapacitor.myapp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.getcapacitor.app", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
41
android/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths"></meta-data>
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<!-- Permissions -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
||||
@ -0,0 +1,5 @@
|
||||
package com.pensionmarama.app;
|
||||
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
BIN
android/app/src/main/res/drawable-land-hdpi/splash.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
android/app/src/main/res/drawable-land-mdpi/splash.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
android/app/src/main/res/drawable-land-xhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
android/app/src/main/res/drawable-land-xxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
android/app/src/main/res/drawable-land-xxxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
android/app/src/main/res/drawable-port-hdpi/splash.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
android/app/src/main/res/drawable-port-mdpi/splash.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
android/app/src/main/res/drawable-port-xhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
android/app/src/main/res/drawable-port-xxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
android/app/src/main/res/drawable-port-xxxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1" />
|
||||
</vector>
|
||||
170
android/app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
</vector>
|
||||
BIN
android/app/src/main/res/drawable/splash.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
12
android/app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
||||
7
android/app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Compagnon du Lagon</string>
|
||||
<string name="title_activity_main">Compagnon du Lagon</string>
|
||||
<string name="package_name">com.pensionmarama.app</string>
|
||||
<string name="custom_url_scheme">com.pensionmarama.app</string>
|
||||
</resources>
|
||||
22
android/app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:background">@null</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
|
||||
<item name="android:background">@drawable/splash</item>
|
||||
</style>
|
||||
</resources>
|
||||
5
android/app/src/main/res/xml/file_paths.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="my_images" path="." />
|
||||
<cache-path name="my_cache_images" path="." />
|
||||
</paths>
|
||||
@ -0,0 +1,18 @@
|
||||
package com.getcapacitor.myapp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
29
android/build.gradle
Normal file
@ -0,0 +1,29 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.2'
|
||||
classpath 'com.google.gms:google-services:4.4.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "variables.gradle"
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
3
android/capacitor.settings.gradle
Normal file
@ -0,0 +1,3 @@
|
||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||
include ':capacitor-android'
|
||||
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
||||
25
android/gradle.properties
Normal file
@ -0,0 +1,25 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# Use Java 21 toolchain (required by Capacitor)
|
||||
org.gradle.java.home=/home/syoul/.sdkman/candidates/java/21.0.1-tem
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
7
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
252
android/gradlew
vendored
Executable file
@ -0,0 +1,252 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
94
android/gradlew.bat
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
5
android/settings.gradle
Normal file
@ -0,0 +1,5 @@
|
||||
include ':app'
|
||||
include ':capacitor-cordova-android-plugins'
|
||||
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
|
||||
|
||||
apply from: 'capacitor.settings.gradle'
|
||||
16
android/variables.gradle
Normal file
@ -0,0 +1,16 @@
|
||||
ext {
|
||||
minSdkVersion = 23
|
||||
compileSdkVersion = 35
|
||||
targetSdkVersion = 35
|
||||
androidxActivityVersion = '1.9.2'
|
||||
androidxAppCompatVersion = '1.7.0'
|
||||
androidxCoordinatorLayoutVersion = '1.2.0'
|
||||
androidxCoreVersion = '1.15.0'
|
||||
androidxFragmentVersion = '1.8.4'
|
||||
coreSplashScreenVersion = '1.0.1'
|
||||
androidxWebkitVersion = '1.12.1'
|
||||
junitVersion = '4.13.2'
|
||||
androidxJunitVersion = '1.2.1'
|
||||
androidxEspressoCoreVersion = '3.6.1'
|
||||
cordovaAndroidVersion = '10.1.1'
|
||||
}
|
||||
@ -31,13 +31,20 @@ export default function AdminLoginPage() {
|
||||
|
||||
if (response.ok) {
|
||||
router.push("/admin");
|
||||
} else if (response.status === 404) {
|
||||
// API non disponible (mode statique/APK) - accepter quand même
|
||||
// Le mot de passe sera vérifié côté serveur lors des vraies requêtes
|
||||
router.push("/admin");
|
||||
} else {
|
||||
setError("Mot de passe incorrect");
|
||||
localStorage.removeItem("adminPassword");
|
||||
}
|
||||
} catch (err) {
|
||||
setError("Erreur de connexion");
|
||||
localStorage.removeItem("adminPassword");
|
||||
// Erreur réseau (API non disponible en mode statique/APK)
|
||||
// Accepter quand même et rediriger
|
||||
// Le mot de passe sera vérifié côté serveur lors des vraies requêtes
|
||||
console.warn("API non disponible (mode statique), connexion acceptée localement");
|
||||
router.push("/admin");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@ -20,7 +20,31 @@ export default function AdminPage() {
|
||||
const adminPassword = localStorage.getItem("adminPassword");
|
||||
if (!adminPassword) {
|
||||
router.push("/admin/login");
|
||||
return;
|
||||
}
|
||||
|
||||
// Tester la connexion avec l'API (si disponible)
|
||||
// Si l'API n'est pas disponible (APK statique), on continue quand même
|
||||
fetch("/api/admin/clients", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${adminPassword}`,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok && res.status !== 404) {
|
||||
// Si erreur autre que 404 (API non disponible), déconnecter
|
||||
if (res.status === 401 || res.status === 403) {
|
||||
localStorage.removeItem("adminPassword");
|
||||
router.push("/admin/login");
|
||||
}
|
||||
}
|
||||
// Si 404, c'est normal en mode statique (API non disponible)
|
||||
// On continue l'affichage
|
||||
})
|
||||
.catch(() => {
|
||||
// Erreur réseau (API non disponible en mode statique)
|
||||
// C'est normal pour l'APK, on continue
|
||||
});
|
||||
}, [router]);
|
||||
|
||||
const handleNewClient = () => {
|
||||
|
||||
132
app/api/admin/clients/route.ts
Normal file
@ -0,0 +1,132 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { writeFile, readFile, mkdir } from "fs/promises";
|
||||
import { existsSync } from "fs";
|
||||
import path from "path";
|
||||
import { Client, ClientInput } from "@/lib/types/client";
|
||||
|
||||
// Mot de passe admin (à changer en production via variable d'environnement)
|
||||
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || "admin123";
|
||||
|
||||
// Chemin vers le fichier de stockage
|
||||
const DATA_DIR = path.join(process.cwd(), "data");
|
||||
const CLIENTS_FILE = path.join(DATA_DIR, "clients.json");
|
||||
|
||||
// Vérifier l'authentification
|
||||
function verifyAuth(request: NextRequest): boolean {
|
||||
const authHeader = request.headers.get("authorization");
|
||||
if (!authHeader) return false;
|
||||
|
||||
const token = authHeader.replace("Bearer ", "");
|
||||
return token === ADMIN_PASSWORD;
|
||||
}
|
||||
|
||||
// Charger les clients depuis le fichier
|
||||
async function loadClients(): Promise<Client[]> {
|
||||
try {
|
||||
if (!existsSync(CLIENTS_FILE)) {
|
||||
// Créer le répertoire et le fichier si nécessaire
|
||||
if (!existsSync(DATA_DIR)) {
|
||||
await mkdir(DATA_DIR, { recursive: true });
|
||||
}
|
||||
await writeFile(CLIENTS_FILE, JSON.stringify([], null, 2));
|
||||
return [];
|
||||
}
|
||||
|
||||
const data = await readFile(CLIENTS_FILE, "utf-8");
|
||||
return JSON.parse(data);
|
||||
} catch (error) {
|
||||
console.error("Erreur lecture clients:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Sauvegarder les clients dans le fichier
|
||||
async function saveClients(clients: Client[]): Promise<void> {
|
||||
try {
|
||||
if (!existsSync(DATA_DIR)) {
|
||||
await mkdir(DATA_DIR, { recursive: true });
|
||||
}
|
||||
await writeFile(CLIENTS_FILE, JSON.stringify(clients, null, 2));
|
||||
} catch (error) {
|
||||
console.error("Erreur sauvegarde clients:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// GET - Récupérer tous les clients
|
||||
export async function GET(request: NextRequest) {
|
||||
if (!verifyAuth(request)) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const clients = await loadClients();
|
||||
return NextResponse.json(clients);
|
||||
} catch (error) {
|
||||
console.error("Erreur GET clients:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Erreur serveur" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// POST - Créer un nouveau client
|
||||
export async function POST(request: NextRequest) {
|
||||
if (!verifyAuth(request)) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const input: ClientInput = await request.json();
|
||||
|
||||
// Validation
|
||||
if (!input.email || !input.bungalowNumber) {
|
||||
return NextResponse.json(
|
||||
{ error: "Email et numéro de bungalow requis" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const clients = await loadClients();
|
||||
|
||||
// Vérifier si l'email existe déjà
|
||||
if (clients.some(c => c.email === input.email)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Un client avec cet email existe déjà" },
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
|
||||
// Créer le nouveau client
|
||||
const newClient: Client = {
|
||||
id: `client-${Date.now()}`,
|
||||
token: generateToken(),
|
||||
email: input.email,
|
||||
bungalowNumber: input.bungalowNumber,
|
||||
wifiName: input.wifiName || "Lagon-WiFi",
|
||||
wifiPassword: input.wifiPassword || "",
|
||||
gerantMessage: input.gerantMessage || "Bienvenue dans notre pension de famille !",
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
clients.push(newClient);
|
||||
await saveClients(clients);
|
||||
|
||||
return NextResponse.json(newClient, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error("Erreur POST client:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Erreur serveur" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Générer un token unique
|
||||
function generateToken(): string {
|
||||
return Math.random().toString(36).substring(2, 15) +
|
||||
Math.random().toString(36).substring(2, 15);
|
||||
}
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
@apply bg-background;
|
||||
@apply bg-background dark:bg-background-dark;
|
||||
font-size: 16px;
|
||||
min-height: 100vh;
|
||||
color: #1f2937;
|
||||
@apply text-foreground dark:text-foreground-dark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import PWARegister from "@/components/PWARegister";
|
||||
import { ThemeProvider } from "@/components/ThemeProvider";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
@ -29,14 +30,21 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="fr">
|
||||
<html lang="fr" suppressHydrationWarning>
|
||||
<head>
|
||||
<link rel="icon" href="/logo-relais-marama.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="/logo-relais-marama.svg" />
|
||||
</head>
|
||||
<body className={inter.className}>
|
||||
{children}
|
||||
<PWARegister />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="light"
|
||||
enableSystem={true}
|
||||
disableTransitionOnChange={false}
|
||||
>
|
||||
{children}
|
||||
<PWARegister />
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
116
app/page.tsx
@ -1,21 +1,121 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function Home() {
|
||||
const router = useRouter();
|
||||
const [checked, setChecked] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
router.replace("/accueil");
|
||||
// Détecter si on est dans l'app admin
|
||||
let isAdminApp = false;
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const Capacitor = (window as any).Capacitor;
|
||||
|
||||
// Méthode 1: Vérifier l'appId de Capacitor via le package name Android
|
||||
if (Capacitor) {
|
||||
try {
|
||||
const platform = Capacitor.getPlatform();
|
||||
|
||||
if (platform === "android") {
|
||||
// En Android, on peut récupérer le package name via Capacitor.getApp()
|
||||
// APK admin: com.pensionmarama.admin
|
||||
// APK client: com.pensionmarama.app
|
||||
const App = Capacitor.Plugins?.App;
|
||||
if (App) {
|
||||
App.getInfo().then((info: any) => {
|
||||
// Le package name est dans info.id ou info.appId
|
||||
const appId = info.id || info.appId || "";
|
||||
if (appId.includes("admin")) {
|
||||
isAdminApp = true;
|
||||
}
|
||||
}).catch(() => {
|
||||
// Fallback si getInfo() échoue
|
||||
});
|
||||
}
|
||||
|
||||
// Fallback: Vérifier le localStorage (si adminPassword existe, c'est admin)
|
||||
const hasAdminPassword = localStorage.getItem("adminPassword") !== null;
|
||||
if (hasAdminPassword) {
|
||||
isAdminApp = true;
|
||||
}
|
||||
} else {
|
||||
// Pour web, vérifier le localStorage
|
||||
const hasAdminPassword = localStorage.getItem("adminPassword") !== null;
|
||||
if (hasAdminPassword) {
|
||||
isAdminApp = true;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// En cas d'erreur, fallback sur les autres méthodes
|
||||
console.warn("Erreur lors de la détection Capacitor:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Méthode 2: Vérifier le path ou query string (pour web)
|
||||
if (!isAdminApp && (
|
||||
window.location.pathname.startsWith("/admin") ||
|
||||
window.location.search.includes("admin=true")
|
||||
)) {
|
||||
isAdminApp = true;
|
||||
}
|
||||
|
||||
// Méthode 3: Si on est dans Capacitor Android sans adminPassword,
|
||||
// on considère que c'est l'app client (redirige vers /accueil)
|
||||
// Sauf si le pathname commence par /admin
|
||||
}
|
||||
|
||||
if (isAdminApp) {
|
||||
// Vérifier si l'admin est connecté
|
||||
const adminPassword = typeof window !== "undefined" ?
|
||||
localStorage.getItem("adminPassword") : null;
|
||||
|
||||
if (adminPassword) {
|
||||
// Tester la connexion (si API disponible)
|
||||
fetch("/api/admin/clients", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${adminPassword}`,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
router.replace("/admin");
|
||||
} else if (res.status === 404) {
|
||||
// API non disponible (mode statique) - accepter quand même
|
||||
router.replace("/admin");
|
||||
} else {
|
||||
localStorage.removeItem("adminPassword");
|
||||
router.replace("/admin/login");
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// Erreur réseau (API non disponible en mode statique)
|
||||
// Accepter quand même et rediriger vers /admin
|
||||
router.replace("/admin");
|
||||
});
|
||||
} else {
|
||||
// Pas de mot de passe, rediriger vers login
|
||||
router.replace("/admin/login");
|
||||
}
|
||||
} else {
|
||||
// App client normale
|
||||
router.replace("/accueil");
|
||||
}
|
||||
setChecked(true);
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
<div className="text-center">
|
||||
<p className="text-gray-600">Redirection...</p>
|
||||
if (!checked) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen bg-background dark:bg-background-dark">
|
||||
<div className="text-center">
|
||||
<p className="text-gray-600 dark:text-gray-400">Chargement...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import type { CapacitorConfig } from '@capacitor/cli';
|
||||
import { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'com.pensionmarama.admin',
|
||||
appName: 'Compagnon Admin',
|
||||
webDir: 'out'
|
||||
appId: 'com.pensionmarama.app',
|
||||
appName: 'Compagnon du Lagon',
|
||||
webDir: 'out',
|
||||
server: {
|
||||
androidScheme: 'https'
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
12
components/ThemeProvider.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
||||
import { type ComponentProps } from "react";
|
||||
|
||||
export function ThemeProvider({
|
||||
children,
|
||||
...props
|
||||
}: ComponentProps<typeof NextThemesProvider>) {
|
||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
|
||||
}
|
||||
|
||||
45
components/ThemeToggle.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import { useTheme } from "next-themes";
|
||||
import { Moon, Sun } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
if (!mounted) {
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-9 w-9 rounded-full p-0"
|
||||
aria-label="Changer de thème"
|
||||
>
|
||||
<Sun className="h-5 w-5" />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
|
||||
className="h-10 w-10 rounded-full hover:bg-secondary dark:hover:bg-gray-800 p-0"
|
||||
aria-label="Changer de thème"
|
||||
>
|
||||
{theme === "dark" ? (
|
||||
<Sun className="h-5 w-5 text-primary dark:text-yellow-400" />
|
||||
) : (
|
||||
<Moon className="h-5 w-5 text-primary dark:text-blue-300" />
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ export default function WifiCard() {
|
||||
const showPasswordFallback = error && error.includes("sélectionner manuellement");
|
||||
|
||||
return (
|
||||
<Card className="bg-white">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Wifi className="h-6 w-6 text-primary" />
|
||||
@ -80,22 +80,22 @@ export default function WifiCard() {
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div>
|
||||
<p className="text-sm text-gray-600 mb-1">Nom du réseau</p>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-1">Nom du réseau</p>
|
||||
<p className="text-lg font-semibold text-primary">{wifiName || "Chargement..."}</p>
|
||||
</div>
|
||||
|
||||
{showPasswordFallback && wifiPassword && (
|
||||
<div className="bg-yellow-50 border border-yellow-200 rounded-xl p-3">
|
||||
<p className="text-sm text-yellow-800 font-mono select-all">
|
||||
<div className="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-xl p-3">
|
||||
<p className="text-sm text-yellow-800 dark:text-yellow-300 font-mono select-all">
|
||||
{wifiPassword}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && !showPasswordFallback && (
|
||||
<div className="bg-red-50 border border-red-200 rounded-xl p-3 flex items-start gap-2">
|
||||
<AlertCircle className="h-5 w-5 text-red-600 flex-shrink-0 mt-0.5" />
|
||||
<p className="text-sm text-red-800">{error}</p>
|
||||
<div className="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl p-3 flex items-start gap-2">
|
||||
<AlertCircle className="h-5 w-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5" />
|
||||
<p className="text-sm text-red-800 dark:text-red-300">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import { LogOut } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ThemeToggle } from "@/components/ThemeToggle";
|
||||
|
||||
export default function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
@ -13,14 +14,17 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<header className="bg-white border-b border-gray-200 shadow-sm">
|
||||
<div className="min-h-screen bg-background dark:bg-background-dark">
|
||||
<header className="bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 shadow-sm">
|
||||
<div className="max-w-4xl mx-auto px-4 py-4 flex items-center justify-between">
|
||||
<h1 className="text-xl font-bold text-primary">Administration</h1>
|
||||
<Button variant="outline" size="sm" onClick={handleLogout}>
|
||||
<LogOut className="h-4 w-4 mr-2" />
|
||||
Déconnexion
|
||||
</Button>
|
||||
<h1 className="text-xl font-bold text-primary dark:text-primary">Administration</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<ThemeToggle />
|
||||
<Button variant="outline" size="sm" onClick={handleLogout} className="dark:border-gray-700 dark:text-gray-300">
|
||||
<LogOut className="h-4 w-4 mr-2" />
|
||||
Déconnexion
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main className="max-w-4xl mx-auto px-4 py-6">{children}</main>
|
||||
|
||||
@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
||||
import { Client, ClientInput } from "@/lib/types/client";
|
||||
import QRCodeDisplay from "./QRCodeDisplay";
|
||||
import { Copy, Check } from "lucide-react";
|
||||
|
||||
interface ClientFormProps {
|
||||
client?: Client;
|
||||
@ -24,6 +25,7 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [createdClient, setCreatedClient] = useState<Client | null>(client || null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@ -68,6 +70,39 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr
|
||||
return `${baseUrl}/accueil?token=${createdClient.token}`;
|
||||
};
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
const url = getClientUrl();
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
setCopied(true);
|
||||
// Alerte pour confirmer
|
||||
alert(`✅ Lien copié !\n\n${url}\n\nVous pouvez maintenant le coller (Ctrl+V) pour le partager avec votre client.`);
|
||||
setTimeout(() => setCopied(false), 3000);
|
||||
} catch (err) {
|
||||
console.error("Erreur lors de la copie:", err);
|
||||
// Fallback pour les navigateurs plus anciens
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = url;
|
||||
textArea.style.position = "fixed";
|
||||
textArea.style.left = "-999999px";
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
const successful = document.execCommand("copy");
|
||||
if (successful) {
|
||||
setCopied(true);
|
||||
alert(`✅ Lien copié !\n\n${url}\n\nVous pouvez maintenant le coller (Ctrl+V) pour le partager avec votre client.`);
|
||||
setTimeout(() => setCopied(false), 3000);
|
||||
} else {
|
||||
alert(`❌ Copie automatique non supportée.\n\nVeuillez copier manuellement le lien:\n\n${url}`);
|
||||
}
|
||||
} catch (e) {
|
||||
alert(`❌ Copie automatique non supportée.\n\nVeuillez copier manuellement le lien:\n\n${url}`);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
@ -167,19 +202,53 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr
|
||||
<h3 className="font-semibold text-primary mb-3">Client créé avec succès !</h3>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<p className="text-sm text-gray-600 mb-2">Lien unique :</p>
|
||||
<div className="bg-secondary rounded-xl p-3 flex items-center justify-between gap-2">
|
||||
<code className="text-xs break-all flex-1">{getClientUrl()}</code>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(getClientUrl());
|
||||
}}
|
||||
>
|
||||
Copier
|
||||
</Button>
|
||||
<p className="text-sm font-medium text-gray-700 mb-2">Lien unique :</p>
|
||||
<div className="bg-secondary rounded-xl p-4 space-y-3">
|
||||
<textarea
|
||||
readOnly
|
||||
value={getClientUrl()}
|
||||
onClick={(e) => e.currentTarget.select()}
|
||||
onFocus={(e) => e.currentTarget.select()}
|
||||
className="w-full p-3 text-sm font-mono text-primary bg-white border-2 border-primary rounded-lg resize-none"
|
||||
rows={3}
|
||||
style={{ cursor: 'text' }}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCopyLink}
|
||||
className={`flex-1 ${copied ? "bg-green-600 hover:bg-green-700" : ""}`}
|
||||
>
|
||||
{copied ? (
|
||||
<>
|
||||
<Check className="h-4 w-4 mr-2" />
|
||||
Copié !
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Copy className="h-4 w-4 mr-2" />
|
||||
Copier
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
const textarea = document.querySelector('textarea[readonly]') as HTMLTextAreaElement;
|
||||
if (textarea) {
|
||||
textarea.select();
|
||||
}
|
||||
}}
|
||||
className="flex-1"
|
||||
>
|
||||
Sélectionner
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-gray-500 mt-2">
|
||||
💡 Cliquez sur le lien pour le sélectionner, puis Ctrl+C pour copier
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm text-gray-600 mb-2">QR Code :</p>
|
||||
|
||||
@ -34,9 +34,19 @@ export default function ClientList({ onEdit, onRefresh }: ClientListProps) {
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setClients(data);
|
||||
} else if (response.status === 404) {
|
||||
// API non disponible (mode statique/APK)
|
||||
// Afficher un message d'information
|
||||
console.warn("API non disponible en mode statique");
|
||||
setClients([]);
|
||||
} else {
|
||||
console.error("Erreur lors du chargement des clients:", response.status);
|
||||
setClients([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Erreur lors du chargement des clients:", error);
|
||||
// Erreur réseau (API non disponible en mode statique/APK)
|
||||
console.warn("API non disponible (mode statique/APK). Les fonctionnalités admin nécessitent un serveur.");
|
||||
setClients([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -73,7 +83,7 @@ export default function ClientList({ onEdit, onRefresh }: ClientListProps) {
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-8">
|
||||
<p className="text-gray-600">Chargement...</p>
|
||||
<p className="text-gray-600 dark:text-gray-400">Chargement...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -81,8 +91,12 @@ export default function ClientList({ onEdit, onRefresh }: ClientListProps) {
|
||||
if (clients.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center">
|
||||
<p className="text-gray-600">Aucun client pour le moment.</p>
|
||||
<CardContent className="py-8 text-center space-y-4">
|
||||
<p className="text-gray-600 dark:text-gray-400">Aucun client pour le moment.</p>
|
||||
<div className="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-xl p-4 text-sm text-yellow-800 dark:text-yellow-300">
|
||||
<p className="font-semibold mb-1">⚠️ Mode hors ligne</p>
|
||||
<p>L'application admin nécessite une connexion au serveur pour fonctionner. Les API routes ne sont pas disponibles en mode statique.</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { QRCodeSVG } from "qrcode.react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Copy, Check } from "lucide-react";
|
||||
|
||||
interface QRCodeDisplayProps {
|
||||
url: string;
|
||||
@ -8,12 +11,89 @@ interface QRCodeDisplayProps {
|
||||
}
|
||||
|
||||
export default function QRCodeDisplay({ url, size = 200 }: QRCodeDisplayProps) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
setCopied(true);
|
||||
alert(`✅ Lien copié !\n\n${url}\n\nVous pouvez maintenant le coller (Ctrl+V) pour le partager avec votre client.`);
|
||||
setTimeout(() => setCopied(false), 3000);
|
||||
} catch (err) {
|
||||
console.error("Erreur lors de la copie:", err);
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = url;
|
||||
textArea.style.position = "fixed";
|
||||
textArea.style.left = "-999999px";
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
const successful = document.execCommand("copy");
|
||||
if (successful) {
|
||||
setCopied(true);
|
||||
alert(`✅ Lien copié !\n\n${url}\n\nVous pouvez maintenant le coller (Ctrl+V) pour le partager avec votre client.`);
|
||||
setTimeout(() => setCopied(false), 3000);
|
||||
} else {
|
||||
alert(`Copiez ce lien manuellement:\n\n${url}`);
|
||||
}
|
||||
} catch (e) {
|
||||
alert(`Copiez ce lien manuellement:\n\n${url}`);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 p-4 bg-white rounded-2xl border border-gray-200">
|
||||
<div className="flex flex-col items-center gap-4 p-6 bg-white rounded-2xl border border-gray-200">
|
||||
<QRCodeSVG value={url} size={size} level="H" />
|
||||
<p className="text-xs text-gray-600 text-center break-all max-w-xs">
|
||||
{url}
|
||||
</p>
|
||||
|
||||
<div className="w-full space-y-3">
|
||||
<p className="text-sm font-medium text-gray-700">Lien unique :</p>
|
||||
<textarea
|
||||
readOnly
|
||||
value={url}
|
||||
onClick={(e) => e.currentTarget.select()}
|
||||
onFocus={(e) => e.currentTarget.select()}
|
||||
className="w-full p-3 text-sm font-mono text-primary bg-secondary border-2 border-primary rounded-lg resize-none"
|
||||
rows={3}
|
||||
style={{ cursor: 'text' }}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCopyLink}
|
||||
className={`flex-1 ${copied ? "bg-green-600 hover:bg-green-700" : ""}`}
|
||||
>
|
||||
{copied ? (
|
||||
<>
|
||||
<Check className="h-4 w-4 mr-2" />
|
||||
Copié !
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Copy className="h-4 w-4 mr-2" />
|
||||
Copier
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
const textarea = document.querySelector('textarea[readonly]') as HTMLTextAreaElement;
|
||||
if (textarea) {
|
||||
textarea.select();
|
||||
}
|
||||
}}
|
||||
className="flex-1"
|
||||
>
|
||||
Sélectionner
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-xs text-gray-500 text-center">
|
||||
💡 Cliquez sur le lien pour le sélectionner, puis Ctrl+C pour copier
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import TabNavigation from "./TabNavigation";
|
||||
|
||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background pb-16">
|
||||
<div className="min-h-screen bg-background dark:bg-background-dark pb-16">
|
||||
{children}
|
||||
<TabNavigation />
|
||||
</div>
|
||||
|
||||
@ -4,6 +4,7 @@ import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { Home, MapPin, Info, Waves } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ThemeToggle } from "@/components/ThemeToggle";
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
@ -32,7 +33,7 @@ export default function TabNavigation() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<nav className="fixed bottom-0 left-0 right-0 z-50 bg-white border-t border-gray-200 shadow-lg">
|
||||
<nav className="fixed bottom-0 left-0 right-0 z-50 bg-white dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 shadow-lg">
|
||||
<div className="flex items-center justify-around h-16 px-2">
|
||||
{tabs.map((tab) => {
|
||||
const Icon = tab.icon;
|
||||
@ -44,8 +45,8 @@ export default function TabNavigation() {
|
||||
className={cn(
|
||||
"flex flex-col items-center justify-center gap-1 flex-1 h-full rounded-xl transition-colors",
|
||||
isActive
|
||||
? "text-primary bg-secondary"
|
||||
: "text-gray-500 hover:text-primary hover:bg-gray-50"
|
||||
? "text-primary bg-secondary dark:bg-primary/20"
|
||||
: "text-gray-500 dark:text-gray-400 hover:text-primary dark:hover:text-primary hover:bg-gray-50 dark:hover:bg-gray-800"
|
||||
)}
|
||||
>
|
||||
<Icon className="h-6 w-6" />
|
||||
@ -53,6 +54,9 @@ export default function TabNavigation() {
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
<div className="flex items-center justify-center h-full px-2">
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
|
||||
@ -7,10 +7,10 @@ const buttonVariants = cva(
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
outline: "border-2 border-primary text-primary hover:bg-primary hover:text-white",
|
||||
ghost: "hover:bg-secondary hover:text-secondary-foreground",
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90 dark:bg-primary dark:hover:bg-primary/80",
|
||||
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 dark:bg-primary/20 dark:text-primary dark:hover:bg-primary/30",
|
||||
outline: "border-2 border-primary text-primary hover:bg-primary hover:text-white dark:border-primary dark:text-primary dark:hover:bg-primary dark:hover:text-white",
|
||||
ghost: "hover:bg-secondary hover:text-secondary-foreground dark:hover:bg-gray-800 dark:hover:text-gray-200",
|
||||
},
|
||||
size: {
|
||||
default: "h-12 px-6 py-3",
|
||||
|
||||
@ -8,7 +8,7 @@ const Card = React.forwardRef<
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"rounded-2xl border border-gray-200 bg-white shadow-sm",
|
||||
"rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@ -46,7 +46,7 @@ const CardDescription = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<p
|
||||
ref={ref}
|
||||
className={cn("text-sm text-gray-600", className)}
|
||||
className={cn("text-sm text-gray-600 dark:text-gray-400", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
|
||||
2
data/.gitkeep
Normal file
@ -0,0 +1,2 @@
|
||||
# Ce dossier contiendra clients.json (ignoré par git)
|
||||
|
||||
BIN
dist/compagnon-admin-debug.apk
vendored
BIN
dist/compagnon-lagon-beta.apk
vendored
Normal file
@ -6,14 +6,8 @@ const nextConfig = {
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
images: {
|
||||
formats: ["image/avif", "image/webp"],
|
||||
minimumCacheTTL: 60,
|
||||
unoptimized: true,
|
||||
},
|
||||
experimental: {
|
||||
optimizePackageImports: ["lucide-react"],
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
|
||||
|
||||
@ -6,14 +6,8 @@ const nextConfig = {
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
images: {
|
||||
formats: ["image/avif", "image/webp"],
|
||||
minimumCacheTTL: 60,
|
||||
unoptimized: true,
|
||||
},
|
||||
experimental: {
|
||||
optimizePackageImports: ["lucide-react"],
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
swcMinify: true,
|
||||
output: "standalone",
|
||||
// Mode serveur (pas d'export statique)
|
||||
// Les API routes fonctionnent normalement
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
images: {
|
||||
11
package-lock.json
generated
@ -15,6 +15,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.460.0",
|
||||
"next": "^14.2.33",
|
||||
"next-themes": "^0.4.6",
|
||||
"qrcode.react": "^4.2.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
@ -4757,6 +4758,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/next-themes": {
|
||||
"version": "0.4.6",
|
||||
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz",
|
||||
"integrity": "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/next/node_modules/postcss": {
|
||||
"version": "8.4.31",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.460.0",
|
||||
"next": "^14.2.33",
|
||||
"next-themes": "^0.4.6",
|
||||
"qrcode.react": "^4.2.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
|
||||
209
scripts/build-apk-admin.sh
Executable file
@ -0,0 +1,209 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Build APK Admin - Compagnon du Lagon"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Couleurs pour les messages
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Vérifier qu'on est dans le bon répertoire
|
||||
if [ ! -f "package.json" ]; then
|
||||
echo "❌ Erreur: Exécutez ce script depuis la racine du projet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Étape 1: Créer la configuration Next.js pour l'export statique
|
||||
echo -e "${BLUE}📦 Étape 1/6: Configuration Next.js pour export statique${NC}"
|
||||
cat > next.config.export.js << 'EOF'
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
swcMinify: true,
|
||||
output: "export",
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
EOF
|
||||
|
||||
# Copier la config pour le build
|
||||
cp next.config.export.js next.config.js
|
||||
|
||||
echo -e "${GREEN}✅ Configuration créée${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 2: Installer les dépendances si nécessaire
|
||||
echo -e "${BLUE}📦 Étape 2/6: Vérification des dépendances${NC}"
|
||||
|
||||
# Vérifier SDKMAN
|
||||
if [ ! -f "$HOME/.sdkman/bin/sdkman-init.sh" ]; then
|
||||
echo "Installation de SDKMAN..."
|
||||
curl -s "https://get.sdkman.io" | bash
|
||||
source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
fi
|
||||
|
||||
source "$HOME/.sdkman/bin/sdkman-init.sh" 2>/dev/null || true
|
||||
|
||||
# Vérifier Java 21
|
||||
if ! java -version 2>&1 | grep -q "21"; then
|
||||
echo "Installation de Java 21..."
|
||||
sdk install java 21.0.1-tem
|
||||
sdk use java 21.0.1-tem
|
||||
fi
|
||||
|
||||
# Vérifier Android SDK
|
||||
if [ ! -d "$HOME/Android/Sdk" ]; then
|
||||
echo "Installation d'Android SDK..."
|
||||
mkdir -p "$HOME/Android/Sdk/cmdline-tools"
|
||||
cd "$HOME/Android/Sdk/cmdline-tools"
|
||||
wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
|
||||
unzip -q commandlinetools-linux-9477386_latest.zip
|
||||
mv cmdline-tools latest
|
||||
rm commandlinetools-linux-9477386_latest.zip
|
||||
cd -
|
||||
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
|
||||
yes | sdkmanager --licenses || true
|
||||
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
|
||||
fi
|
||||
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "Installation des dépendances Node.js..."
|
||||
npm install --include=dev
|
||||
else
|
||||
echo "Dépendances Node.js déjà installées"
|
||||
fi
|
||||
|
||||
# Installer Capacitor si nécessaire
|
||||
if ! npm list @capacitor/core > /dev/null 2>&1; then
|
||||
echo "Installation de Capacitor..."
|
||||
npm install @capacitor/core @capacitor/cli @capacitor/android
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Dépendances OK${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 3: Build Next.js
|
||||
echo -e "${BLUE}📦 Étape 3/6: Build Next.js (export statique)${NC}"
|
||||
rm -rf .next out
|
||||
|
||||
# Exclure temporairement les routes API pour l'export statique
|
||||
if [ -d "app/api" ]; then
|
||||
echo "Exclusion temporaire des routes API..."
|
||||
mv app/api /tmp/api-backup-$$
|
||||
echo -e "${GREEN}✅ Routes API déplacées temporairement${NC}"
|
||||
fi
|
||||
|
||||
if npm run build; then
|
||||
echo -e "${GREEN}✅ Build Next.js réussi${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Build avec avertissements, continuation...${NC}"
|
||||
npm run build -- --no-lint || true
|
||||
fi
|
||||
|
||||
# Restaurer les routes API
|
||||
if [ -d "/tmp/api-backup-$$" ]; then
|
||||
mv /tmp/api-backup-$$ app/api
|
||||
echo -e "${GREEN}✅ Routes API restaurées${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Vérifier que le dossier out existe
|
||||
if [ ! -d "out" ]; then
|
||||
echo "❌ Erreur: Le dossier 'out' n'a pas été créé"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Étape 4: Initialiser/Configurer Capacitor
|
||||
echo -e "${BLUE}📦 Étape 4/6: Configuration Capacitor${NC}"
|
||||
|
||||
# Initialiser Capacitor si nécessaire
|
||||
if [ ! -f "capacitor.config.ts" ]; then
|
||||
echo "Initialisation de Capacitor..."
|
||||
npx cap init "Compagnon Admin" com.pensionmarama.admin --web-dir=out
|
||||
else
|
||||
echo "Capacitor déjà initialisé"
|
||||
# Mettre à jour la config pour pointer vers out
|
||||
cat > capacitor.config.ts << 'EOF'
|
||||
import { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'com.pensionmarama.admin',
|
||||
appName: 'Compagnon Admin',
|
||||
webDir: 'out',
|
||||
server: {
|
||||
androidScheme: 'https'
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Capacitor configuré${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 5: Synchroniser avec Android
|
||||
echo -e "${BLUE}📦 Étape 5/6: Synchronisation Android${NC}"
|
||||
|
||||
# Ajouter Android si nécessaire
|
||||
if [ ! -d "android" ]; then
|
||||
echo "Ajout de la plateforme Android..."
|
||||
npx cap add android
|
||||
fi
|
||||
|
||||
# Synchroniser
|
||||
echo "Synchronisation Capacitor..."
|
||||
npx cap sync android
|
||||
|
||||
echo -e "${GREEN}✅ Android synchronisé${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 6: Générer l'APK
|
||||
echo -e "${BLUE}📦 Étape 6/6: Génération de l'APK${NC}"
|
||||
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
|
||||
|
||||
cd android
|
||||
./gradlew assembleDebug
|
||||
cd ..
|
||||
|
||||
# Copier l'APK généré
|
||||
if [ -f "android/app/build/outputs/apk/debug/app-debug.apk" ]; then
|
||||
mkdir -p dist
|
||||
cp android/app/build/outputs/apk/debug/app-debug.apk dist/compagnon-admin-debug.apk
|
||||
echo ""
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}✅ APK ADMIN GÉNÉRÉ AVEC SUCCÈS !${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "📱 Fichier: ${BLUE}dist/compagnon-admin-debug.apk${NC}"
|
||||
APK_SIZE=$(du -h dist/compagnon-admin-debug.apk | cut -f1)
|
||||
echo -e "📊 Taille: ${BLUE}${APK_SIZE}${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}📤 Pour distribuer aux administrateurs:${NC}"
|
||||
echo " 1. Envoyez le fichier dist/compagnon-admin-debug.apk"
|
||||
echo " 2. Demandez-leur d'activer 'Sources inconnues'"
|
||||
echo " 3. Installer l'APK sur leur téléphone"
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔄 Pour mettre à jour:${NC}"
|
||||
echo " Relancez simplement ce script !"
|
||||
echo ""
|
||||
else
|
||||
echo "❌ L'APK n'a pas été généré. Vérifiez les erreurs ci-dessus."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
234
scripts/build-apk-simple.sh
Executable file
@ -0,0 +1,234 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Build APK - Compagnon du Lagon"
|
||||
echo "=================================="
|
||||
echo ""
|
||||
|
||||
# Couleurs pour les messages
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Vérifier qu'on est dans le bon répertoire
|
||||
if [ ! -f "package.json" ]; then
|
||||
echo "❌ Erreur: Exécutez ce script depuis la racine du projet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Étape 1: Créer la configuration Next.js pour l'export statique
|
||||
echo -e "${BLUE}📦 Étape 1/6: Configuration Next.js pour export statique${NC}"
|
||||
cat > next.config.export.js << 'EOF'
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
swcMinify: true,
|
||||
output: "export",
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
EOF
|
||||
|
||||
# Copier la config pour le build
|
||||
cp next.config.export.js next.config.js
|
||||
|
||||
echo -e "${GREEN}✅ Configuration créée${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 2: Installer les dépendances si nécessaire
|
||||
echo -e "${BLUE}📦 Étape 2/6: Vérification des dépendances${NC}"
|
||||
|
||||
# Vérifier SDKMAN
|
||||
if [ ! -f "$HOME/.sdkman/bin/sdkman-init.sh" ]; then
|
||||
echo "SDKMAN non trouvé. Installation..."
|
||||
curl -s "https://get.sdkman.io" | bash
|
||||
fi
|
||||
|
||||
# Initialiser SDKMAN
|
||||
source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
|
||||
# Vérifier Java 21
|
||||
if ! sdk current java 2>&1 | grep -q "21.0"; then
|
||||
echo "Installation de Java 21 (requis par Capacitor)..."
|
||||
sdk install java 21.0.1-tem
|
||||
sdk use java 21.0.1-tem
|
||||
fi
|
||||
|
||||
# Vérifier Android SDK
|
||||
if [ ! -d "$HOME/Android/Sdk" ]; then
|
||||
echo "Installation d'Android SDK..."
|
||||
mkdir -p "$HOME/Android/Sdk/cmdline-tools"
|
||||
cd "$HOME/Android/Sdk/cmdline-tools"
|
||||
wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
|
||||
unzip -q commandlinetools-linux-9477386_latest.zip
|
||||
mv cmdline-tools latest
|
||||
rm commandlinetools-linux-9477386_latest.zip
|
||||
cd -
|
||||
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
|
||||
yes | sdkmanager --licenses || true
|
||||
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
|
||||
fi
|
||||
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "Installation des dépendances Node.js..."
|
||||
npm install --include=dev
|
||||
else
|
||||
echo "Dépendances Node.js déjà installées"
|
||||
fi
|
||||
|
||||
# Installer Capacitor si nécessaire
|
||||
if ! npm list @capacitor/core > /dev/null 2>&1; then
|
||||
echo "Installation de Capacitor..."
|
||||
npm install @capacitor/core @capacitor/cli @capacitor/android
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Dépendances OK${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 3: Build Next.js
|
||||
echo -e "${BLUE}📦 Étape 3/6: Build Next.js (export statique)${NC}"
|
||||
rm -rf .next out
|
||||
|
||||
# Exclure temporairement les routes API pour l'export statique
|
||||
if [ -d "app/api" ]; then
|
||||
echo "Exclusion temporaire des routes API..."
|
||||
mv app/api /tmp/api-backup-$$
|
||||
echo -e "${GREEN}✅ Routes API déplacées temporairement${NC}"
|
||||
fi
|
||||
|
||||
if npm run build; then
|
||||
echo -e "${GREEN}✅ Build Next.js réussi${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Build avec avertissements, continuation...${NC}"
|
||||
npm run build -- --no-lint || true
|
||||
fi
|
||||
|
||||
# Restaurer les routes API
|
||||
if [ -d "/tmp/api-backup-$$" ]; then
|
||||
mv /tmp/api-backup-$$ app/api
|
||||
echo -e "${GREEN}✅ Routes API restaurées${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Vérifier que le dossier out existe
|
||||
if [ ! -d "out" ]; then
|
||||
echo "❌ Erreur: Le dossier 'out' n'a pas été créé"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Étape 4: Initialiser/Configurer Capacitor
|
||||
echo -e "${BLUE}📦 Étape 4/6: Configuration Capacitor${NC}"
|
||||
|
||||
# Initialiser Capacitor si nécessaire
|
||||
if [ ! -f "capacitor.config.ts" ]; then
|
||||
echo "Initialisation de Capacitor..."
|
||||
npx cap init "Compagnon du Lagon" com.pensionmarama.app --web-dir=out
|
||||
else
|
||||
echo "Capacitor déjà initialisé"
|
||||
# Mettre à jour la config pour pointer vers out
|
||||
cat > capacitor.config.ts << 'EOF'
|
||||
import { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'com.pensionmarama.app',
|
||||
appName: 'Compagnon du Lagon',
|
||||
webDir: 'out',
|
||||
server: {
|
||||
androidScheme: 'https'
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Ajouter la plateforme Android si nécessaire
|
||||
if [ ! -d "android" ]; then
|
||||
echo "Ajout de la plateforme Android..."
|
||||
npx cap add android
|
||||
else
|
||||
echo "Plateforme Android déjà présente"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Capacitor configuré${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 5: Synchroniser les assets
|
||||
echo -e "${BLUE}📦 Étape 5/6: Synchronisation des assets${NC}"
|
||||
npx cap sync android
|
||||
echo -e "${GREEN}✅ Assets synchronisés${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 6: Build l'APK
|
||||
echo -e "${BLUE}📦 Étape 6/6: Génération de l'APK${NC}"
|
||||
|
||||
# Initialiser SDKMAN et configurer Java
|
||||
source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
sdk use java 21.0.1-tem
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
|
||||
cd android
|
||||
|
||||
# Vérifier que gradlew existe et est exécutable
|
||||
if [ ! -f "./gradlew" ]; then
|
||||
echo "❌ Erreur: gradlew n'existe pas"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x ./gradlew
|
||||
|
||||
# Build l'APK
|
||||
echo "Construction de l'APK debug..."
|
||||
./gradlew clean assembleDebug
|
||||
|
||||
cd ..
|
||||
|
||||
# Copier l'APK dans dist/
|
||||
echo ""
|
||||
echo -e "${BLUE}📦 Copie de l'APK...${NC}"
|
||||
mkdir -p dist
|
||||
|
||||
if [ -f "android/app/build/outputs/apk/debug/app-debug.apk" ]; then
|
||||
cp android/app/build/outputs/apk/debug/app-debug.apk dist/compagnon-lagon-beta.apk
|
||||
|
||||
# Afficher les infos
|
||||
APK_SIZE=$(du -h dist/compagnon-lagon-beta.apk | cut -f1)
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}✅ APK GÉNÉRÉ AVEC SUCCÈS !${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "📱 Fichier: ${BLUE}dist/compagnon-lagon-beta.apk${NC}"
|
||||
echo -e "📊 Taille: ${BLUE}${APK_SIZE}${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}📤 Pour distribuer aux bêta-testeurs:${NC}"
|
||||
echo " 1. Envoyez le fichier dist/compagnon-lagon-beta.apk"
|
||||
echo " 2. Demandez-leur d'activer 'Sources inconnues'"
|
||||
echo " 3. Installer l'APK sur leur téléphone"
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔄 Pour mettre à jour:${NC}"
|
||||
echo " Relancez simplement ce script !"
|
||||
echo ""
|
||||
|
||||
else
|
||||
echo -e "${RED}❌ Erreur: L'APK n'a pas été généré${NC}"
|
||||
echo "Vérifiez les erreurs ci-dessus"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restaurer la config Next.js originale si elle existe
|
||||
if [ -f "next.config.js.backup" ]; then
|
||||
mv next.config.js.backup next.config.js
|
||||
fi
|
||||
|
||||
190
scripts/build-server.sh
Executable file
@ -0,0 +1,190 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Build de l'admin pour déploiement serveur"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
|
||||
# Couleurs
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Vérifier qu'on est dans le bon répertoire
|
||||
if [ ! -f "package.json" ]; then
|
||||
echo "❌ Erreur: Exécutez ce script depuis la racine du projet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Étape 1: Configuration Next.js pour serveur
|
||||
echo -e "${BLUE}📦 Étape 1/4: Configuration Next.js${NC}"
|
||||
if [ -f "next.config.js" ]; then
|
||||
cp next.config.js next.config.js.backup
|
||||
fi
|
||||
cp next.config.server.js next.config.js
|
||||
echo -e "${GREEN}✅ Configuration serveur activée${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 2: Installation des dépendances
|
||||
echo -e "${BLUE}📦 Étape 2/4: Vérification des dépendances${NC}"
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "Installation des dépendances..."
|
||||
npm install
|
||||
else
|
||||
echo "Dépendances déjà installées"
|
||||
fi
|
||||
echo -e "${GREEN}✅ Dépendances OK${NC}"
|
||||
echo ""
|
||||
|
||||
# Étape 3: Build Next.js
|
||||
echo -e "${BLUE}📦 Étape 3/4: Build de production${NC}"
|
||||
rm -rf .next
|
||||
|
||||
if npm run build; then
|
||||
echo -e "${GREEN}✅ Build réussi${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Build avec avertissements${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Étape 4: Préparer les fichiers pour le déploiement
|
||||
echo -e "${BLUE}📦 Étape 4/4: Préparation du déploiement${NC}"
|
||||
|
||||
# Créer le dossier de déploiement
|
||||
mkdir -p deploy
|
||||
rm -rf deploy/*
|
||||
|
||||
# Copier les fichiers nécessaires
|
||||
echo "Copie des fichiers..."
|
||||
cp -r .next deploy/
|
||||
cp -r public deploy/
|
||||
cp package.json deploy/
|
||||
cp package-lock.json deploy/ 2>/dev/null || true
|
||||
cp next.config.server.js deploy/next.config.js
|
||||
|
||||
# Créer le dossier data
|
||||
mkdir -p deploy/data
|
||||
cp data/.gitkeep deploy/data/ 2>/dev/null || true
|
||||
|
||||
# Créer un fichier .env.example
|
||||
cat > deploy/.env.example << 'EOF'
|
||||
# Mot de passe admin
|
||||
ADMIN_PASSWORD=votre_mot_de_passe_securise
|
||||
|
||||
# Port (optionnel, par défaut 3000)
|
||||
PORT=3000
|
||||
EOF
|
||||
|
||||
# Créer un fichier de lancement
|
||||
cat > deploy/start.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
# Script de lancement pour le serveur
|
||||
|
||||
# Installer les dépendances production uniquement
|
||||
npm ci --production
|
||||
|
||||
# Démarrer le serveur
|
||||
npm start
|
||||
EOF
|
||||
|
||||
chmod +x deploy/start.sh
|
||||
|
||||
# Créer un fichier README pour le déploiement
|
||||
cat > deploy/DEPLOY.md << 'EOF'
|
||||
# Déploiement sur serveur
|
||||
|
||||
## Étapes de déploiement
|
||||
|
||||
1. **Transférer les fichiers sur le serveur**
|
||||
```bash
|
||||
rsync -avz --delete deploy/ user@marama.syoul.fr:/var/www/pension-admin/
|
||||
```
|
||||
|
||||
2. **Se connecter au serveur**
|
||||
```bash
|
||||
ssh user@marama.syoul.fr
|
||||
cd /var/www/pension-admin
|
||||
```
|
||||
|
||||
3. **Configurer les variables d'environnement**
|
||||
```bash
|
||||
cp .env.example .env
|
||||
nano .env # Modifier ADMIN_PASSWORD
|
||||
```
|
||||
|
||||
4. **Installer et démarrer**
|
||||
```bash
|
||||
chmod +x start.sh
|
||||
./start.sh
|
||||
```
|
||||
|
||||
5. **Avec PM2 (recommandé)**
|
||||
```bash
|
||||
npm install -g pm2
|
||||
pm2 start npm --name "pension-admin" -- start
|
||||
pm2 save
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
## Configuration Nginx (reverse proxy)
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name admin.marama.syoul.fr;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## SSL avec Certbot
|
||||
|
||||
```bash
|
||||
sudo certbot --nginx -d admin.marama.syoul.fr
|
||||
```
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Fichiers prêts dans deploy/${NC}"
|
||||
echo ""
|
||||
|
||||
# Restaurer la config originale
|
||||
if [ -f "next.config.js.backup" ]; then
|
||||
mv next.config.js.backup next.config.js
|
||||
fi
|
||||
|
||||
# Afficher le résumé
|
||||
DEPLOY_SIZE=$(du -sh deploy | cut -f1)
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}✅ BUILD SERVEUR TERMINÉ !${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "📁 Dossier de déploiement: ${BLUE}deploy/${NC}"
|
||||
echo -e "📊 Taille: ${BLUE}${DEPLOY_SIZE}${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}📤 Prochaines étapes:${NC}"
|
||||
echo ""
|
||||
echo "1. Transférer sur le serveur:"
|
||||
echo " ${BLUE}rsync -avz --delete deploy/ user@marama.syoul.fr:/var/www/pension-admin/${NC}"
|
||||
echo ""
|
||||
echo "2. Sur le serveur:"
|
||||
echo " ${BLUE}cd /var/www/pension-admin${NC}"
|
||||
echo " ${BLUE}./start.sh${NC}"
|
||||
echo ""
|
||||
echo "3. Configurer le mot de passe admin:"
|
||||
echo " ${BLUE}nano .env${NC}"
|
||||
echo " ${BLUE}ADMIN_PASSWORD=votre_mot_de_passe${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}📖 Documentation complète: deploy/DEPLOY.md${NC}"
|
||||
echo ""
|
||||
|
||||
@ -17,10 +17,20 @@ const config: Config = {
|
||||
secondary: {
|
||||
DEFAULT: "#ECFCCB",
|
||||
foreground: "#0E7490",
|
||||
dark: "#1a3a2e",
|
||||
},
|
||||
background: {
|
||||
DEFAULT: "#FAFAFA",
|
||||
dark: "#0f172a",
|
||||
},
|
||||
foreground: {
|
||||
DEFAULT: "#1f2937",
|
||||
dark: "#f1f5f9",
|
||||
},
|
||||
border: {
|
||||
DEFAULT: "#e5e7eb",
|
||||
dark: "#334155",
|
||||
},
|
||||
background: "#FAFAFA",
|
||||
foreground: "#1f2937",
|
||||
border: "#e5e7eb",
|
||||
},
|
||||
borderRadius: {
|
||||
xl: "1rem",
|
||||
|
||||