wip(feat): contact groups
Some checks failed
/ integration-test--firefox (push) Failing after 3m11s

This commit is contained in:
Robert Perce 2026-01-16 23:19:40 -06:00
parent e3e77cbae3
commit 1f05189ec6
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,4 @@
create table if not exists groups (
contact_id number not null references contacts(id),
name text not null
);

View file

@ -28,6 +28,13 @@ pub struct Address {
pub value: String, pub value: String,
} }
#[derive(serde::Serialize, Debug)]
pub struct Group {
pub contact_id: DbId,
pub name: String,
}
pub fn router() -> Router<AppState> { pub fn router() -> Router<AppState> {
Router::new() Router::new()
.route("/contact/new", post(self::post::contact)) .route("/contact/new", post(self::post::contact))
@ -94,6 +101,13 @@ mod get {
.fetch_all(pool) .fetch_all(pool)
.await?; .await?;
let groups: Vec<Group> = sqlx::query_as!(
Group,
"select * from groups where contact_id = $1",
contact_id)
.fetch_all(pool)
.await?;
let text_body: Option<String> = let text_body: Option<String> =
sqlx::query!("select text_body from contacts where id = $1", contact_id) sqlx::query!("select text_body from contacts where id = $1", contact_id)
.fetch_one(pool) .fetch_one(pool)
@ -153,6 +167,15 @@ mod get {
} }
} }
} }
@if groups.len() > 0 {
label { "in groups" }
#groups {
@for group in groups {
.group { (group.name) }
}
}
}
} }