diff --git a/.gitignore b/.gitignore index c6f9a44..736c5c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode/settings.json +project1.zip diff --git a/README.md b/README.md index bddffcb..e06ee9e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Users can create new shopping lists, add items to them, and mark items as collected. The application displays a list of all active shopping lists, as well as a page for each individual shopping list showing all its items. -The application is deployed at https://shopper.fly.dev/ using +The application is deployed at https://shoptool.fly.dev/ using [Fly.io](https://fly.io/). Feel free to try it out! The web application is built using Deno, a JavaScript/TypeScript runtime with diff --git a/shopping-lists/controllers/mainController.js b/shopping-lists/controllers/mainController.js index ec7e8ca..feb5db2 100644 --- a/shopping-lists/controllers/mainController.js +++ b/shopping-lists/controllers/mainController.js @@ -7,10 +7,15 @@ const responseDetails = { const showMain = async (_request) => { const data = { + flag: true, listCount: await mainService.checkList(), itemCount: await mainService.checkItem(), }; + if (data.listCount > 0) { + data.flag = false; + } + return new Response(await renderFile("main.eta", data), responseDetails); }; diff --git a/shopping-lists/fly.toml b/shopping-lists/fly.toml index 4755085..5636344 100644 --- a/shopping-lists/fly.toml +++ b/shopping-lists/fly.toml @@ -1,6 +1,6 @@ -# fly.toml file generated for shopper on 2022-12-27T19:33:40+02:00 +# fly.toml file generated for shoptool on 2022-12-28T19:38:57+02:00 -app = "shopper" +app = "shoptool" kill_signal = "SIGINT" kill_timeout = 5 processes = [] diff --git a/shopping-lists/services/mainService.js b/shopping-lists/services/mainService.js index 0584a98..da274be 100644 --- a/shopping-lists/services/mainService.js +++ b/shopping-lists/services/mainService.js @@ -2,14 +2,20 @@ import { executeQuery } from "../database/database.js"; const checkList = async () => { const result = await executeQuery("SELECT COUNT(*) FROM shopping_lists;"); - return result.rows[0].count; + if (result.rows && result.rows.length > 0) { + return result.rows[0].count; + } + return 0; }; const checkItem = async () => { const result = await executeQuery( "SELECT COUNT(*) FROM shopping_list_items;" ); - return result.rows[0].count; + if (result.rows && result.rows.length > 0) { + return result.rows[0].count; + } + return 0; }; export { checkList, checkItem }; diff --git a/shopping-lists/views/main.eta b/shopping-lists/views/main.eta index 1e5dabd..9e52804 100644 --- a/shopping-lists/views/main.eta +++ b/shopping-lists/views/main.eta @@ -2,18 +2,11 @@