Skip to content

Commit

Permalink
FAB bottom style, single workout class, fetch workout fix + add la ba…
Browse files Browse the repository at this point in the history
…guette hangboard
  • Loading branch information
Stevie-Ray committed Jun 22, 2024
1 parent 721e6ac commit 0bdf533
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 127 deletions.
201 changes: 101 additions & 100 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/digital-goods-browser": "^2.0.3",
"@types/google.maps": "^3.55.10",
"@types/jsdom": "^21.1.7",
"@types/node": "^20.14.7",
"@types/node": "^20.14.8",
"@types/web-bluetooth": "^0.0.20",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0",
Expand All @@ -74,6 +74,6 @@
"vite-plugin-vue-devtools": "^7.3.3",
"vite-plugin-vuetify": "^2.0.3",
"vitest": "^1.6.0",
"vue-tsc": "^2.0.21"
"vue-tsc": "^2.0.22"
}
}
13 changes: 13 additions & 0 deletions src/assets/hangboards/YYVERTICALBAGUETTEBACK.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions src/components/molecules/dialog/HangboardAdd/HangboardAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ const { t } = useI18n()
const { user } = storeToRefs(useAuthenticationStore())
const { fetchCommunityWorkouts } = useWorkoutsStore()
const { workoutsCommunity } = storeToRefs(useWorkoutsStore())
const { online } = storeToRefs(useAppStore())
const { fetchCommunityWorkouts, resetCommunityWorkouts } = useWorkoutsStore()
const { getHangboardByIds, getHangboardNameByIds } = useUserStore()
const { updateUser } = useAuthenticationStore()
const { online } = storeToRefs(useAppStore())
const dialog = ref(false)
const selected = reactive({
Expand Down Expand Up @@ -53,6 +55,8 @@ const addHangboard = async () => {
if (user.value) {
updateSelected()
updateUser()
workoutsCommunity.value = []
resetCommunityWorkouts()
await fetchCommunityWorkouts()
}
dialog.value = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IRCRA from 'ircra'
import HangboardSelect from '@/components/molecules/HangboardSelect/HangboardSelect.vue'
import { useAppStore } from '@/stores/app'
import { useUserStore } from '@/stores/user'
import { useWorkoutsStore } from '@/stores/workouts'
import { useAuthenticationStore } from '@/stores/authentication'
import { loadLanguageAsync } from '@/plugins/i18n'
Expand All @@ -17,8 +18,12 @@ const { user } = storeToRefs(useAuthenticationStore())
const { online } = storeToRefs(useAppStore())
const { workoutsCommunity } = storeToRefs(useWorkoutsStore())
const { getHangboardNameByIds, getHangboardByIds } = useUserStore()
const { resetCommunityWorkouts } = useWorkoutsStore()
const { updateUser } = useAuthenticationStore()
const router = useRouter()
Expand Down Expand Up @@ -101,6 +106,8 @@ const finishWalkthrough = (addWorkout: boolean) => {
user.value.settings.walkthrough = true
if (getHangboard.value?.holds !== 0) {
updateSelected()
workoutsCommunity.value = []
resetCommunityWorkouts()
}
updateUser()
}
Expand Down
43 changes: 40 additions & 3 deletions src/helpers/hangboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,31 @@ const companies: Company[] = [
type: 'wood',
url: 'https://www.maxclimbing.com/products/one-finger-trainer',
holds: 6
},
{
name: 'La Baguette',
id: 3,
image: 'hangboards/YYVERTICALBAGUETTE.svg',
size: {
x: 470,
y: 40,
z: 40
},
type: 'wood',
url: 'https://www.maxclimbing.com/products/one-finger-trainer',
holds: 2,
sides: [
{
name: 'Front',
image: 'hangboards/YYVERTICALBAGUETTE.svg',
holds: 2
},
{
name: 'Back',
image: 'hangboards/YYVERTICALBAGUETTEBACK.svg',
holds: 3
}
]
}
]
},
Expand Down Expand Up @@ -5903,8 +5928,20 @@ const companies: Company[] = [
z: 40
},
type: 'wood',
url: null,
holds: 3
url: 'https://www.yyvertical.com/collections/tous-les-produits/products/la-baguette-poutre-escalade',
holds: 2,
sides: [
{
name: 'Front',
image: 'hangboards/YYVERTICALBAGUETTE.svg',
holds: 2
},
{
name: 'Back',
image: 'hangboards/YYVERTICALBAGUETTEBACK.svg',
holds: 3
}
]
},
{
name: 'Travelboard',
Expand All @@ -5916,7 +5953,7 @@ const companies: Company[] = [
z: 30
},
type: 'wood',
url: null,
url: 'https://www.yyvertical.com/collections/tous-les-produits/products/la-travelboard-poutre-dentrainement',
sides: [
{
name: 'Default',
Expand Down
20 changes: 10 additions & 10 deletions src/stores/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import { Activity } from '@/interfaces/activities.interface'

export const useActivitiesStore = defineStore('activities', () => {
const activities: Ref<Activity[]> = ref([])
const { user } = storeToRefs(useAuthenticationStore())
let activitiesDB: UserActivitiesDB | null = null

if (user.value) {
activitiesDB = new UserActivitiesDB(user.value?.id)
}
// action
/**
* Fetch user activity
* @return Array
*/
async function fetchUserActivity() {
if (activities.value.length) return
const { user } = storeToRefs(useAuthenticationStore())
if (user.value) {
const userActivitiesDb = new UserActivitiesDB(user.value?.id)
activities.value = await userActivitiesDb.readAll(null, 'createTimestamp', 'desc', 20)
if (activitiesDB) {
activities.value = await activitiesDB.readAll(null, 'createTimestamp', 'desc', 20)
}
}
/**
Expand All @@ -25,12 +29,8 @@ export const useActivitiesStore = defineStore('activities', () => {
* @return {Promise<void>}
*/
async function createUserActivity(activity: Activity) {
const { user } = storeToRefs(useAuthenticationStore())
if (user.value) {
const userActivitiesDb = new UserActivitiesDB(user.value.id)

const createdActivity = await userActivitiesDb.create(activity)

if (activitiesDB) {
const createdActivity = await activitiesDB.create(activity)
// push to beginning of workouts
activities.value.unshift(createdActivity)
}
Expand Down
23 changes: 14 additions & 9 deletions src/stores/workouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ export const useWorkoutsStore = defineStore('workouts', () => {
const workoutsCommunityFilter = ref({ filter: 'Last Modified', value: 'updateTimestamp' })
const workoutsCommunityFilterDirection = ref<'desc' | 'asc'>('desc')
const leaderboards = ref<Leaderboard[]>([])
let workoutDB: UserWorkoutsDB | null = null

const { user } = storeToRefs(useAuthenticationStore())

if (user.value) {
workoutDB = new UserWorkoutsDB(user.value.id)
}

const fetchUserWorkouts = async () => {
const newWorkouts = await userSubscribedDB.readAll(
[['subscribers', 'array-contains', user.value?.id]],
Expand Down Expand Up @@ -76,9 +81,8 @@ export const useWorkoutsStore = defineStore('workouts', () => {
}

const createUserWorkout = async (workout: Workout) => {
if (user.value) {
const userWorkoutDb = new UserWorkoutsDB(user.value.id)
const createdWorkout = await userWorkoutDb.create(workout)
if (workoutDB) {
const createdWorkout = await workoutDB.create(workout)

workouts.value.unshift(createdWorkout)

Expand All @@ -89,16 +93,14 @@ export const useWorkoutsStore = defineStore('workouts', () => {
}

const updateUserWorkout = async (workout: Workout) => {
if (user.value) {
const userWorkoutsDb = new UserWorkoutsDB(user.value.id)
await userWorkoutsDb.update(workout)
if (workoutDB) {
await workoutDB.update(workout)
}
}

const removeUserWorkoutById = async (id: string) => {
if (user.value) {
const userWorkoutsDb = new UserWorkoutsDB(user.value.id)
await userWorkoutsDb.delete(id)
if (workoutDB) {
await workoutDB.delete(id)

const index = workouts.value.findIndex((workout) => workout.id === id)
if (index !== -1) {
Expand All @@ -107,6 +109,9 @@ export const useWorkoutsStore = defineStore('workouts', () => {
}
}

/**
* Updates a workout of a gven user.
*/
const updateWorkout = async ({ userId, workout }: { userId: string; workout: Workout }) => {
const userWorkoutsDb = new UserWorkoutsDB(userId)
await userWorkoutsDb.update(workout)
Expand Down
1 change: 1 addition & 0 deletions src/views/brands/BrandsDetailPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ useHead({
extended
app
:text="t('Start training')"
style="bottom: 56px"
></v-fab>
</v-fab-transition>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/views/workouts/WorkoutsDetailPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ useHead({
extended
app
:text="t('Start workout')"
style="bottom: 56px"
></v-fab>
</v-fab-transition>
</div>
Expand Down

0 comments on commit 0bdf533

Please sign in to comment.