Compare commits

...

2 Commits

Author SHA1 Message Date
f6350b1d7f more link fixes. 2025-04-04 11:12:54 +01:00
292db01011 Fix issue creating syndicates, accepted should not be set when creating. 2025-04-04 11:10:15 +01:00
5 changed files with 7 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ func CreateSyndicateHandler(db *sql.DB) http.HandlerFunc {
helpers.SetFlash(w, r, "Syndicate created successfully")
}
http.Redirect(w, r, "/account/syndicates", http.StatusSeeOther)
http.Redirect(w, r, "/syndicate", http.StatusSeeOther)
default:
helpers.RenderError(w, r, http.StatusMethodNotAllowed)
}

View File

@@ -78,7 +78,7 @@ func AcceptInviteHandler(db *sql.DB) http.HandlerFunc {
} else {
helpers.SetFlash(w, r, "You have joined the syndicate")
}
http.Redirect(w, r, "/syndicates", http.StatusSeeOther)
http.Redirect(w, r, "/syndicate", http.StatusSeeOther)
}
}

View File

@@ -192,7 +192,7 @@ CREATE TABLE IF NOT EXISTS syndicate_members (
syndicate_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
role TEXT DEFAULT 'member', -- owner, manager, member
status TEXT DEFAULT 'active', -- pending, accepted, kicked
status TEXT DEFAULT 'active',
joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (syndicate_id) REFERENCES syndicates(id),
FOREIGN KEY (user_id) REFERENCES users(id)
@@ -204,7 +204,7 @@ CREATE TABLE IF NOT EXISTS syndicate_invites (
syndicate_id INTEGER NOT NULL,
invited_user_id INTEGER NOT NULL,
sent_by_user_id INTEGER NOT NULL,
status TEXT DEFAULT 'pending', -- 'pending', 'accepted', 'declined'
status TEXT DEFAULT 'pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(syndicate_id) REFERENCES syndicates(id),
FOREIGN KEY(invited_user_id) REFERENCES users(id)

View File

@@ -215,8 +215,8 @@ func CreateSyndicate(db *sql.DB, ownerID int, name, description string) (int64,
}
_, err = tx.Exec(`
INSERT INTO syndicate_members (syndicate_id, user_id, accepted)
VALUES (?, ?, 1)
INSERT INTO syndicate_members (syndicate_id, user_id, role, joined_at)
VALUES (?, ?, 'manager', CURRENT_TIMESTAMP)
`, syndicateID, ownerID)
if err != nil {
return 0, fmt.Errorf("failed to add owner as member: %w", err)

View File

@@ -20,7 +20,7 @@
</div>
<button type="submit" class="btn btn-primary">Create</button>
<a href="/syndicates" class="btn btn-secondary">Cancel</a>
<a href="/syndicate" class="btn btn-secondary">Cancel</a>
</form>
</div>
{{ end }}