-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added manufacturers endpoints and types
- Loading branch information
1 parent
e59840b
commit 70cde21
Showing
8 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Address } from './Address' | ||
import { UUID } from './UUID' | ||
|
||
export interface Manufacturer { | ||
id: UUID | ||
name?: string | null | ||
first_name?: string | null | ||
last_name?: string | null | ||
email: string | ||
address: Address | ||
product_ids?: string[] | ||
} | ||
|
||
export type ManufacturerDto = Omit<Manufacturer, 'id'> | ||
|
||
export interface ManufacturerListed { | ||
id: UUID | ||
name?: string | null | ||
first_name?: string | null | ||
last_name?: string | null | ||
email: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { CrudService, ServiceFactory } from '../types/Service' | ||
import { | ||
createDeleteRequest, | ||
createGetListRequest, | ||
createGetOneRequest, | ||
createPatchRequest, | ||
createPostRequest, | ||
} from '../utils/requests' | ||
import { createEntityMetadataService, EntityMetadataService } from './metadata' | ||
import { MetadataParams, PaginationParams, SearchParam } from '../types/DefaultParams' | ||
import { UUID } from '../../../interfaces/UUID' | ||
import { Manufacturer, ManufacturerDto, ManufacturerListed } from '../../../interfaces' | ||
|
||
interface ManufacturersListParams extends SearchParam, PaginationParams, MetadataParams { | ||
search?: string | ||
email?: string | ||
name?: string | ||
ids?: UUID[] | ||
} | ||
|
||
export type ManufacturersService = CrudService< | ||
Manufacturer, | ||
ManufacturerListed, | ||
ManufacturerDto, | ||
ManufacturerDto, | ||
ManufacturersListParams | ||
> & | ||
EntityMetadataService | ||
|
||
export const createManufacturersService: ServiceFactory<ManufacturersService> = (axios) => { | ||
const route = 'manufacturers' | ||
return { | ||
get: createGetListRequest(axios, route), | ||
getOne: createGetOneRequest(axios, route, { byId: true }), | ||
getOneBySlug: createGetOneRequest(axios, route), | ||
create: createPostRequest(axios, route), | ||
update: createPatchRequest(axios, route), | ||
delete: createDeleteRequest(axios, route), | ||
|
||
...createEntityMetadataService(axios, route), | ||
} | ||
} |