krsyer-server-monitor-pro 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/UPDATES.md +84 -0
- package/lib/controllers/cloudflareController.js +1 -1
- package/lib/controllers/dockerController.js +1 -1
- package/lib/controllers/networkController.js +1 -1
- package/lib/controllers/serverController.js +1 -1
- package/lib/ecosystem.config.js +1 -1
- package/lib/middleware/saasAuth.js +1 -1
- package/lib/routes/cloudflareRoutes.js +1 -1
- package/lib/routes/dockerRoutes.js +1 -1
- package/lib/routes/networkRoutes.js +1 -1
- package/lib/routes/serverRoutes.js +1 -1
- package/lib/server.js +1 -1
- package/lib/services/cashfreeService.js +1 -1
- package/package.json +8 -1
- package/guestguru-api/.idea/guestguru-api.iml +0 -9
- package/guestguru-api/.idea/misc.xml +0 -6
- package/guestguru-api/.idea/modules.xml +0 -8
- package/guestguru-api/.idea/vcs.xml +0 -6
- package/guestguru-api/API_DESIGN_GUIDE.md +0 -140
- package/guestguru-api/API_DOCUMENTATION.md +0 -504
- package/guestguru-api/API_REQUIREMENTS_TENANTS.md +0 -110
- package/guestguru-api/AVAILABLE_TENANT_ENDPOINTS.md +0 -137
- package/guestguru-api/BACKEND_INSTRUCTIONS.md +0 -77
- package/guestguru-api/DINING_MODULE_INTEGRATION.md +0 -175
- package/guestguru-api/FRONTEND_FINANCE_MODULE.md +0 -151
- package/guestguru-api/README.md +0 -93
- package/guestguru-api/app.json +0 -12
- package/guestguru-api/database.sqlite +0 -0
- package/guestguru-api/eas.json +0 -21
- package/guestguru-api/ecosystem.config.js +0 -19
- package/guestguru-api/fix_db_schema.js +0 -77
- package/guestguru-api/list_columns.js +0 -27
- package/guestguru-api/package.json +0 -34
- package/guestguru-api/postman_backend_v2.json +0 -1745
- package/guestguru-api/postman_collection.json +0 -477
- package/guestguru-api/postman_environment.json +0 -17
- package/guestguru-api/public/icon.png +0 -0
- package/guestguru-api/public/icon_b64.txt +0 -1
- package/guestguru-api/readd_column.js +0 -27
- package/guestguru-api/server.js +0 -263
- package/guestguru-api/test_cashfree_connection.js +0 -52
- package/license-portal/.env.example +0 -15
- package/license-portal/README.md +0 -93
- package/license-portal/ecosystem.config.js +0 -16
- package/license-portal/package.json +0 -22
- package/license-portal/server.js +0 -306
- package/license-portal/services/emailService.js +0 -126
- package/license-portal/views/pricing.html +0 -358
- package/temp_cf_method.js +0 -48
|
@@ -1,504 +0,0 @@
|
|
|
1
|
-
# PG Management System - Backend API
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
This is a Node.js/Express backend for a SaaS-based PG Management application. It supports Authentication, Role-based access control (Superadmin, Admin, Customer), Room Management, and Payment processing (Stubbed/integrated logic).
|
|
5
|
-
|
|
6
|
-
## Base URL
|
|
7
|
-
`http://localhost:5000`
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
- **Authentication**: JWT based Login/Signup.
|
|
11
|
-
- **Roles**:
|
|
12
|
-
- `superadmin`: Full access.
|
|
13
|
-
- `admin`: Manage rooms, view all payments.
|
|
14
|
-
- `customer`: View own dashboard, make payments.
|
|
15
|
-
- **Payments**: Simulates payment gateway intent and confirmation.
|
|
16
|
-
- **Database**: SQLite (Development), configurable for Postgres/MySQL.
|
|
17
|
-
|
|
18
|
-
## Setup
|
|
19
|
-
1. `npm install`
|
|
20
|
-
2. `npm start`
|
|
21
|
-
3. Super Admin default credentials: `admin@pg.com` / `admin123`
|
|
22
|
-
|
|
23
|
-
## Postman Collection
|
|
24
|
-
Copy the JSON below and import it into Postman.
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"info": {
|
|
29
|
-
"_postman_id": "pg-backend-collection",
|
|
30
|
-
"name": "PG Management API",
|
|
31
|
-
"description": "Postman collection for PG Management SaaS Backend",
|
|
32
|
-
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
33
|
-
},
|
|
34
|
-
"item": [
|
|
35
|
-
{
|
|
36
|
-
"name": "Auth",
|
|
37
|
-
"item": [
|
|
38
|
-
{
|
|
39
|
-
"name": "Signup (Customer)",
|
|
40
|
-
"request": {
|
|
41
|
-
"method": "POST",
|
|
42
|
-
"header": [],
|
|
43
|
-
"body": {
|
|
44
|
-
"mode": "raw",
|
|
45
|
-
"raw": "{\n \"name\": \"John Customer\",\n \"email\": \"customer@example.com\",\n \"password\": \"password123\",\n \"phone\": \"9876543210\",\n \"role\": \"customer\"\n}",
|
|
46
|
-
"options": {
|
|
47
|
-
"raw": {
|
|
48
|
-
"language": "json"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"url": {
|
|
53
|
-
"raw": "{{url}}/api/auth/signup",
|
|
54
|
-
"host": [
|
|
55
|
-
"{{url}}"
|
|
56
|
-
],
|
|
57
|
-
"path": [
|
|
58
|
-
"api",
|
|
59
|
-
"auth",
|
|
60
|
-
"signup"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"response": []
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"name": "Signin (Admin)",
|
|
68
|
-
"event": [
|
|
69
|
-
{
|
|
70
|
-
"listen": "test",
|
|
71
|
-
"script": {
|
|
72
|
-
"exec": [
|
|
73
|
-
"var jsonData = pm.response.json();",
|
|
74
|
-
"if(jsonData.accessToken) {",
|
|
75
|
-
" pm.environment.set(\"token\", jsonData.accessToken);",
|
|
76
|
-
" console.log(\"Token set successfully\");",
|
|
77
|
-
"}"
|
|
78
|
-
],
|
|
79
|
-
"type": "text/javascript"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
"request": {
|
|
84
|
-
"method": "POST",
|
|
85
|
-
"header": [],
|
|
86
|
-
"body": {
|
|
87
|
-
"mode": "raw",
|
|
88
|
-
"raw": "{\n \"email\": \"admin@pg.com\",\n \"password\": \"admin123\"\n}",
|
|
89
|
-
"options": {
|
|
90
|
-
"raw": {
|
|
91
|
-
"language": "json"
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
"url": {
|
|
96
|
-
"raw": "{{url}}/api/auth/signin",
|
|
97
|
-
"host": [
|
|
98
|
-
"{{url}}"
|
|
99
|
-
],
|
|
100
|
-
"path": [
|
|
101
|
-
"api",
|
|
102
|
-
"auth",
|
|
103
|
-
"signin"
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"response": []
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"name": "Signin (Customer)",
|
|
111
|
-
"event": [
|
|
112
|
-
{
|
|
113
|
-
"listen": "test",
|
|
114
|
-
"script": {
|
|
115
|
-
"exec": [
|
|
116
|
-
"var jsonData = pm.response.json();",
|
|
117
|
-
"if(jsonData.accessToken) {",
|
|
118
|
-
" pm.environment.set(\"token\", jsonData.accessToken);",
|
|
119
|
-
"}"
|
|
120
|
-
],
|
|
121
|
-
"type": "text/javascript"
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
"request": {
|
|
126
|
-
"method": "POST",
|
|
127
|
-
"header": [],
|
|
128
|
-
"body": {
|
|
129
|
-
"mode": "raw",
|
|
130
|
-
"raw": "{\n \"email\": \"customer@example.com\",\n \"password\": \"password123\"\n}",
|
|
131
|
-
"options": {
|
|
132
|
-
"raw": {
|
|
133
|
-
"language": "json"
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
"url": {
|
|
138
|
-
"raw": "{{url}}/api/auth/signin",
|
|
139
|
-
"host": [
|
|
140
|
-
"{{url}}"
|
|
141
|
-
],
|
|
142
|
-
"path": [
|
|
143
|
-
"api",
|
|
144
|
-
"auth",
|
|
145
|
-
"signin"
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
"response": []
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"name": "Rooms",
|
|
155
|
-
"item": [
|
|
156
|
-
{
|
|
157
|
-
"name": "Get All Rooms",
|
|
158
|
-
"request": {
|
|
159
|
-
"method": "GET",
|
|
160
|
-
"header": [
|
|
161
|
-
{
|
|
162
|
-
"key": "x-access-token",
|
|
163
|
-
"value": "{{token}}",
|
|
164
|
-
"type": "text"
|
|
165
|
-
}
|
|
166
|
-
],
|
|
167
|
-
"url": {
|
|
168
|
-
"raw": "{{url}}/api/rooms",
|
|
169
|
-
"host": [
|
|
170
|
-
"{{url}}"
|
|
171
|
-
],
|
|
172
|
-
"path": [
|
|
173
|
-
"api",
|
|
174
|
-
"rooms"
|
|
175
|
-
]
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
"response": []
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"name": "Create Room (Admin)",
|
|
182
|
-
"request": {
|
|
183
|
-
"method": "POST",
|
|
184
|
-
"header": [
|
|
185
|
-
{
|
|
186
|
-
"key": "x-access-token",
|
|
187
|
-
"value": "{{token}}",
|
|
188
|
-
"type": "text"
|
|
189
|
-
}
|
|
190
|
-
],
|
|
191
|
-
"body": {
|
|
192
|
-
"mode": "raw",
|
|
193
|
-
"raw": "{\n \"roomNumber\": \"101\",\n \"floor\": 1,\n \"capacity\": 3,\n \"pricePerMonth\": 6000,\n \"amenities\": \"WiFi, TV\"\n}",
|
|
194
|
-
"options": {
|
|
195
|
-
"raw": {
|
|
196
|
-
"language": "json"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
"url": {
|
|
201
|
-
"raw": "{{url}}/api/rooms",
|
|
202
|
-
"host": [
|
|
203
|
-
"{{url}}"
|
|
204
|
-
],
|
|
205
|
-
"path": [
|
|
206
|
-
"api",
|
|
207
|
-
"rooms"
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
"response": []
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
"name": "Update Room (Admin)",
|
|
215
|
-
"request": {
|
|
216
|
-
"method": "PUT",
|
|
217
|
-
"header": [
|
|
218
|
-
{
|
|
219
|
-
"key": "x-access-token",
|
|
220
|
-
"value": "{{token}}",
|
|
221
|
-
"type": "text"
|
|
222
|
-
}
|
|
223
|
-
],
|
|
224
|
-
"body": {
|
|
225
|
-
"mode": "raw",
|
|
226
|
-
"raw": "{\n \"pricePerMonth\": 6500,\n \"floor\": 2,\n \"amenities\": \"WiFi, TV, AC\",\n \"isMaintenance\": true\n}",
|
|
227
|
-
"options": {
|
|
228
|
-
"raw": {
|
|
229
|
-
"language": "json"
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
"url": {
|
|
234
|
-
"raw": "{{url}}/api/rooms/:id",
|
|
235
|
-
"host": [
|
|
236
|
-
"{{url}}"
|
|
237
|
-
],
|
|
238
|
-
"path": [
|
|
239
|
-
"api",
|
|
240
|
-
"rooms",
|
|
241
|
-
":id"
|
|
242
|
-
],
|
|
243
|
-
"variable": [
|
|
244
|
-
{
|
|
245
|
-
"key": "id",
|
|
246
|
-
"value": "ENTER_ROOM_ID_HERE"
|
|
247
|
-
}
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
"response": []
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
"name": "Delete Room (Admin)",
|
|
255
|
-
"request": {
|
|
256
|
-
"method": "DELETE",
|
|
257
|
-
"header": [
|
|
258
|
-
{
|
|
259
|
-
"key": "x-access-token",
|
|
260
|
-
"value": "{{token}}",
|
|
261
|
-
"type": "text"
|
|
262
|
-
}
|
|
263
|
-
],
|
|
264
|
-
"url": {
|
|
265
|
-
"raw": "{{url}}/api/rooms/:id",
|
|
266
|
-
"host": [
|
|
267
|
-
"{{url}}"
|
|
268
|
-
],
|
|
269
|
-
"path": [
|
|
270
|
-
"api",
|
|
271
|
-
"rooms",
|
|
272
|
-
":id"
|
|
273
|
-
],
|
|
274
|
-
"variable": [
|
|
275
|
-
{
|
|
276
|
-
"key": "id",
|
|
277
|
-
"value": "ENTER_ROOM_ID_HERE"
|
|
278
|
-
}
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"response": []
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"name": "Payments",
|
|
288
|
-
"item": [
|
|
289
|
-
{
|
|
290
|
-
"name": "Create Payment Intent",
|
|
291
|
-
"request": {
|
|
292
|
-
"method": "POST",
|
|
293
|
-
"header": [
|
|
294
|
-
{
|
|
295
|
-
"key": "x-access-token",
|
|
296
|
-
"value": "{{token}}",
|
|
297
|
-
"type": "text"
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
"body": {
|
|
301
|
-
"mode": "raw",
|
|
302
|
-
"raw": "{\n \"amount\": 6000,\n \"type\": \"monthly_rent\"\n}",
|
|
303
|
-
"options": {
|
|
304
|
-
"raw": {
|
|
305
|
-
"language": "json"
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
"url": {
|
|
310
|
-
"raw": "{{url}}/api/payments/create-intent",
|
|
311
|
-
"host": [
|
|
312
|
-
"{{url}}"
|
|
313
|
-
],
|
|
314
|
-
"path": [
|
|
315
|
-
"api",
|
|
316
|
-
"payments",
|
|
317
|
-
"create-intent"
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
"response": []
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
"name": "Confirm Payment",
|
|
325
|
-
"request": {
|
|
326
|
-
"method": "POST",
|
|
327
|
-
"header": [
|
|
328
|
-
{
|
|
329
|
-
"key": "x-access-token",
|
|
330
|
-
"value": "{{token}}",
|
|
331
|
-
"type": "text"
|
|
332
|
-
}
|
|
333
|
-
],
|
|
334
|
-
"body": {
|
|
335
|
-
"mode": "raw",
|
|
336
|
-
"raw": "{\n \"paymentId\": \"PASTE_PAYMENT_ID_HERE\",\n \"transactionId\": \"TXN_99999\",\n \"method\": \"upi\"\n}",
|
|
337
|
-
"options": {
|
|
338
|
-
"raw": {
|
|
339
|
-
"language": "json"
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
"url": {
|
|
344
|
-
"raw": "{{url}}/api/payments/confirm",
|
|
345
|
-
"host": [
|
|
346
|
-
"{{url}}"
|
|
347
|
-
],
|
|
348
|
-
"path": [
|
|
349
|
-
"api",
|
|
350
|
-
"payments",
|
|
351
|
-
"confirm"
|
|
352
|
-
]
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
"response": []
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
"name": "My History (Customer)",
|
|
359
|
-
"request": {
|
|
360
|
-
"method": "GET",
|
|
361
|
-
"header": [
|
|
362
|
-
{
|
|
363
|
-
"key": "x-access-token",
|
|
364
|
-
"value": "{{token}}",
|
|
365
|
-
"type": "text"
|
|
366
|
-
}
|
|
367
|
-
],
|
|
368
|
-
"url": {
|
|
369
|
-
"raw": "{{url}}/api/payments/my-history",
|
|
370
|
-
"host": [
|
|
371
|
-
"{{url}}"
|
|
372
|
-
],
|
|
373
|
-
"path": [
|
|
374
|
-
"api",
|
|
375
|
-
"payments",
|
|
376
|
-
"my-history"
|
|
377
|
-
]
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
"response": []
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
"name": "All Payments (Admin)",
|
|
384
|
-
"request": {
|
|
385
|
-
"method": "GET",
|
|
386
|
-
"header": [
|
|
387
|
-
{
|
|
388
|
-
"key": "x-access-token",
|
|
389
|
-
"value": "{{token}}",
|
|
390
|
-
"type": "text"
|
|
391
|
-
}
|
|
392
|
-
],
|
|
393
|
-
"url": {
|
|
394
|
-
"raw": "{{url}}/api/payments?status=pending",
|
|
395
|
-
"host": [
|
|
396
|
-
"{{url}}"
|
|
397
|
-
],
|
|
398
|
-
"path": [
|
|
399
|
-
"api",
|
|
400
|
-
"payments"
|
|
401
|
-
],
|
|
402
|
-
"query": [
|
|
403
|
-
{
|
|
404
|
-
"key": "status",
|
|
405
|
-
"value": "pending",
|
|
406
|
-
"description": "Optional filter: pending, completed, failed"
|
|
407
|
-
}
|
|
408
|
-
]
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
"response": []
|
|
412
|
-
}
|
|
413
|
-
]
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
"name": "Dashboard",
|
|
417
|
-
"item": [
|
|
418
|
-
{
|
|
419
|
-
"name": "Admin Stats",
|
|
420
|
-
"request": {
|
|
421
|
-
"method": "GET",
|
|
422
|
-
"header": [
|
|
423
|
-
{
|
|
424
|
-
"key": "x-access-token",
|
|
425
|
-
"value": "{{token}}",
|
|
426
|
-
"type": "text"
|
|
427
|
-
}
|
|
428
|
-
],
|
|
429
|
-
"url": {
|
|
430
|
-
"raw": "{{url}}/api/dashboard/admin",
|
|
431
|
-
"host": [
|
|
432
|
-
"{{url}}"
|
|
433
|
-
],
|
|
434
|
-
"path": [
|
|
435
|
-
"api",
|
|
436
|
-
"dashboard",
|
|
437
|
-
"admin"
|
|
438
|
-
]
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
"response": []
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
"name": "Customer Dashboard",
|
|
445
|
-
"request": {
|
|
446
|
-
"method": "GET",
|
|
447
|
-
"header": [
|
|
448
|
-
{
|
|
449
|
-
"key": "x-access-token",
|
|
450
|
-
"value": "{{token}}",
|
|
451
|
-
"type": "text"
|
|
452
|
-
}
|
|
453
|
-
],
|
|
454
|
-
"url": {
|
|
455
|
-
"raw": "{{url}}/api/dashboard/customer",
|
|
456
|
-
"host": [
|
|
457
|
-
"{{url}}"
|
|
458
|
-
],
|
|
459
|
-
"path": [
|
|
460
|
-
"api",
|
|
461
|
-
"dashboard",
|
|
462
|
-
"customer"
|
|
463
|
-
]
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
"response": []
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
"name": "Announcements",
|
|
470
|
-
"request": {
|
|
471
|
-
"method": "GET",
|
|
472
|
-
"header": [
|
|
473
|
-
{
|
|
474
|
-
"key": "x-access-token",
|
|
475
|
-
"value": "{{token}}",
|
|
476
|
-
"type": "text"
|
|
477
|
-
}
|
|
478
|
-
],
|
|
479
|
-
"url": {
|
|
480
|
-
"raw": "{{url}}/api/dashboard/announcements",
|
|
481
|
-
"host": [
|
|
482
|
-
"{{url}}"
|
|
483
|
-
],
|
|
484
|
-
"path": [
|
|
485
|
-
"api",
|
|
486
|
-
"dashboard",
|
|
487
|
-
"announcements"
|
|
488
|
-
]
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
"response": []
|
|
492
|
-
}
|
|
493
|
-
]
|
|
494
|
-
}
|
|
495
|
-
],
|
|
496
|
-
"variable": [
|
|
497
|
-
{
|
|
498
|
-
"key": "url",
|
|
499
|
-
"value": "http://localhost:5000",
|
|
500
|
-
"type": "string"
|
|
501
|
-
}
|
|
502
|
-
]
|
|
503
|
-
}
|
|
504
|
-
```
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# API Requirements: Tenant Management Module
|
|
2
|
-
|
|
3
|
-
To make the `TenantsList` component dynamic and support full CRUD functionality along with current UI operations (filtering, searching, status updates), the following API endpoints and data structures are required.
|
|
4
|
-
|
|
5
|
-
## 1. Data Models
|
|
6
|
-
|
|
7
|
-
### **Tenant Object**
|
|
8
|
-
The core entity representing a tenant.
|
|
9
|
-
|
|
10
|
-
```json
|
|
11
|
-
{
|
|
12
|
-
"id": "uuid",
|
|
13
|
-
"name": "string",
|
|
14
|
-
"email": "string",
|
|
15
|
-
"phone": "string",
|
|
16
|
-
"profileImage": "string (url)",
|
|
17
|
-
"roomNumber": "string",
|
|
18
|
-
"bedId": "string (optional)",
|
|
19
|
-
"joinDate": "ISO8601 Date String",
|
|
20
|
-
"status": "enum('Active', 'Due Payment', 'Moved Out')",
|
|
21
|
-
"outstandingBalance": "number",
|
|
22
|
-
"lastPaymentDate": "ISO8601 Date String"
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## 2. API Endpoints
|
|
27
|
-
|
|
28
|
-
### **A. Tenant Management (CRUD)**
|
|
29
|
-
|
|
30
|
-
#### 1. **Fetch Tenants List**
|
|
31
|
-
- **Endpoint**: `GET /api/tenants`
|
|
32
|
-
- **Description**: Retrieves a paginated list of tenants with support for filtering and searching.
|
|
33
|
-
- **Query Parameters**:
|
|
34
|
-
- `page`: Page number (default: 1)
|
|
35
|
-
- `limit`: Items per page (default: 10)
|
|
36
|
-
- `search`: Search term (matches name, roomNumber, or phone)
|
|
37
|
-
- `status`: Filter by status (`Active`, `Due Payment`, `Moved Out`, or `All`)
|
|
38
|
-
- **Response**:
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"data": [ ...TenantObjects ],
|
|
42
|
-
"meta": {
|
|
43
|
-
"total": 50,
|
|
44
|
-
"page": 1,
|
|
45
|
-
"limit": 10
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
#### 2. **Get Single Tenant Details**
|
|
51
|
-
- **Endpoint**: `GET /api/tenants/:id`
|
|
52
|
-
- **Description**: Fetches detailed information for a specific tenant (useful for a future detail view).
|
|
53
|
-
|
|
54
|
-
#### 3. **Add New Tenant**
|
|
55
|
-
- **Endpoint**: `POST /api/tenants`
|
|
56
|
-
- **Description**: Onboards a new tenant.
|
|
57
|
-
- **Body**:
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"name": "John Doe",
|
|
61
|
-
"phone": "9876543210",
|
|
62
|
-
"roomNumber": "101",
|
|
63
|
-
"joinDate": "2023-01-01",
|
|
64
|
-
"initialPayment": 5000
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### 4. **Update Tenant Details**
|
|
69
|
-
- **Endpoint**: `PUT /api/tenants/:id`
|
|
70
|
-
- **Description**: Updates tenant information (e.g., room change, phone number update).
|
|
71
|
-
- **Body**: (Partial Tenant Object)
|
|
72
|
-
|
|
73
|
-
#### 5. **Delete/Archive Tenant**
|
|
74
|
-
- **Endpoint**: `DELETE /api/tenants/:id`
|
|
75
|
-
- **Description**: Soft deletes a tenant or marks them as 'Archived'.
|
|
76
|
-
|
|
77
|
-
### **B. Operational Actions**
|
|
78
|
-
|
|
79
|
-
#### 6. **Record Rent Payment (Collect Rent)**
|
|
80
|
-
- **Endpoint**: `POST /api/payments`
|
|
81
|
-
- **Description**: Triggered when the "Collect Rent" button is clicked. Records a payment and potentially updates the tenant's status from 'Due Payment' to 'Active'.
|
|
82
|
-
- **Body**:
|
|
83
|
-
```json
|
|
84
|
-
{
|
|
85
|
-
"tenantId": "uuid",
|
|
86
|
-
"amount": 5000,
|
|
87
|
-
"type": "Rent",
|
|
88
|
-
"date": "2023-10-01"
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
#### 7. **Move Out Tenant**
|
|
93
|
-
- **Endpoint**: `POST /api/tenants/:id/move-out`
|
|
94
|
-
- **Description**: Special action to mark a tenant as 'Moved Out' and free up the room/bed.
|
|
95
|
-
- **Body**:
|
|
96
|
-
```json
|
|
97
|
-
{
|
|
98
|
-
"moveOutDate": "2023-10-15"
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## 3. UI Integration Logic
|
|
103
|
-
|
|
104
|
-
- **Search Bar**: Debounce input and call `GET /api/tenants?search={query}`.
|
|
105
|
-
- **Filter Chips**: On click, call `GET /api/tenants?status={selectedStatus}`.
|
|
106
|
-
- **Infinite Scroll**: On reaching list end, increment `page` param and append results.
|
|
107
|
-
- **"Collect Rent" Button**:
|
|
108
|
-
1. Opens a modal to confirm amount.
|
|
109
|
-
2. Calls `POST /api/payments`.
|
|
110
|
-
3. On success, local state update: remove "Due Payment" status and "Make Payment" button from that card.
|