mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-24 07:41:47 +00:00
Resolve the remaining client type errors and the trip.title navbar bug
Drive the client typecheck to zero without any/ts-ignore: convert the tripId route param to a number once at the page boundary so it matches the numeric props and store actions it feeds, fix trip.name -> trip.title (the wire field is title, so the old read rendered blank in the files/offline views), and tighten the scattered handler-arity, DOM-cast and untyped-payload sites. No runtime behaviour change.
This commit is contained in:
@@ -61,8 +61,8 @@ export interface TripStoreState
|
||||
loadTrip: (tripId: number | string) => Promise<void>
|
||||
refreshDays: (tripId: number | string) => Promise<void>
|
||||
updateTrip: (tripId: number | string, data: Partial<Trip>) => Promise<Trip>
|
||||
addTag: (data: Partial<Tag>) => Promise<Tag>
|
||||
addCategory: (data: Partial<Category>) => Promise<Category>
|
||||
addTag: (data: Partial<Tag> & { name: string }) => Promise<Tag>
|
||||
addCategory: (data: Partial<Category> & { name: string }) => Promise<Category>
|
||||
}
|
||||
|
||||
export const useTripStore = create<TripStoreState>((set, get) => ({
|
||||
@@ -162,7 +162,7 @@ export const useTripStore = create<TripStoreState>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
addTag: async (data: Partial<Tag>) => {
|
||||
addTag: async (data: Partial<Tag> & { name: string }) => {
|
||||
try {
|
||||
const result = await tagsApi.create(data)
|
||||
set((state) => ({ tags: [...state.tags, result.tag] }))
|
||||
@@ -172,7 +172,7 @@ export const useTripStore = create<TripStoreState>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
addCategory: async (data: Partial<Category>) => {
|
||||
addCategory: async (data: Partial<Category> & { name: string }) => {
|
||||
try {
|
||||
const result = await categoriesApi.create(data)
|
||||
set((state) => ({ categories: [...state.categories, result.category] }))
|
||||
|
||||
Reference in New Issue
Block a user