diff --git a/backend/db/main.go b/backend/db/main.go
index ff130cd..f22f25f 100644
--- a/backend/db/main.go
+++ b/backend/db/main.go
@@ -27,10 +27,10 @@ func InitDB(driver string, connStr string) error {
);
CREATE TABLE IF NOT EXISTS cards (
id INTEGER PRIMARY KEY AUTOINCREMENT,
- list_id INTEGER,
+ project_id INTEGER,
title TEXT,
content TEXT,
- FOREIGN KEY(list_id) REFERENCES lists(id)
+ FOREIGN KEY(project_id) REFERENCES projects(id)
);
`)
if err != nil {
diff --git a/backend/handlers/cards.go b/backend/handlers/cards.go
index 925d59a..dce7bfd 100644
--- a/backend/handlers/cards.go
+++ b/backend/handlers/cards.go
@@ -1,6 +1,7 @@
package handlers
import (
+ "fmt"
"strconv"
"git.bhasher.com/bhasher/focus/backend/db"
@@ -16,24 +17,24 @@ func CreateCards(c *fiber.Ctx) error {
id, err := db.CreateCard(card)
if err != nil {
- return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot create card"})
+ return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot create card", "trace": fmt.Sprint(err)})
}
return c.Status(fiber.StatusCreated).JSON(fiber.Map{"id": id})
}
func GetAllCardsOf(c *fiber.Ctx) error {
- listID, err := strconv.Atoi(c.Params("project_id"))
+ projectID, err := strconv.Atoi(c.Params("project_id"))
if err != nil {
- return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid project_id"})
+ return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"status": "error", "error": "Invalid project_id"})
}
- lists, err := db.GetAllListsOf(listID)
+ projects, err := db.GetAllCardsOf(projectID)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot retrieve cards"})
}
- return c.JSON(lists)
+ return c.JSON(fiber.Map{"status": "ok", "data": projects})
}
func GetCard(c *fiber.Ctx) error {
diff --git a/backend/handlers/projects.go b/backend/handlers/projects.go
index 9970163..7455310 100644
--- a/backend/handlers/projects.go
+++ b/backend/handlers/projects.go
@@ -1,8 +1,6 @@
package handlers
import (
- "fmt"
-
"git.bhasher.com/bhasher/focus/backend/db"
"git.bhasher.com/bhasher/focus/backend/types"
"github.com/gofiber/fiber/v2"
@@ -14,8 +12,6 @@ func GetAllProjects(c *fiber.Ctx) error {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot retrieve projects"})
}
- fmt.Println(projects)
-
return c.JSON(projects)
}
diff --git a/backend/main.go b/backend/main.go
index ff1410e..bd523e6 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -30,17 +30,23 @@ func main() {
AllowHeaders: "Origin, Content-Type, Accept",
}))
+ app.Post("/api/project", handlers.CreateProject)
app.Get("/api/projects", handlers.GetAllProjects)
app.Get("/api/project/:id", handlers.GetProject)
- app.Post("/api/project", handlers.CreateProject)
app.Put("/api/project/:id", handlers.UpdateProject)
app.Delete("/api/project/:id", handlers.DeleteProject)
app.Post("/api/list", handlers.CreateList)
- app.Get("/api/lists/:board_id", handlers.GetAllListsOf)
+ app.Get("/api/lists/:project_id", handlers.GetAllListsOf)
app.Get("/api/list/:id", handlers.GetList)
app.Delete("/api/list/:id", handlers.DeleteList)
app.Put("/api/list/:id", handlers.UpdateList)
+ app.Post("/api/card", handlers.CreateCards)
+ app.Get("/api/cards/:project_id", handlers.GetAllCardsOf)
+ app.Get("/api/card/:id", handlers.GetCard)
+ app.Delete("/api/card/:id", handlers.DeleteCard)
+ app.Put("/api/card/:id", handlers.UpdateCard)
+
log.Fatal(app.Listen(fmt.Sprintf(":%v", port)))
}
diff --git a/frontend/src/components/card.svelte b/frontend/src/components/card.svelte
new file mode 100644
index 0000000..1067964
--- /dev/null
+++ b/frontend/src/components/card.svelte
@@ -0,0 +1,25 @@
+
+
+
Invalid number
-{:else} -Hello on dashboard {projectId}!
+