Skip to content

Commit

Permalink
Merge pull request #17 from fumeapp/shot-day-alert-toggle
Browse files Browse the repository at this point in the history
⚗️ shot day reflects the shot has been taken
  • Loading branch information
acidjazz authored Aug 30, 2024
2 parents 1062f9e + de562bb commit d8493da
Show file tree
Hide file tree
Showing 6 changed files with 5,518 additions and 7,050 deletions.
25 changes: 23 additions & 2 deletions app/components/shot/ShotDayForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ const isShotDayToday = computed((): boolean =>
weekDays[new Date().getDay()]?.toLowerCase() === props.pen.shotDay?.toLowerCase(),
)
const lastShot = computed(() => props.pen?.cartridge?.shots?.at(-1) ?? null)
const hasTakenShotOnShotDay = computed((): boolean => {
if (!isShotDayToday.value) return false
if (!lastShot.value) return false
const today = new Date()
const lastShotDate = new Date(lastShot.value.date)
return (
today.getDate() === lastShotDate.getDate()
&& today.getMonth() === lastShotDate.getMonth()
&& today.getFullYear() === lastShotDate.getFullYear()
)
})
const update = (day?: string) => {
useApi()
.api(
Expand Down Expand Up @@ -39,11 +55,16 @@ const update = (day?: string) => {
<u-button :ui="{ rounded: 'rounded-full' }" icon="i-mdi-close" size="xs" variant="ghost" square @click="update()" />
</div>
<u-alert
v-if="isShotDayToday"
v-if="hasTakenShotOnShotDay"
icon="i-mdi-check"
title="You've taken your shot today!" color="emerald"
/>
<u-alert
v-else-if="isShotDayToday"
icon="i-mdi-alert"
title="Shot day is today"
description="Don't forget to take your shot and log it!"
color="emerald"
color="sky"
/>
</template>

Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default defineNuxtConfig({
vite: {
resolve: {
alias: {
'.prisma/client/index-browser': './node_modules/.pnpm/@prisma+client@5.18.0_prisma@5.18.0/node_modules/.prisma/client/index-browser.js',
'.prisma/client/index-browser': './node_modules/.pnpm/@prisma+client@5.19.0_prisma@5.19.0/node_modules/.prisma/client/index-browser.js',
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
"date-fns": "^3.6.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.27.1",
"@antfu/eslint-config": "^3.0.0",
"@iconify-json/logos": "^1.1.44",
"@iconify-json/mdi": "^1.1.68",
"@nuxt/content": "^2.13.2",
"@nuxt/devtools": "^1.3.14",
"@nuxt/eslint": "^0.5.2",
"@nuxt/image": "^1.7.0",
"@nuxt/devtools": "^1.4.1",
"@nuxt/eslint": "^0.5.4",
"@nuxt/image": "^1.8.0",
"@nuxt/test-utils": "^3.14.1",
"@prisma/client": "^5.18.0",
"@prisma/client": "^5.19.0",
"@prisma/nuxt": "^0.0.35",
"@types/ua-parser-js": "^0.7.39",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"dotenv-cli": "^7.4.2",
"happy-dom": "^15.0.0",
"happy-dom": "^15.6.0",
"nuxt": "^3.13.0",
"nuxt-auth-utils": "^0.3.4",
"prisma": "^5.18.0",
"nuxt-auth-utils": "^0.3.5",
"prisma": "^5.19.0",
"ua-parser-js": "^1.0.38",
"vitest": "^2.0.5",
"zod": "^3.23.8"
Expand Down
Loading

0 comments on commit d8493da

Please sign in to comment.