Skip to content

Commit 27c6a63

Browse files
committed
Refactor search component to utilize app state for search term and last n number retrieval
1 parent 47eae45 commit 27c6a63

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

dashboard/components/search.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
"""
44
from fasthtml.common import *
55
from monsterui.all import *
6-
from dashboard.state import get_state
6+
from dashboard.app import app
77

88
def create_search_form(batch_name: str) -> Form:
99
"""Create the search form."""
10-
state = get_state()
11-
current_search = state.search_term.get(batch_name, "")
10+
current_search = app.state.search_term.get(batch_name, "")
1211

1312
return Form(
1413
Input(
@@ -32,13 +31,12 @@ def create_search_form(batch_name: str) -> Form:
3231

3332
def create_last_n_form(batch_name: str) -> Form:
3433
"""Create the last n number form."""
35-
state = get_state()
3634
return Form(
3735
DivLAligned(
3836
Input(
3937
type="text",
4038
name="last_n",
41-
value=state.last_n.get(batch_name, "30n"),
39+
value=app.state.last_n.get(batch_name, "30n"),
4240
pattern=r"^\d+[nNhmd]$",
4341
title="Use format: 30n (observations), 24h (hours), 45m (minutes), 7d (days)",
4442
cls="uk-input uk-form-small rounded-md border-gray-200 w-full md:w-[110px]",

0 commit comments

Comments
 (0)