Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
pull_request:
branches: ["main", "master"]
push:
branches: ["main", "master"]
branches: ["**"]
workflow_dispatch:

jobs:
test:
Expand Down
6 changes: 3 additions & 3 deletions src/components/AuthDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ export const AuthDialog: React.FC<{ isOpen: boolean; onClose: () => void }> = ({
</Button>
</form>
{error && (
<Alert className="mt-4">
<Alert variant="destructive" className="mt-4">
<AlertDescription>{error}</AlertDescription>
</Alert>
)}

{success && (
<Alert className="mt-4">
<AlertDescription className="text-green-600">
<Alert className="mt-4 border-green-200 bg-green-50">
<AlertDescription className="text-green-700">
{success}
</AlertDescription>
</Alert>
Expand Down
52 changes: 37 additions & 15 deletions src/components/CategoryManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Plus, Edit, Trash2, Tag } from "lucide-react";
import { TaskCategory } from "@/config/categories";
import { useTimeTracking } from "@/hooks/useTimeTracking";
import { toast } from "@/hooks/use-toast";

interface CategoryManagementProps {
isOpen: boolean;
Expand All @@ -41,6 +42,7 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
);
const [isAddingNew, setIsAddingNew] = useState(false);
const [deleteTargetId, setDeleteTargetId] = useState<string | null>(null);
const [isSaving, setIsSaving] = useState(false);
const [formData, setFormData] = useState({
name: '',
description: '',
Expand All @@ -61,6 +63,7 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIsSaving(true);

const categoryData = {
name: formData.name.trim(),
Expand All @@ -69,16 +72,23 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
isBillable: formData.isBillable
};

if (editingCategory) {
updateCategory(editingCategory.id, categoryData);
const isEditing = !!editingCategory;
if (isEditing) {
updateCategory(editingCategory!.id, categoryData);
} else {
addCategory(categoryData);
}

// Save changes to database
await forceSyncToDatabase();
toast({
title: isEditing ? "Category updated" : "Category added",
description: isEditing
? `"${categoryData.name}" has been updated.`
: `"${categoryData.name}" has been added.`
});

resetForm();
setIsSaving(false);
};

const handleEdit = (category: TaskCategory) => {
Expand All @@ -94,9 +104,16 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({

const handleDeleteConfirm = async () => {
if (!deleteTargetId) return;
setIsSaving(true);
const deletedName = categories.find((c) => c.id === deleteTargetId)?.name;
deleteCategory(deleteTargetId);
await forceSyncToDatabase();
toast({
title: "Category deleted",
description: deletedName ? `"${deletedName}" has been removed.` : undefined
});
setDeleteTargetId(null);
setIsSaving(false);
};

const predefinedColors = [
Expand Down Expand Up @@ -146,9 +163,12 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
<CardContent>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<Label htmlFor="name">Category Name *</Label>
<Label htmlFor="name">
Category Name <span className="text-destructive" aria-hidden="true">*</span>
</Label>
<Input
id="name"
aria-required="true"
value={formData.name}
onChange={(e) =>
setFormData((prev) => ({
Expand Down Expand Up @@ -193,7 +213,7 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
}
className="w-16 h-10"
/>
<span className="text-sm text-gray-500">
<span className="text-sm text-muted-foreground">
{formData.color}
</span>
<div
Expand All @@ -204,7 +224,7 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({

{/* Predefined Colors */}
<div className="flex flex-wrap gap-2">
<span className="text-sm text-gray-600 w-full">
<span className="text-sm text-muted-foreground w-full">
Quick colors:
</span>
{predefinedColors.map((color) => (
Expand Down Expand Up @@ -240,16 +260,18 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
<Label htmlFor="billable" className="text-sm font-medium">
Billable category
</Label>
<span className="text-xs text-gray-500">
<span className="text-xs text-muted-foreground">
(Tasks in this category can generate revenue)
</span>
</div>

<div className="flex space-x-2">
<Button type="submit">
{editingCategory ? 'Update' : 'Add'}
<Button type="submit" disabled={isSaving}>
{isSaving
? (editingCategory ? "Updating..." : "Adding...")
: (editingCategory ? "Update" : "Add")}
</Button>
<Button type="button" variant="outline" onClick={resetForm}>
<Button type="button" variant="outline" onClick={resetForm} disabled={isSaving}>
Cancel
</Button>
</div>
Expand All @@ -267,8 +289,8 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
{categories.length === 0 ? (
<Card>
<CardContent className="text-center py-8">
<Tag className="w-12 h-12 text-gray-400 mx-auto mb-4" />
<p className="text-gray-600">
<Tag className="w-12 h-12 text-muted-foreground mx-auto mb-4" />
<p className="text-muted-foreground">
No categories yet. Add your first category to get started!
</p>
</CardContent>
Expand All @@ -291,19 +313,19 @@ export const CategoryManagement: React.FC<CategoryManagementProps> = ({
/>
<div>
<div className="flex items-center space-x-2">
<h4 className="font-semibold text-gray-900">
<h4 className="font-semibold text-foreground">
{category.name}
</h4>
<span className={`px-2 py-1 text-xs rounded-full ${
category.isBillable !== false
? 'bg-green-100 text-green-800'
: 'bg-gray-100 text-gray-800'
: 'bg-muted text-muted-foreground'
}`}>
{category.isBillable !== false ? 'Billable' : 'Non-billable'}
</span>
</div>
{category.description && (
<p className="text-sm text-gray-600 mt-1">
<p className="text-sm text-muted-foreground mt-1">
{category.description}
</p>
)}
Expand Down
10 changes: 5 additions & 5 deletions src/components/DaySummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const DaySummary: React.FC<DaySummaryProps> = ({
</CardHeader>
<CardContent>
<div className="space-y-4">
<div className="text-sm text-gray-600">
<div className="text-sm text-muted-foreground">
<p>{formatDate(dayStartTime)}</p>
<p>Started at {formatTime(dayStartTime)}</p>
</div>
Expand All @@ -39,16 +39,16 @@ export const DaySummary: React.FC<DaySummaryProps> = ({
<span className="text-2xl font-bold text-blue-600">
{formatDuration(totalDuration)}
</span>
<span className="text-gray-600">total time</span>
<span className="text-muted-foreground">total time</span>
</div>

<div className="space-y-2">
<h4 className="font-medium text-gray-900">Tasks completed:</h4>
<h4 className="font-medium text-foreground">Tasks completed:</h4>
<div className="space-y-1">
{tasks.map((task) => (
<div key={task.id} className="flex justify-between text-sm">
<span className="text-gray-700">{task.title}</span>
<span className="text-gray-600">
<span className="text-foreground">{task.title}</span>
<span className="text-muted-foreground">
{formatDuration(task.duration || 0)}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const ExportDialog: React.FC<ExportDialogProps> = ({

<div className="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center">
<Upload className="w-8 h-8 mx-auto mb-2 text-muted-foreground" />
<p className="text-sm text-gray-600 mb-2">
<p className="text-sm text-muted-foreground mb-2">
Click to select a CSV file
</p>
<Button onClick={handleImport} variant="outline">
Expand Down
8 changes: 4 additions & 4 deletions src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const SiteNavigationMenu = () => {
<NavigationMenu className="relative bg-gradient-to-br from-gray-50 to-blue-50 print:hidden block">
<List className="flex items-center justify-between px-4 py-2 md:px-8 md:py-4 m-0 list-none rounded-md bg-white p-1 shadow-sm">
<Item className="flex items-center justify-between">
<h1 className="text-2xl font-bold text-gray-900 flex">
<h1 className="text-2xl font-bold text-foreground flex">
<Link
to="/"
className="flex items-center text-gray-900 hover:text-blue-700"
className="flex items-center text-foreground hover:text-blue-700"
>
<img
src="icon.png"
Expand All @@ -65,8 +65,8 @@ const SiteNavigationMenu = () => {
</Link>
</h1>
{isDayStarted && tasks.length > 0 && (
<span className="ml-4 text-lg text-gray-900 font-bold inline-flex">
<CalendarClock className="mr-1 text-gray-900" />
<span className="ml-4 text-lg text-foreground font-bold inline-flex">
<CalendarClock className="mr-1 text-foreground" />
{formatDuration(runningTime)}
</span>
)}
Expand Down
Loading
Loading