Remove cancel confirmation — discard timer immediately on click
This commit is contained in:
@@ -56,7 +56,6 @@ export function TimerWidget() {
|
|||||||
const { projects } = useProjects();
|
const { projects } = useProjects();
|
||||||
const [showProjectSelect, setShowProjectSelect] = useState(false);
|
const [showProjectSelect, setShowProjectSelect] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [confirmCancel, setConfirmCancel] = useState(false);
|
|
||||||
|
|
||||||
// Start time editing state
|
// Start time editing state
|
||||||
const [editingStartTime, setEditingStartTime] = useState(false);
|
const [editingStartTime, setEditingStartTime] = useState(false);
|
||||||
@@ -74,7 +73,6 @@ export function TimerWidget() {
|
|||||||
|
|
||||||
const handleStop = async () => {
|
const handleStop = async () => {
|
||||||
setError(null);
|
setError(null);
|
||||||
setConfirmCancel(false);
|
|
||||||
try {
|
try {
|
||||||
await stopTimer();
|
await stopTimer();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -86,7 +84,6 @@ export function TimerWidget() {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await cancelTimer();
|
await cancelTimer();
|
||||||
setConfirmCancel(false);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Failed to cancel timer");
|
setError(err instanceof Error ? err.message : "Failed to cancel timer");
|
||||||
}
|
}
|
||||||
@@ -210,41 +207,20 @@ export function TimerWidget() {
|
|||||||
|
|
||||||
{/* Stop + Cancel Buttons */}
|
{/* Stop + Cancel Buttons */}
|
||||||
<div className="flex items-center space-x-2 shrink-0 sm:order-last">
|
<div className="flex items-center space-x-2 shrink-0 sm:order-last">
|
||||||
{confirmCancel ? (
|
<button
|
||||||
<div className="flex items-center space-x-2">
|
onClick={() => void handleCancelTimer()}
|
||||||
<span className="text-sm text-gray-600">Discard timer?</span>
|
title="Discard timer"
|
||||||
<button
|
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
onClick={() => void handleCancelTimer()}
|
>
|
||||||
className="flex items-center space-x-1 px-3 py-2 bg-gray-700 text-white rounded-lg font-medium hover:bg-gray-800 transition-colors text-sm"
|
<Trash2 className="h-5 w-5" />
|
||||||
>
|
</button>
|
||||||
<Trash2 className="h-4 w-4" />
|
<button
|
||||||
<span>Discard</span>
|
onClick={handleStop}
|
||||||
</button>
|
className="flex items-center space-x-2 px-6 py-3 bg-red-600 text-white rounded-lg font-medium hover:bg-red-700 transition-colors"
|
||||||
<button
|
>
|
||||||
onClick={() => setConfirmCancel(false)}
|
<Square className="h-5 w-5 fill-current" />
|
||||||
className="px-3 py-2 text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-lg transition-colors text-sm"
|
<span>Stop</span>
|
||||||
>
|
</button>
|
||||||
Keep
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<button
|
|
||||||
onClick={() => setConfirmCancel(true)}
|
|
||||||
title="Discard timer"
|
|
||||||
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
<Trash2 className="h-5 w-5" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={handleStop}
|
|
||||||
className="flex items-center space-x-2 px-6 py-3 bg-red-600 text-white rounded-lg font-medium hover:bg-red-700 transition-colors"
|
|
||||||
>
|
|
||||||
<Square className="h-5 w-5 fill-current" />
|
|
||||||
<span>Stop</span>
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user