ccsync icon indicating copy to clipboard operation
ccsync copied to clipboard

Bug: incorrect toast showing up on fail to creating task

Open rohansen856 opened this issue 1 year ago • 6 comments

After logging in and trying to create a new task fron the Tasks section, while creating a new task:

  1. If task description is not provided or,
  2. taskserver is not running the task creation fails ad the backend returns error 400 and 500 respectively. instead of showing task creation failed, the toast shows task created successfully. I think the problem is in file frontend/src/components/HomeComponents/Tasks/Tasks.tsx, right here:
if (response) {
    console.log("Task added successfully!")
    toast.success("Task added successfully!", {
        position: "bottom-left",
        autoClose: 3000,
        hideProgressBar: false,
        closeOnClick: true,
        pauseOnHover: true,
        draggable: true,
        progress: undefined,
    })
    setNewTask({
        description: "",
        priority: "",
        project: "",
        due: "",
    })
    setIsAddTaskOpen(false)
}

as fetch always returns a Response object, the if(response) check is always true. instead it should be this: if(response.ok). I would like to solve this issue. please assign me.

rohansen856 avatar Jan 05 '25 21:01 rohansen856

attaching a demo video for reference:

Screencast from 2025-01-05 05-08-25.webm

as shown in the video, although no description is provided (in the first case) and the taskserver is not running (in second case), the server returns error, but the frontend shows success toast.

rohansen856 avatar Jan 05 '25 21:01 rohansen856

this seems about right, but i think that, for the empty description part, we can do something better... like if possible, stop the user at the dialog itself and prompt them to enter a non-empty description.

its-me-abhishek avatar Jan 06 '25 05:01 its-me-abhishek

this also should be changed in the edit-description function

its-me-abhishek avatar Jan 06 '25 05:01 its-me-abhishek

Sure @its-me-abhishek i believe there are two possible ways to handle it:

  1. update the submit task functionality and make it a form component with all the necessary checks
  2. update the handleAddTask function to implement all the necessary checks there.

personally i think implementing both of these together will ensure maximum safety. same for the edit description functinality in handleEditTaskDesc function. we can implement a form structure and also make necessary checks in handleSaveClick function before the handleEditTaskDesc is called with the validated data.

It would be best if you can suggest a minlength for the description. that way all checks can be safely done via that.

PS. the response.ok should be implemented together with all these.

rohansen856 avatar Jan 06 '25 08:01 rohansen856

update the submit task functionality and make it a form component with all the necessary checks

why is this required?

for the minLength, i think that 1 should work... as we cannot have an empty string as a description

its-me-abhishek avatar Jan 08 '25 12:01 its-me-abhishek

Ok will implement that. Along with it i have observed one more bug in the Due date input, invalid dates like 2025-33-33 can be submitted without throwing any errors. Will try to prevent that too along with the description validation.

rohansen856 avatar Jan 08 '25 13:01 rohansen856