completed 06 ticket management
Some checks failed
CI / build (push) Failing after 1m16s
CI / gravity (push) Has been skipped
CI / is_fresh (push) Successful in 26s
CI / formatter (push) Failing after 17s

This commit is contained in:
2025-04-07 12:12:47 +05:30
parent 199b57aad8
commit 9bc063a05b
5 changed files with 65 additions and 13 deletions

View File

@@ -11,6 +11,7 @@ use ticket_fields::{TicketDescription, TicketTitle};
#[derive(Clone)]
pub struct TicketStore {
tickets: Vec<Ticket>,
total: usize,
}
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -41,11 +42,25 @@ impl TicketStore {
pub fn new() -> Self {
Self {
tickets: Vec::new(),
total: 0,
}
}
pub fn add_ticket(&mut self, ticket: Ticket) {
self.tickets.push(ticket);
pub fn add_ticket(&mut self, ticket: TicketDraft) -> TicketId {
let newID = TicketId(self.total as u64 + 1);
let tick: Ticket = Ticket {
title: ticket.title,
description: ticket.description,
status: Status::ToDo,
id: newID,
};
self.tickets.push(tick);
self.total += 1;
return newID;
}
pub fn get(&self, id: TicketId) -> Option<&Ticket> {
return Some(&self.tickets[(id.0 - 1) as usize]);
}
}