feat: redirect from loaner check in to main page
This commit is contained in:
1 parent
bab47ac4af
commit
ddfac3dc2e
1 file changed
+6
-12
@@ -298,6 +298,8 @@ pub fn LoanerBorrowForm() -> impl IntoView {
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn LoanerReturnForm() -> impl IntoView {
|
pub fn LoanerReturnForm() -> impl IntoView {
|
||||||
|
let navigate = use_navigate();
|
||||||
|
|
||||||
// Register server actions
|
// Register server actions
|
||||||
let check_in_action = ServerAction::<CheckInLoaner>::new();
|
let check_in_action = ServerAction::<CheckInLoaner>::new();
|
||||||
|
|
||||||
@@ -313,26 +315,18 @@ pub fn LoanerReturnForm() -> impl IntoView {
|
|||||||
|
|
||||||
let dialog_ref = NodeRef::<Dialog>::new();
|
let dialog_ref = NodeRef::<Dialog>::new();
|
||||||
let chosen_student = RwSignal::new(None::<LoanerReturnOutput>);
|
let chosen_student = RwSignal::new(None::<LoanerReturnOutput>);
|
||||||
let dialog_disabled = RwSignal::new(false);
|
let dialog_disabled = Signal::derive(move || check_in_action.pending().get());
|
||||||
|
|
||||||
// Create an effect to run after check-in - refreshes the list with another scan request.
|
// Create an effect to run after check-in - refreshes the list with another scan request.
|
||||||
// This could be beneficial if we ever decided to make multiple loaner kiosks (think SAT days)
|
// This could be beneficial if we ever decided to make multiple loaner kiosks (think SAT days)
|
||||||
Effect::new(move || {
|
Effect::new(move || {
|
||||||
if let Some(Ok(_)) = check_in_action.value().get() {
|
if let Some(Ok(_)) = check_in_action.value().get() {
|
||||||
// Check the local loaner list and remove the indicated student from it.
|
// Return to the main page.
|
||||||
return_list_refresh.update(|n| *n += 1);
|
|
||||||
if let Some(dialog) = dialog_ref.get() {
|
if let Some(dialog) = dialog_ref.get() {
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
}
|
navigate("/loaners", Default::default());
|
||||||
});
|
check_in_action.clear();
|
||||||
|
|
||||||
// We can't use a Memo in our custom components for the disabled signal.
|
|
||||||
Effect::new(move || {
|
|
||||||
if check_in_action.pending().get() {
|
|
||||||
dialog_disabled.set(true);
|
|
||||||
} else {
|
|
||||||
dialog_disabled.set(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user