Format tasks code

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-06-05 11:05:54 -07:00
parent fc008c27f4
commit 7a3c782e1a
4 changed files with 20 additions and 19 deletions

View File

@@ -996,7 +996,7 @@ function MeasureViewContent({
name: newTaskName, name: newTaskName,
description: newTaskDescription, description: newTaskDescription,
timeEstimate: isoTimeEstimate === "" ? null : isoTimeEstimate, timeEstimate: isoTimeEstimate === "" ? null : isoTimeEstimate,
deadline: newDeadline === "" ? null : formatISO(newDeadline), deadline: newDeadline === "" ? null : formatISO(parseISO(newDeadline)),
}, },
}, },
onCompleted: () => { onCompleted: () => {
@@ -1762,7 +1762,7 @@ function MeasureViewContent({
// Function to handle saving the updated deadline // Function to handle saving the updated deadline
const handleSaveDeadline = useCallback( const handleSaveDeadline = useCallback(
(taskId: string) => { (taskId: string) => {
const newDeadline = editDeadline === "" ? null : formatISO(editDeadline); const newDeadline = editDeadline === "" ? null : formatISO(parseISO(editDeadline));
updateTask({ updateTask({
variables: { variables: {
input: { input: {

View File

@@ -47,7 +47,7 @@ import {
DropdownMenuTrigger, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { ListTaskViewOrganizationQuery } from "./__generated__/ListTaskViewOrganizationQuery.graphql"; import { ListTaskViewOrganizationQuery } from "./__generated__/ListTaskViewOrganizationQuery.graphql";
import {formatDate, parseISO} from "date-fns"; import {format as formatDate, parseISO} from "date-fns";
// Function to format ISO8601 duration to human-readable format // Function to format ISO8601 duration to human-readable format
const formatDuration = (isoDuration: string | null | undefined): string => { const formatDuration = (isoDuration: string | null | undefined): string => {
@@ -279,7 +279,7 @@ function TaskCard({ task, onClick, onToggleState }: {
)} )}
{task.deadline && ( {task.deadline && (
<span className="text-xs text-gray-500"> <span className="text-xs text-gray-500">
{formatDate(task.deadline, "dd MMM yyyy")} {formatDate(parseISO(task.deadline), "dd MMM yyyy")}
</span> </span>
)} )}
</div> </div>
@@ -463,7 +463,7 @@ function ListTaskContent({
measureId: selectedMeasure?.id || null, measureId: selectedMeasure?.id || null,
assignedToId: assignee?.id, assignedToId: assignee?.id,
timeEstimate: formattedTimeEstimate, timeEstimate: formattedTimeEstimate,
deadline: deadline deadline: deadline ? deadline.toISOString() : null
}, },
connections: [data.node?.tasks?.__id || ""], connections: [data.node?.tasks?.__id || ""],
}, },
@@ -854,7 +854,7 @@ function ListTaskContent({
</div> </div>
{/* Deadline */} {/* Deadline */}
<div className="flex justify-between items-center broder-b border-[rgba(2,42,2,0.08)] py-3"> <div className="flex justify-between items-center border-b border-[rgba(2,42,2,0.08)] py-3">
<Label className="text-sm font-medium text-gray-500">Deadline</Label> <Label className="text-sm font-medium text-gray-500">Deadline</Label>
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<Input type="date" value={deadlineString} onChange={handleDeadlineChange} <Input type="date" value={deadlineString} onChange={handleDeadlineChange}

View File

@@ -1 +1 @@
ALTER TABLE tasks ADD COLUMN deadline TIMESTAMP WITH TIME ZONE; ALTER TABLE tasks ADD COLUMN IF NOT EXISTS deadline TIMESTAMP WITH TIME ZONE;

View File

@@ -72,7 +72,7 @@ SELECT
reference_id, reference_id,
time_estimate, time_estimate,
assigned_to, assigned_to,
deadline, deadline,
created_at, created_at,
updated_at updated_at
FROM FROM
@@ -121,7 +121,7 @@ INSERT INTO
state, state,
time_estimate, time_estimate,
assigned_to, assigned_to,
deadline, deadline,
created_at, created_at,
updated_at updated_at
) )
@@ -136,7 +136,7 @@ VALUES (
@state, @state,
@time_estimate, @time_estimate,
@assigned_to, @assigned_to,
@deadline, @deadline,
@created_at, @created_at,
@updated_at @updated_at
); );
@@ -179,7 +179,7 @@ INSERT INTO
state, state,
time_estimate, time_estimate,
assigned_to, assigned_to,
deadline, deadline,
created_at, created_at,
updated_at updated_at
) )
@@ -194,14 +194,15 @@ VALUES (
@state, @state,
@time_estimate, @time_estimate,
@assigned_to, @assigned_to,
@deadline, @deadline,
@created_at, @created_at,
@updated_at @updated_at
) )
ON CONFLICT (measure_id, reference_id) DO UPDATE SET ON CONFLICT (measure_id, reference_id) DO UPDATE SET
name = @name, name = @name,
description = @description, description = @description,
updated_at = @updated_at updated_at = @updated_at,
deadline = @deadline
RETURNING RETURNING
id, id,
organization_id, organization_id,
@@ -212,7 +213,7 @@ RETURNING
state, state,
time_estimate, time_estimate,
assigned_to, assigned_to,
deadline, deadline,
created_at, created_at,
updated_at updated_at
` `
@@ -314,7 +315,7 @@ SELECT
reference_id, reference_id,
time_estimate, time_estimate,
assigned_to, assigned_to,
deadline, deadline,
created_at, created_at,
updated_at updated_at
FROM FROM