Added basic create content

This commit is contained in:
xeovalyte 2024-12-30 09:56:59 +01:00
parent 924b98f7e6
commit d04340fcfb
Signed by: xeovalyte
SSH Key Fingerprint: SHA256:kSQDrQDmKzljJzfGYcd3m9RqHi4h8rSwkZ3sQ9kBURo
8 changed files with 263 additions and 210 deletions

386
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ edition = "2021"
serde = { version = "1.0", features = ["derive"] }
dioxus = { version = "0.6", features = ["fullstack", "router"] }
wasm-bindgen = "=0.2.97"
dioxus-cli-config = { version = "0.6", optional = true }
web-sys = { version = "0.3", features = ["Window", "Location"] }

View File

@ -3,10 +3,10 @@
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1732585607,
"lastModified": 1735241861,
"owner": "cachix",
"repo": "devenv",
"rev": "a520f05c40ebecaf5e17064b27e28ba8e70c49fb",
"rev": "991abff153b995192bf36655394246fc97ba8627",
"type": "github"
},
"original": {
@ -24,10 +24,10 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1732602776,
"lastModified": 1735367591,
"owner": "nix-community",
"repo": "fenix",
"rev": "e0d44b70dcd2b98dd77857b4c5c7b1dc6b1ef56d",
"rev": "3743208cafd7bc3c150f0c77c25ef7430e9c0de2",
"type": "github"
},
"original": {
@ -39,10 +39,10 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
@ -73,10 +73,10 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1731797254,
"lastModified": 1735286948,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
"rev": "31ac92f9628682b294026f0860e14587a09ffb4b",
"type": "github"
},
"original": {
@ -88,10 +88,10 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1731797254,
"lastModified": 1735286948,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
"rev": "31ac92f9628682b294026f0860e14587a09ffb4b",
"type": "github"
},
"original": {
@ -111,10 +111,10 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1732021966,
"lastModified": 1734797603,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "3308484d1a443fc5bc92012435d79e80458fe43c",
"rev": "f0f0dc4920a903c3e08f5bdb9246bb572fcae498",
"type": "github"
},
"original": {
@ -134,10 +134,10 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1732562640,
"lastModified": 1735338518,
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "157c7d01149e9be7179c5724b89d8d073e923bd8",
"rev": "d3bb15ecec7c1386767c45776fab497e8a22a30f",
"type": "github"
},
"original": {

View File

@ -6,6 +6,7 @@ use dioxus::prelude::*;
mod content;
mod targets;
mod verify;
#[derive(PartialEq)]
enum Steps {
@ -44,6 +45,7 @@ impl Default for Form {
pub fn MessagesCreatePage() -> Element {
let mut step = use_signal(|| Steps::Message);
let form = Form::default();
let mut target_amount: Signal<usize> = use_signal(|| 0);
let submit_proposal = move |_| async move {
let targets = (form.targets)();
@ -55,7 +57,7 @@ pub fn MessagesCreatePage() -> Element {
)
.await
{
tracing::info!("{}", amount);
target_amount.set(amount);
step.set(Steps::Verify);
} else {
tracing::info!("Error occured")
@ -103,6 +105,15 @@ pub fn MessagesCreatePage() -> Element {
onsubmit: submit_proposal,
}
}
div {
class: if let Steps::Verify = *step.read() { "" } else { "hidden" },
verify::Verify {
step: step,
title: form.title,
body: form.body,
amount: target_amount,
}
}
}
}
}

View File

@ -13,6 +13,7 @@ pub fn Content(step: Signal<Steps>, title: Signal<String>, body: Signal<String>)
form {
class: "flex flex-col w-full gap-y-5",
onsubmit: submit,
h2 { class: "text-xl", "Bericht inhoud" },
label {
class: "form-control w-full",
div {

View File

@ -24,6 +24,7 @@ pub fn Targets(
form {
class: "w-full",
onsubmit: move |event| onsubmit.call(event),
h2 { class: "text-xl", "Leden selecteren" },
label {
class: "form-control w-full",
div {
@ -106,8 +107,6 @@ fn TargetValueInput(
let groups = use_context::<crate::Groups>();
let value = use_memo(move || targets.read().get(&id).unwrap().value.clone());
tracing::info!("Input rendered");
rsx! {
match target_kind() {
TargetKind::Group => {

View File

@ -0,0 +1,38 @@
use super::Steps;
use dioxus::prelude::*;
#[component]
pub fn Verify(
step: Signal<Steps>,
title: Signal<String>,
body: Signal<String>,
amount: Signal<usize>,
) -> Element {
let submit = move |_event: FormEvent| {
step.set(Steps::Targets);
};
rsx! {
form {
class: "flex flex-col w-full gap-y-5",
onsubmit: submit,
h2 { class: "text-xl", "Stuur onderstaand bericht naar {amount} leden" },
div {
class: "card bg-base-200 w-full",
div {
class: "card-body",
h2 { class: "card-title", "{title}" }
p { "{body}" }
}
},
div {
class: "w-full flex gap-x-3 justify-end",
input {
r#type: "submit",
class: "btn btn-primary",
value: "Volgende",
}
}
}
}
}

View File

@ -72,6 +72,7 @@ async fn apply_queries() -> surrealdb::Result<()> {
"
DEFINE TABLE OVERWRITE member SCHEMAFULL;
DEFINE FIELD id ON TABLE member TYPE record;
DEFINE FIELD name ON TABLE member TYPE object;
DEFINE FIELD name.first ON TABLE member TYPE string;
DEFINE FIELD name.full ON TABLE member TYPE string;
@ -80,6 +81,8 @@ async fn apply_queries() -> surrealdb::Result<()> {
DEFINE FIELD diploma ON TABLE member TYPE option<string>;
DEFINE FIELD hours ON TABLE member TYPE set<string>;
DEFINE FIELD groups ON TABLE member TYPE set<string>;
DEFINE INDEX memberIdIndex ON TABLE member COLUMNS id;
",
)
.await?;