Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ were moving from portions to units #43

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/components/pen/PenCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ defineProps<{ round: Round }>()
<div class="flex">
<u-card class="w-full">
<div class="flex flex-col items-center justify-center space-y-4">
<div> {{ round.mg }}mg of {{ round.content }} </div>
<pen-model :color="round.color">
<transition name="fade">
<cartridge-model :round="round" />
</transition>
</pen-model>
<div>
{{ round.content }} {{ round.ml }}ml {{ round.mg }}mg
</div>
<shot-summary :round="round" />
<shot-log :round="round" />
</div>
Expand Down
11 changes: 7 additions & 4 deletions app/components/round/RoundForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const state = reactive<Partial<Round>>({
color: props.round?.color ?? range.colors[0],
content: props.round?.content ?? range.contents[0],
ml: props.round?.ml ?? range.mls[0],
mg: props.round?.mg ?? range.mgs[1],
portions: props.round?.portions ?? 4,
mg: props.round?.mg ?? range.mgs[2],
units: props.round?.portions ?? range.units[2],
frequency: props.round?.frequency ?? 'weekly',
date: props.round?.date
? format(new Date(props.round.date), 'yyyy-MM-dd')
Expand Down Expand Up @@ -79,8 +79,11 @@ const submit = async () => {
/>
</u-form-group>

<u-form-group label="Portions" name="portions">
<u-input v-model="state.portions" type="number" label="Portions" />
<u-form-group label="Units per-shot" name="units">
<u-select-menu
v-model="state.units"
:options="range.units"
/>
</u-form-group>
<u-form-group label="Frequency" name="frequency">
<u-input
Expand Down
5 changes: 3 additions & 2 deletions app/components/shot/ShotSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import type { Round } from '~/types/models'

const props = defineProps<{ round: Round }>()
const { unitsRemain } = useRound(props.round)
const { unitsRemain, mgPerUnits } = useRound(props.round)
</script>

<template>
<div>
{{ unitsRemain() }} remaining units
<div> {{ unitsRemain() }} remaining units </div>
<div> {{ round.units }} units = {{ mgPerUnits() }}mg </div>
</div>
</template>
8 changes: 6 additions & 2 deletions app/composables/round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ShotDay {

export const useRound = (round: Round) => {
const shotDates = (): Date[] => {
const portions = round.portions || 4
const portions = round.ml * 100 / round.units

const getNextDate = (index: number): Date => {
switch (round.frequency) {
Expand All @@ -29,7 +29,7 @@ export const useRound = (round: Round) => {
const today = new Date()
return shotDates().map(date => ({
date,
units: round.ml * 100 / round.portions,
units: round.units,
taken: isBefore(date, today),
isToday: isSameDay(date, today),
}))
Expand All @@ -55,6 +55,9 @@ export const useRound = (round: Round) => {
.reduce((total, day) => total + day.units, 0)
}

// 200 units = 20mg so 50 units is 5mg
const mgPerUnits = (): number => round.mg * round.units / (round.ml * 100)

return {
shotDates,
lastShotDate,
Expand All @@ -63,6 +66,7 @@ export const useRound = (round: Round) => {
shotDaysLeft,
isShotDayToday,
unitsRemain,
mgPerUnits,
title,
}
}
1 change: 1 addition & 0 deletions app/pages/users/[user]/rounds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const columns = [
{ label: 'Content', key: 'content' },
{ label: 'Mg', key: 'mg' },
{ label: 'Ml', key: 'ml' },
{ label: 'Units', key: 'units' },
{ label: 'Timeline', key: 'date' },
{ label: 'Actions', key: 'actions' },
]
Expand Down
18 changes: 4 additions & 14 deletions app/utils/shared.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { CookieOptions } from '#app'
import type { HeaderLink } from '@nuxt/ui-pro/types'

(BigInt.prototype as any).toJSON = function () {
Expand All @@ -21,7 +20,7 @@ export type HeaderIconLink = HeaderLink & { icon: string }
export const links: HeaderIconLink[] = [
{
label: 'Home',
icon: 'i-heroicons-home',
icon: 'i-mdi-home',
to: '/',
},
{
Expand All @@ -34,18 +33,8 @@ export const links: HeaderIconLink[] = [
icon: 'i-mdi-account-multiple',
to: '/users',
},
{
label: 'Shots',
icon: 'i-mdi-syringe',
},
]

export const cookieOptions: CookieOptions & { readonly?: false } = {
path: '/',
sameSite: 'strict',
maxAge: 60 * 60 * 24 * 365,
}

const colors = [
'cyan',
'sky',
Expand All @@ -57,8 +46,7 @@ const colors = [

const contents = [
'Tirzepatide',
'Retatrutide',
'Semaglutide',
'Cagrilintide',
]

const mls = [
Expand All @@ -67,6 +55,7 @@ const mls = [
]

const mgs = [
5,
10,
20,
30,
Expand All @@ -75,6 +64,7 @@ const mgs = [

const units = [
25,
40,
50,
]
export const range = {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"jose": "^5.9.3"
},
"devDependencies": {
"@antfu/eslint-config": "^3.7.1",
"@antfu/eslint-config": "^3.7.3",
"@cloudflare/workers-types": "^4.20240925.0",
"@iconify-json/logos": "^1.2.0",
"@iconify-json/mdi": "^1.2.0",
Expand All @@ -51,12 +51,12 @@
"dotenv-cli": "^7.4.2",
"happy-dom": "^15.7.4",
"nuxt": "^3.13.2",
"nuxt-auth-utils": "^0.3.9",
"nuxt-og-image": "3.0.2",
"nuxt-auth-utils": "^0.4.1",
"nuxt-og-image": "3.0.4",
"prisma": "^5.20.0",
"ua-parser-js": "^1.0.39",
"vitest": "^2.1.1",
"wrangler": "^3.78.9",
"wrangler": "^3.78.12",
"zod": "^3.23.8"
}
}
Loading