diff --git a/serve.py b/serve.py index d97bd3c..313fe6e 100644 --- a/serve.py +++ b/serve.py @@ -19,6 +19,13 @@ def criterias(): data = json.load(file) return data +@app.route('/params') +def params(): + print("get params") + + with open('data.csv', 'r') as file: + content = file.read() + return content if __name__ == '__main__': app.run(port=1984) diff --git a/src/main.rs b/src/main.rs index 5f80938..1719553 100644 --- a/src/main.rs +++ b/src/main.rs @@ -145,14 +145,22 @@ fn App() -> Html {
{ "my job" }
{ "How it maters" }
- { for (*criterias_state_5).clone().into_iter().map(|criteria: Criteria| { - let param = (*parameter_state).clone().into_iter().find(|param| param.id == criteria.id).unwrap(); - html! { -
- -
+ if (*criterias_state_5).len() == (*parameter_state).len() { +
+ { + for (*criterias_state_5).clone().into_iter().map(|criteria: Criteria| { + let param = (*parameter_state).clone().into_iter().find(|param| param.id == criteria.id).unwrap(); + html! { +
+ +
+ } + }) } - })} +
+ } else { +
{"loading or data mismatch somewhere..."}
+ } } diff --git a/src/salary_param.rs b/src/salary_param.rs index e3e56a6..7b14542 100644 --- a/src/salary_param.rs +++ b/src/salary_param.rs @@ -1,4 +1,8 @@ -#[derive(Copy, Clone, Debug)] +use serde::Deserialize; + +const _PARAM_DATA_URL: &str = "http://localhost:1984/params"; + +#[derive(Clone, Debug, Deserialize)] pub struct SalaryParam { pub id: &'static str, pub value: i8, diff --git a/src/slider.rs b/src/slider.rs index 249e808..2684609 100644 --- a/src/slider.rs +++ b/src/slider.rs @@ -30,6 +30,7 @@ pub fn Slider(props: &Props) -> Html { let coef_value = (*coef_value_handle).clone(); let salary_param = props.salary_param.clone(); + let salary_param_2 = props.salary_param.clone(); let criteria = props.criteria.clone(); let cb_value_handle = props.on_parameter_slide.clone(); @@ -55,7 +56,7 @@ pub fn Slider(props: &Props) -> Html { if let Some(input) = input { coef_value_handle.set(input.value()); cb_coef_handle.emit( SliderCoefMessage { - id: salary_param.id.to_string(), + id: salary_param_2.id.to_string(), coef: input.value().parse::().expect("expected number") }); }