diff --git a/README.md b/README.md index 66ab45e..1dd5de5 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,12 @@ cd ./latosa-frontend deno install ``` +then use the init to developp + +```bash +./init.sh +``` + ## Run To run the frontend part: @@ -20,7 +26,17 @@ cd ./latosa-frontend/ deno task dev ``` -It should launch properly, go at http://localhost:3000 +It should launch properly, go at http://localhost:8000 + +Use this to sync with backend + +```bash +docker compose up -d --build +``` + +## deploy + +For deployement, it can be found at http://localhost:3000 ## Committing diff --git a/backend/go.mod b/backend/go.mod index dfc90c4..857f398 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -3,6 +3,7 @@ module fr.latosa-escrima go 1.23.4 require ( + github.com/google/uuid v1.6.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect diff --git a/backend/go.sum b/backend/go.sum index eeda9ee..bfd2319 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -1,3 +1,5 @@ +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= diff --git a/backend/schemas.go b/backend/schemas.go new file mode 100644 index 0000000..6c61ba2 --- /dev/null +++ b/backend/schemas.go @@ -0,0 +1,75 @@ +package main + +import ( + "time" + "github.com/uptrace/bun" + "github.com/google/uuid" +) + +type Role string + +const ( + AdminRole Role = "admin" + UserRole Role = "user" +) + +type User struct { + bun.BaseModel `bun:"table:users"` + + ID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()"` + FirstName string `bun:"firstname,notnull"` + LastName string `bun:"lastname,notnull"` + Email string `bun:"email,unique,notnull"` + Phone string `bun:"phone,notnull"` + Role Role `bun:"role,notnull,default:'user'"` + CreatedAt time.Time `bun:"created_at,default:current_timestamp"` + UpdatedAt time.Time `bun:"updated_at,default:current_timestamp"` +} + +type Event struct { + bun.BaseModel `bun:"table:events"` + + EventID uuid.UUID `bun:"type:uuid,pk"` + CreationDate time.Time `bun:"creation_date,notnull,default:current_timestamp"` + ScheduleStart time.Time `bun:"schedule_start,notnull"` + ScheduleEnd time.Time `bun:"schedule_end,notnull"` + Status string `bun:"status,notnull"` +} + +type EventsToUsers struct { + bun.BaseModel `bun:"table:events_to_users"` + + EventID uuid.UUID `bun:"type:uuid,notnull"` + UserID uuid.UUID `bun:"type:uuid,notnull"` + + Event *Event `bun:"rel:belongs_to,join:event_id=event_id"` + User *User `bun:"rel:belongs_to,join:user_id=user_id"` + + PrimaryKey struct { + EventID uuid.UUID `bun:"pk"` + UserID uuid.UUID `bun:"pk"` + } +} + +type Blog struct { + bun.BaseModel `bun:"table:blogs"` + + UUID uuid.UUID `bun:"type:uuid,pk"` + Slug string `bun:"slug,unique,notnull"` + Content string `bun:"content,notnull"` + Label string `bun:"label"` + AuthorID uuid.UUID `bun:"author,notnull"` + Published time.Time `bun:"published,default:current_timestamp"` + Summary string `bun:"summary"` + Image string `bun:"image"` + Href string `bun:"href"` + + Author *User `bun:"rel:belongs_to,join:author=author_id"` +} + +type WebsiteSettings struct { + bun.BaseModel `bun:"table:website_settings"` + + ID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()"` + AutoAcceptDemand bool `bun:"auto_accept_demand,default:false"` +} diff --git a/database/mock-up.md b/database/mock-up.md new file mode 100644 index 0000000..f28cd11 --- /dev/null +++ b/database/mock-up.md @@ -0,0 +1,25 @@ +Latosa-escrima-db +- user (cedric job) +- planning_events + - event_id uuid PK, + - creation_date id, + - schedule_start date, + - schedule_end end, + - status { 'Canceled', 'Active', '' } + CHECK schedule_start < schedule_end +- events_to_users + - event_id uuid references planning_events(event_id), + - user_id uuid references user(user_id) +- blog + uuid: slug PK, + slug: string unique, + content: string, + label: string, + author: uuid references user_id, + published: string, + summary: string, + image: string, + href: string + +- website settings + - auto accept demand ? true/false diff --git a/database/schemas/blog.sql b/database/schemas/blog.sql new file mode 100644 index 0000000..3833c36 --- /dev/null +++ b/database/schemas/blog.sql @@ -0,0 +1,12 @@ +CREATE TABLE blogs ( + uuid UUID PRIMARY KEY, -- The blog primary key + slug VARCHAR(255) UNIQUE NOT NULL, -- Slug must be unique and non-null + content TEXT NOT NULL, -- Content cannot be null + label VARCHAR(100), -- Optional label + author UUID REFERENCES users(user_id) ON DELETE SET NULL, -- Foreign key to user with cascading null for author deletion + published TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Automatically set the published time + summary VARCHAR(500), -- A brief summary of the blog + image VARCHAR(255), -- URL for the blog image + href VARCHAR(255), -- Link to the blog if external + CONSTRAINT check_slug_length CHECK (length(slug) > 0) -- Ensure slug is not empty +); diff --git a/database/schemas/events.sql b/database/schemas/events.sql new file mode 100644 index 0000000..8441c57 --- /dev/null +++ b/database/schemas/events.sql @@ -0,0 +1,11 @@ +CREATE EXTENSION IF NOT EXISTS pgcrypto; +CREATE TYPE Event_status as ENUM('Canceled', 'Active') + +CREATE TABLE events ( + event_id UUID PRIMARY KEY, -- Use UUID as the primary key + creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Automatically capture the creation date + schedule_start DATE NOT NULL, + schedule_end DATE NOT NULL, + status Event_status DEFAULT 'Active', -- enum-like constraint for status + CHECK (schedule_start < schedule_end) -- Ensure the start date is before the end date +); diff --git a/database/schemas/events_to_user.sql b/database/schemas/events_to_user.sql new file mode 100644 index 0000000..ed56738 --- /dev/null +++ b/database/schemas/events_to_user.sql @@ -0,0 +1,6 @@ + +CREATE TABLE events_to_users ( + event_id UUID REFERENCES events(event_id) ON DELETE CASCADE, -- Foreign key with cascading delete for referential integrity + user_id UUID REFERENCES users(user_id) ON DELETE CASCADE, -- Foreign key with cascading delete + PRIMARY KEY (event_id, user_id) -- Ensure uniqueness of event-user pairs +); diff --git a/database/schemas/web_settings.sql b/database/schemas/web_settings.sql new file mode 100644 index 0000000..92a6a3b --- /dev/null +++ b/database/schemas/web_settings.sql @@ -0,0 +1,4 @@ +CREATE TABLE website_settings ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Auto-generate UUID for settings table + auto_accept_demand BOOLEAN DEFAULT FALSE -- Automatically accept demands by default is false +); diff --git a/frontend/app/(main)/about/page.tsx b/frontend/app/(main)/about/page.tsx new file mode 100644 index 0000000..85f4e66 --- /dev/null +++ b/frontend/app/(main)/about/page.tsx @@ -0,0 +1,16 @@ +"use server" + +export default async function About() { + return ( +
+
+ About us + will : + +explain what we + +pricing + + +plannign for what will come next +
+
+ ) +} diff --git a/frontend/components/nav-bar.tsx b/frontend/components/nav-bar.tsx index fa91969..99a0400 100644 --- a/frontend/components/nav-bar.tsx +++ b/frontend/components/nav-bar.tsx @@ -69,7 +69,7 @@ const subMenuItemsTwo = [ const Navbar = () => { return (
-
+