pub struct TicketByID {
_marker: PhantomData<()>,
function_component: FunctionComponent<Self>,
}Expand description
A component for displaying, updating, and deleting a single ticket by its ID.
This component fetches a specific ticket’s details from the backend based on the
id provided in its TicketProps. It allows administrators to update the ticket’s
status and delete the ticket.
§Props
id: Thei32ID of the ticket to fetch and display.
§State
Uses use_state hooks to manage:
ticket: The fetchedTicketdata, if available.error: Any error message encountered during API calls.loading: A boolean indicating if data is currently being fetched.status: The selected status for updating the ticket.deleting: A boolean indicating if a delete operation is in progress.delete_error: Any error message from a delete operation.
§Functionality
- Data Fetching: On component mount or
idchange, fetches ticket data from/api/tickets/:id. - Status Update: Provides a dropdown to change the ticket’s status. Submitting the
form sends a PATCH request to
/api/tickets/:idwith aTicketUpdateSchemepayload. - Ticket Deletion: Includes a “Delete” button that, after user confirmation,
sends a DELETE request to
/api/tickets/:id. On success, clears the ticket from display. - Error Handling: Displays error messages for network issues, API errors, or parsing failures.
- Date Formatting: Displays the ticket creation date formatted to
Europe/Berlintimezone.
§Example
html! {
<TicketByID id={123} />
}Fields§
§_marker: PhantomData<()>§function_component: FunctionComponent<Self>Trait Implementations§
Source§impl BaseComponent for TicketByIDwhere
Self: 'static,
impl BaseComponent for TicketByIDwhere
Self: 'static,
Source§type Properties = TicketProps
type Properties = TicketProps
The Component’s Properties.
Source§fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
Updates component’s internal state.
Source§fn changed(
&mut self,
_ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, _ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Source§fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
Notified after a layout is rendered.
Source§fn prepare_state(&self) -> Option<String>
fn prepare_state(&self) -> Option<String>
Prepares the server-side state.
Source§impl Debug for TicketByID
impl Debug for TicketByID
Source§impl FunctionProvider for TicketByID
impl FunctionProvider for TicketByID
Source§type Properties = TicketProps
type Properties = TicketProps
Properties for the Function Component.
Auto Trait Implementations§
impl !Freeze for TicketByID
impl !RefUnwindSafe for TicketByID
impl !Send for TicketByID
impl !Sync for TicketByID
impl Unpin for TicketByID
impl !UnwindSafe for TicketByID
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.