diff --git a/README.md b/README.md index 7f3b6f2..985f341 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ # HabitKit +[![Build & Publish](https://github.com/MichaelHolley/HabitKit/actions/workflows/nixpacks_publish.yml/badge.svg?branch=main)](https://github.com/MichaelHolley/HabitKit/actions/workflows/nixpacks_publish.yml) + A simple and intuitive app to track, build, and maintain your habits for a better you! ![image](https://github.com/user-attachments/assets/1fcd0733-f82f-474f-a1b5-844f9167aae8) diff --git a/src/lib/server/habit.ts b/src/lib/server/habit.ts index 87aedbe..4539b08 100644 --- a/src/lib/server/habit.ts +++ b/src/lib/server/habit.ts @@ -1,12 +1,19 @@ +import { Prisma } from '@prisma/client'; import { prisma } from './prisma'; export const getHabitForUser = async (id: string, userId: string) => { - return await prisma.habit.findUnique({ + let habit = await prisma.habit.findUnique({ where: { id: id, userId: userId } }); + + if (!habit) return null; + + habit = { ...habit, dates: (habit.dates as Prisma.JsonArray).sort().reverse() }; + + return habit; }; export const getUserHabits = async (userId: string) => {