fixed due today and made it due within 12 hrs either way. Also added 'complete until' language to recurring task status update dropdown
This commit is contained in:
@@ -68,3 +68,44 @@ export const STATUS_OPTIONS = [
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "0", label: "0 - Not Yet Started" }
|
||||
];
|
||||
|
||||
const DAY_NAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
|
||||
type Recurrence = {
|
||||
type: 'daily' | 'weekly' | 'monthly';
|
||||
days?: number[];
|
||||
dayOfMonth?: number;
|
||||
};
|
||||
|
||||
export const getRecurrenceCompleteLabel = (recurrence?: Recurrence | null): string => {
|
||||
if (!recurrence) return "10 - Complete";
|
||||
if (recurrence.type === 'daily') return "10 - Complete until tomorrow";
|
||||
if (recurrence.type === 'weekly') {
|
||||
if (recurrence.days && recurrence.days.length > 0) {
|
||||
const today = new Date().getDay();
|
||||
const sorted = [...recurrence.days].sort((a, b) => {
|
||||
const da = (a - today + 7) % 7 || 7;
|
||||
const db = (b - today + 7) % 7 || 7;
|
||||
return da - db;
|
||||
});
|
||||
return `10 - Complete until ${DAY_NAMES[sorted[0]]}`;
|
||||
}
|
||||
return "10 - Complete (weekly)";
|
||||
}
|
||||
if (recurrence.type === 'monthly') {
|
||||
const dom = recurrence.dayOfMonth;
|
||||
if (dom != null) {
|
||||
const suffix = dom === 1 || dom === 21 || dom === 31 ? 'st'
|
||||
: dom === 2 || dom === 22 ? 'nd'
|
||||
: dom === 3 || dom === 23 ? 'rd' : 'th';
|
||||
return `10 - Complete until the ${dom}${suffix}`;
|
||||
}
|
||||
}
|
||||
return "10 - Complete";
|
||||
};
|
||||
|
||||
export const getStatusOptionsForTask = (recurrence?: Recurrence | null) =>
|
||||
STATUS_OPTIONS.map(opt =>
|
||||
opt.value === "10" ? { ...opt, label: getRecurrenceCompleteLabel(recurrence) } : opt
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user