Adding a ton of stuff

This commit is contained in:
2026-07-17 04:39:18 -07:00
parent 8d9fe8e75d
commit de28a67417
63 changed files with 2027 additions and 613 deletions
+32
View File
@@ -0,0 +1,32 @@
import http from "@/api/http-client"
/** Keep in sync with api/src/models/user-preference.ts */
export enum PreferenceKeys {
FLASHCARDS_DAY_STREAK = "flashcards.day_streak",
}
export type PreferenceValueMap = {
[PreferenceKeys.FLASHCARDS_DAY_STREAK]: number
}
export type Preference = {
key: PreferenceKeys
value: unknown | null
}
export type PreferenceAsShow = Preference
export const preferencesApi = {
async upsert<K extends PreferenceKeys>(
userId: number,
key: K,
value: PreferenceValueMap[K] | null
): Promise<{ message: string }> {
const { data } = await http.patch(`/api/users/${userId}/preferences/${key}`, {
value,
})
return data
},
}
export default preferencesApi