feature: add necessary shadcn components for CategoryFilter and Sidebar
This commit is contained in:
21
src/shared/types/collection.ts
Normal file
21
src/shared/types/collection.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Generic collection API response model
|
||||
* Use this for APIs that return collections of items
|
||||
*
|
||||
* @template T - The type of items in the collection array
|
||||
* @template K - The key used to access the collection array in the response
|
||||
*/
|
||||
export type CollectionApiModel<T, K extends string = 'items'> = Record<K, T[]> & {
|
||||
/**
|
||||
* Number of items returned in the current page/response
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Total number of items available across all pages
|
||||
*/
|
||||
count_total: number;
|
||||
/**
|
||||
* Indicates if there are more items available beyond this page
|
||||
*/
|
||||
has_more: boolean;
|
||||
};
|
||||
37
src/shared/types/common.ts
Normal file
37
src/shared/types/common.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Model of response with error
|
||||
*/
|
||||
export interface ApiErrorResponse {
|
||||
/**
|
||||
* Error text
|
||||
*/
|
||||
error: string;
|
||||
/**
|
||||
* Status
|
||||
*/
|
||||
status: number;
|
||||
/**
|
||||
* Status text
|
||||
*/
|
||||
statusText: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model of response with success
|
||||
*/
|
||||
export interface ApiSuccessResponse<T> {
|
||||
/**
|
||||
* Data
|
||||
*/
|
||||
data: T;
|
||||
/**
|
||||
* Status
|
||||
*/
|
||||
status: number;
|
||||
/**
|
||||
* Status text
|
||||
*/
|
||||
statusText: string;
|
||||
}
|
||||
|
||||
export type ApiResponse<T> = ApiErrorResponse | ApiSuccessResponse<T>;
|
||||
Reference in New Issue
Block a user