Minor frontend fixes

This commit is contained in:
Ryan Pandya 2024-12-03 21:30:40 -08:00
parent cdd0a01fab
commit 0021b103d0
5 changed files with 18 additions and 13 deletions

View File

@ -36,7 +36,7 @@ export default function EditableDayComment({
if (!newComment) { return }
updateDay(
{
dateQuery: format(day.date, "yyyy-MM-dd"),
dateQuery: day.date,
comment: newComment,
},
{

View File

@ -8,21 +8,22 @@ import {
import { ButtonWithTooltip } from "@/components/ui/button";
import { Star } from "lucide-react";
import { useUpdateDay } from "@lifetracker/shared-react/hooks/days";
import { format } from 'date-fns';
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "@/components/ui/use-toast";
export function MoodStars({
day,
day: initialDay,
maximum = 10,
}) {
const router = useRouter();
const [day, setDay] = useState(initialDay);
const { mutate: updateDay, isPending } = useUpdateDay({
onSuccess: () => {
onSuccess: (res, req, meta) => {
setDay(res);
toast({
description: "Rating updated!",
});
router.refresh();
},
});
const setStars = (newStars: number) => {
@ -32,7 +33,7 @@ export function MoodStars({
}
updateDay(
{
dateQuery: format(day.date, "yyyy-MM-dd"),
dateQuery: day.date,
mood: newStars,
},
{

View File

@ -62,9 +62,10 @@ export function EditableHourCode({
</div>
<input
className="w-8 border-b-2 text-center edit-hour-code"
className="w-8 border-b text-center edit-hour-code"
style={{
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
borderColor: hour.foreground ?? "inherit"
}}
ref={ref}
defaultValue={originalText}

View File

@ -54,7 +54,7 @@ export function EditableHourComment({
};
return (
<input
className="w-full border-b-2 text-left edit-hour-comment"
className="w-full text-left edit-hour-comment"
style={{
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
}}

View File

@ -171,9 +171,12 @@ export const daysAppRouter = router({
if (updatedProps.mood) {
updatedProps.mood = parseInt(updatedProps.mood);
}
await ctx.db
const res = await ctx.db
.update(days)
.set(updatedProps)
.where(eq(days.date, utcDateFromInput({ dateQuery: dateQuery, timezone: timezone ?? ctx.user.timezone })));
.where(eq(days.date, dateFromInput({ dateQuery: dateQuery, timezone: timezone ?? ctx.user.timezone })
)).returning();
return res[0];
}),
});