Skip to content

client(feat): add deadline field to ticket management with input and …#10

Open
xowin wants to merge 2 commits intodevfrom
ticket-deadline
Open

client(feat): add deadline field to ticket management with input and …#10
xowin wants to merge 2 commits intodevfrom
ticket-deadline

Conversation

@xowin
Copy link
Collaborator

@xowin xowin commented Oct 8, 2025

This pull request adds support for a "deadline" field to tickets across both the frontend and backend. Users can now set, edit, and view deadlines for tickets, and the UI will display deadlines and highlight overdue tickets. The backend has been updated to store and handle the new deadline field, including parsing and saving it correctly.

Frontend changes:

Ticket creation, editing, and viewing:

  • Added a "deadline" input to the ticket creation (ticket-create.tsx) and edit (ticket-edit.tsx) forms, storing the value as a date string in the form state. [1] [2] [3] [4]
  • Updated the ticket detail view (ticket-detail.tsx) to display the deadline, formatted as a local date, and show an "Overdue" label if the deadline has passed. [1] [2] [3]
  • Updated the tickets table (tickets-table.tsx) to include a deadline column, displaying the formatted deadline and an "Overdue" indicator for past deadlines.

Backend changes:

Ticket model and persistence:

  • Added a Deadline field of type time.Time to the Ticket struct and ensured it is handled in BSON unmarshalling. [1] [2] [3]
  • Updated the ticket update logic to parse and store the deadline field from incoming updates, handling RFC3339 date strings and errors gracefully.…display

@vercel
Copy link

vercel bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nestqueue Error Error Oct 9, 2025 11:48pm
nestqueue-mmc4 Error Error Oct 9, 2025 11:48pm

@xowin xowin requested review from Copilot and villaleo October 8, 2025 23:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive deadline support to the ticket management system, allowing users to set, edit, and view deadlines for tickets with visual indicators for overdue items.

  • Added deadline field to the backend Ticket model with proper BSON handling and RFC3339 parsing
  • Implemented deadline input fields in ticket creation and editing forms
  • Enhanced ticket views to display deadlines with overdue indicators

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/internal/models/ticket.go Added Deadline field to Ticket struct and BSON unmarshalling
server/internal/storage/storage.go Added deadline parsing and storage logic for ticket updates
client/components/tickets/ticket-create.tsx Added deadline input field to ticket creation form
client/components/tickets/ticket-edit.tsx Added deadline input field and initialization logic to edit form
client/components/tickets/ticket-detail.tsx Added deadline display with overdue indicator in ticket details
client/components/tickets/tickets-table.tsx Added deadline column with overdue highlighting to tickets table

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vercel vercel bot temporarily deployed to Preview – nestqueue October 9, 2025 23:47 Inactive
@vercel vercel bot temporarily deployed to Preview – nestqueue-mmc4 October 9, 2025 23:48 Inactive
Copy link
Contributor

@villaleo villaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, nice job on adding the deadline. However, there is room for improvement in your code.

Please make sure to keep changes in PRs targeted to a single feature/fix.

createdBy: "techsquad@digitalnest.org",
site: "Watsonville",
category: "Hardware",
deadline: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deadline should be the zero date value instead of a date string. The zero date value in JavaScript is:

new Date(0)

However, this will introduce a bug since JavaScript and Go have different zero values for time/date objects. More on this later (in storage.go).

const { addToast } = useToast();
const { mutate: createTicket } = useCreateTicket();
const [formData, setFormData] = useState<Partial<Ticket>>({
const [formData, setFormData] = useState<Omit<Partial<Ticket>, "deadline"> & { deadline?: string }>({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I see what you're doing here, the type of this state variable is very cumbersome. This state variable should store the form data that will be sent to the server. The server should expect deadline to be a Go time.Time object (equivalent to JavaScript's Date object), which is not reflected here. I recommend reverting this change.

},
onSettled: () => setIsSaving(false),
});
// Prepare the ticket data, converting deadline string to Date and excluding empty deadline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit pick: fix the formatting (excess indentation).

status: Status;
createdOn: Date;
updatedAt: Date;
deadline?: Date;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property deadline should not be optional.

const { deadline, ...rest } = formData;
const ticketData: Partial<Ticket> = { ...rest } as Partial<Ticket>;

if (deadline && deadline !== "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to convert from string to Date anymore.

Status string `json:"status"`
CreatedOn time.Time `json:"createdOn"`
UpdatedAt time.Time `json:"updatedAt"`
Deadline *time.Time `json:"deadline,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field Deadline should not be a pointer. Remove the omitempty tag.

Status string `json:"status"`
CreatedOn time.Time `json:"createdOn"`
UpdatedAt time.Time `json:"updatedAt"`
Deadline *time.Time `json:"deadline,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove pointer. Remove omitempty.

)

// Add deadline if it's provided
if ticket.Deadline != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Deadline is no longer a pointer, check if its the JavaScript Date zero value (January 1, 1970, 00:00:00 UTC) to determine how to store the date:

// Get the milliseconds since the Unix epoch (AKA the JavaScript zero value)
milliseconds := ticket.Deadline.UnixMilli()

if milliseconds == 0 {
    // Create a time.Time representing the Unix epoch
    unixEpoch := time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)

    // Store the Unix epoch instead
    doc = append(doc, bson.E{Key: "deadline", Value: unixEpoch})
} else {
    // Non-zero date value provided; store the deadline
    doc = append(doc, bson.E{Key: "deadline", Value: ticket.Deadline})
}

updatesDoc = append(updatesDoc, bson.E{Key: "status", Value: status})
}

if deadline, ok := updates["deadline"].(string); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost! No need to try parsing different formatted date strings. RFC3339 should work:

if datestr, ok := updates["deadline"].(string); ok {
    deadline, err := time.Parse(time.RFC3339, datestr)
    if err != nil {
        sugar.Error(err)
        return nil, err
    }

    updatesDoc = append(updatesDoc, bson.E{Key: "deadline", Value: deadline})
}

{tickets.map((ticket) => {
// Format deadline with both date and time (no seconds)
const deadline = (ticket as any).deadline;
const deadlineDisplay = deadline ? (() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issues here. Don't include the time in the deadline in this PR. Refer to my comments on ticket-detail.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants