CognxSafeTrack commited on
Commit ·
dced83b
1
Parent(s): cc442ef
chore: add netlify.toml and fix tsconfig exports
Browse files- apps/api/src/services/whatsapp.ts +48 -4
- netlify.toml +9 -0
- packages/tsconfig/package.json +2 -1
apps/api/src/services/whatsapp.ts
CHANGED
|
@@ -30,15 +30,59 @@ export class WhatsAppService {
|
|
| 30 |
});
|
| 31 |
|
| 32 |
if (activeEnrollment) {
|
| 33 |
-
//
|
| 34 |
-
console.log(`User ${user.id}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
return;
|
| 36 |
}
|
| 37 |
|
| 38 |
// 3. Handle Commands
|
| 39 |
if (normalizedText === 'INSCRIPTION') {
|
| 40 |
-
console.log('
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
}
|
| 44 |
}
|
|
|
|
| 30 |
});
|
| 31 |
|
| 32 |
if (activeEnrollment) {
|
| 33 |
+
// Handle daily response
|
| 34 |
+
console.log(`User ${user.id} responding to day ${activeEnrollment.currentDay}`);
|
| 35 |
+
|
| 36 |
+
// Save response
|
| 37 |
+
await prisma.response.create({
|
| 38 |
+
data: {
|
| 39 |
+
enrollmentId: activeEnrollment.id,
|
| 40 |
+
userId: user.id,
|
| 41 |
+
dayNumber: activeEnrollment.currentDay,
|
| 42 |
+
content: text
|
| 43 |
+
}
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
// TODO: Schedule next day or send immediate feedback
|
| 47 |
+
// For MVP, just acknowledge reception
|
| 48 |
+
// await sendMessage(phone, "Réponse enregistrée ! À demain pour la suite.");
|
| 49 |
+
|
| 50 |
return;
|
| 51 |
}
|
| 52 |
|
| 53 |
// 3. Handle Commands
|
| 54 |
if (normalizedText === 'INSCRIPTION') {
|
| 55 |
+
console.log('Processing new enrollment...');
|
| 56 |
+
|
| 57 |
+
// Find default track (Business Model Express)
|
| 58 |
+
const defaultTrack = await prisma.track.findFirst({
|
| 59 |
+
where: { title: "Business Model Express" }
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
if (!defaultTrack) {
|
| 63 |
+
console.error('Default track not found!');
|
| 64 |
+
return;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// Create enrollment
|
| 68 |
+
await prisma.enrollment.create({
|
| 69 |
+
data: {
|
| 70 |
+
userId: user.id,
|
| 71 |
+
trackId: defaultTrack.id,
|
| 72 |
+
startedAt: new Date(),
|
| 73 |
+
status: 'ACTIVE',
|
| 74 |
+
currentDay: 1
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
console.log(`User ${user.id} enrolled in ${defaultTrack.title}`);
|
| 79 |
+
|
| 80 |
+
// TODO: Send Day 1 Content immediately
|
| 81 |
+
// const day1 = await prisma.trackDay.findFirst(...)
|
| 82 |
+
// await sendMessage(phone, day1.textContent);
|
| 83 |
+
} else {
|
| 84 |
+
console.log('Unknown command, sending menu...');
|
| 85 |
+
// TODO: Send "Envoyez INSCRIPTION pour commencer"
|
| 86 |
}
|
| 87 |
}
|
| 88 |
}
|
netlify.toml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build]
|
| 2 |
+
command = "pnpm --filter admin... run build"
|
| 3 |
+
publish = "apps/admin/dist"
|
| 4 |
+
|
| 5 |
+
[context.production]
|
| 6 |
+
command = "pnpm --filter admin... run build"
|
| 7 |
+
|
| 8 |
+
[context.deploy-preview]
|
| 9 |
+
command = "pnpm --filter admin... run build"
|
packages/tsconfig/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
| 5 |
"files": [
|
| 6 |
"base.json",
|
| 7 |
"nextjs.json",
|
| 8 |
-
"react.json"
|
|
|
|
| 9 |
]
|
| 10 |
}
|
|
|
|
| 5 |
"files": [
|
| 6 |
"base.json",
|
| 7 |
"nextjs.json",
|
| 8 |
+
"react.json",
|
| 9 |
+
"vite-react.json"
|
| 10 |
]
|
| 11 |
}
|