refactor(types): add TypeScript type assertion for channel API response
All checks were successful
Admin CI / build-and-push-web (push) Successful in 4m53s
All checks were successful
Admin CI / build-and-push-web (push) Successful in 4m53s
Add explicit type casting to handle potential channel data response formats, improving type safety and IDE autocomplete for Channel data structures.
This commit is contained in:
@@ -55,7 +55,7 @@ export default function Channels() {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
const response = await channelsApi.getChannels()
|
const response = await channelsApi.getChannels()
|
||||||
const data = response.data.data
|
const data = response.data.data as Channel[] | { list: Channel[] } | undefined
|
||||||
const list = Array.isArray(data) ? data : (data?.list || [])
|
const list = Array.isArray(data) ? data : (data?.list || [])
|
||||||
list.sort((a: Channel, b: Channel) => a.sort_order - b.sort_order)
|
list.sort((a: Channel, b: Channel) => a.sort_order - b.sort_order)
|
||||||
setChannels(list)
|
setChannels(list)
|
||||||
|
|||||||
Reference in New Issue
Block a user