Minor frontend fixes
This commit is contained in:
parent
cdd0a01fab
commit
0021b103d0
@ -36,7 +36,7 @@ export default function EditableDayComment({
|
|||||||
if (!newComment) { return }
|
if (!newComment) { return }
|
||||||
updateDay(
|
updateDay(
|
||||||
{
|
{
|
||||||
dateQuery: format(day.date, "yyyy-MM-dd"),
|
dateQuery: day.date,
|
||||||
comment: newComment,
|
comment: newComment,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,21 +8,22 @@ import {
|
|||||||
import { ButtonWithTooltip } from "@/components/ui/button";
|
import { ButtonWithTooltip } from "@/components/ui/button";
|
||||||
import { Star } from "lucide-react";
|
import { Star } from "lucide-react";
|
||||||
import { useUpdateDay } from "@lifetracker/shared-react/hooks/days";
|
import { useUpdateDay } from "@lifetracker/shared-react/hooks/days";
|
||||||
import { format } from 'date-fns';
|
import { useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { toast } from "@/components/ui/use-toast";
|
||||||
|
|
||||||
|
|
||||||
export function MoodStars({
|
export function MoodStars({
|
||||||
day,
|
day: initialDay,
|
||||||
maximum = 10,
|
maximum = 10,
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
|
||||||
|
const [day, setDay] = useState(initialDay);
|
||||||
|
|
||||||
const { mutate: updateDay, isPending } = useUpdateDay({
|
const { mutate: updateDay, isPending } = useUpdateDay({
|
||||||
onSuccess: () => {
|
onSuccess: (res, req, meta) => {
|
||||||
|
setDay(res);
|
||||||
toast({
|
toast({
|
||||||
description: "Rating updated!",
|
description: "Rating updated!",
|
||||||
});
|
});
|
||||||
router.refresh();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const setStars = (newStars: number) => {
|
const setStars = (newStars: number) => {
|
||||||
@ -32,7 +33,7 @@ export function MoodStars({
|
|||||||
}
|
}
|
||||||
updateDay(
|
updateDay(
|
||||||
{
|
{
|
||||||
dateQuery: format(day.date, "yyyy-MM-dd"),
|
dateQuery: day.date,
|
||||||
mood: newStars,
|
mood: newStars,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,9 +62,10 @@ export function EditableHourCode({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
className="w-8 border-b-2 text-center edit-hour-code"
|
className="w-8 border-b text-center edit-hour-code"
|
||||||
style={{
|
style={{
|
||||||
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
|
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
|
||||||
|
borderColor: hour.foreground ?? "inherit"
|
||||||
}}
|
}}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
defaultValue={originalText}
|
defaultValue={originalText}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ export function EditableHourComment({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
className="w-full border-b-2 text-left edit-hour-comment"
|
className="w-full text-left edit-hour-comment"
|
||||||
style={{
|
style={{
|
||||||
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
|
background: hour.background ?? "inherit", color: hour.foreground ?? "inherit", fontFamily: "inherit",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -171,9 +171,12 @@ export const daysAppRouter = router({
|
|||||||
if (updatedProps.mood) {
|
if (updatedProps.mood) {
|
||||||
updatedProps.mood = parseInt(updatedProps.mood);
|
updatedProps.mood = parseInt(updatedProps.mood);
|
||||||
}
|
}
|
||||||
await ctx.db
|
const res = await ctx.db
|
||||||
.update(days)
|
.update(days)
|
||||||
.set(updatedProps)
|
.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];
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user