Fixed: fixed bug scrcpy and shell is disconnect when switch page

This commit is contained in:
Kenta420 2024-02-19 14:24:05 +07:00
parent 9543d4541c
commit 0fe469b5c6
43 changed files with 1378 additions and 1366 deletions

View file

@ -0,0 +1,52 @@
import customAxios from '@/lib/customAxios'
import { type RecipeDashboard } from '@/models/recipe/schema'
import { create } from 'zustand'
export interface RecipeDashboardFilterQuery {
countryID: string
filename: string
}
interface materialDashboard {
lebel: string
value: string
}
interface RecipeDashboardHook {
getRecipesDashboard: (filter?: RecipeDashboardFilterQuery) => Promise<RecipeDashboard[] | []>
getMaterials: (filter?: RecipeDashboardFilterQuery) => Promise<materialDashboard[] | []>
}
const useRecipeDashboard = create<RecipeDashboardHook>(() => ({
async getRecipesDashboard(filter) {
return customAxios
.get<RecipeDashboard[]>('/v2/recipes/dashboard', {
params: filter
? {
country_id: filter.countryID,
filename: filter.filename
}
: undefined
})
.then(res => {
return res.data
})
.catch(() => [])
},
async getMaterials(filter) {
return customAxios
.get<materialDashboard[]>('/v2/materials/dashboard', {
params: filter
? {
country_id: filter.countryID,
filename: filter.filename
}
: undefined
})
.then(res => {
return res.data
})
}
}))
export default useRecipeDashboard