Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prestamo fix #23

Merged
merged 20 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ npm run dev
| Alejandra Coeto | | |
| Yaír Reyes | | |
| Leonardo Llanas | | |
| Gilberto Malagamba | [@GilMM27](https://github.com/GilMM27) | [email protected] |

# Proyect structure

Expand All @@ -85,3 +86,49 @@ npm run dev
└─ utils
```

# Testing websocket

First, on the root of this project run:
```bash
npm run dev
```
Then on vscode forward the port that is hosting the web page (commonly 3000) and change the visibility to public. Add the respective Endpoint URLs on aws WebSocket Routes, for example: https://something.devtunnels.ms/api/websocket/connect

Use https://piehost.com/websocket-tester and connect to the WebSocket link, for example: wss://something.execute-api.us-east-2.amazonaws.com/development/

Try sending a JSON such as *{ "data": "", "action": "getPrestamos","id": "RFID" }* and expect a response like *{"status":"Success","data":[]}*

If there are préstamos in the database then it will return an array like *{"status":"Success","data":[{"User":{"name":"Gilberto Malagamba Montejo"},"Item":{"name":"a"},"Celda":{"name":"d","column":0,"row":0},"id":"cm1zrg9l7000kes8epm8d74ya"}]}*

In the arduino code, we use the following function to send that message:

wsClient.sendResponse("", "getPrestamos", "RFID"); // Data Action Id

In the following table there are all the examples of actions

| Message | Response |
| --- | --- |
| { "data": "", "action": "getPrestamos", "id": "RFID" } | {"status":"Success","data":[{"User":{"name":"UserName"},"Item":{"name":"ItemName"},"Celda":{"name":"CeldaName","column":#,"row":#},"id":"Id"}]} |
| { "data": "", "action": "getIssuedPrestamos", "id": "RFID" } | {"status":"Success","data":[{"User":{"name":"UserName"},"Item":{"name":"ItemName"},"Celda":{"name":"CeldaName","column":#,"row":#},"id":"Id"}]} |
| { "data": "RFIDtoken,prestamoId", "action": "issuePrestamo", "id": "RFID" } | {"status":"Success","data":"Prestamo issued"} |
| { "data": "RFIDtoken,prestamoId", "action": "returnPrestamo", "id": "RFID" } | {"status":"Success","data":"Prestamo returned"}

# Testing database

Run a local instance of mysql or similar provider and add the route to url in the shema.prisma file. *Suggestion: Try using xampp.*

datasource db {
provider = "mysql"
url = "mysql://root:@localhost:3306/AlmacenLocal"
}

To open the database ui interface run:
```bash
npx prisma studio
```
To test a new schema.prisma kill *next dev* and *prisma studio* and run:
```bash
npx prisma migrate dev
npx prisma generate
```
21 changes: 21 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/styles/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "rbgs/components",
"utils": "rbgs/lib/utils",
"ui": "rbgs/components/ui",
"lib": "rbgs/lib",
"hooks": "rbgs/hooks"
},
"iconLibrary": "lucide"
}
Loading