-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
307 additions
and
85 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ dist-ssr | |
*.sw? | ||
|
||
node/ | ||
|
||
tsconfig.tsbuildinfo |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export const OWNERS = "owners"; | ||
export const PETS = "pets"; | ||
export const PET_TYPES = "pettypes"; |
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
17 changes: 17 additions & 0 deletions
17
spring-petclinic-reactjs-client/src/data-providers/index.ts
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,17 @@ | ||
import { combineDataProviders } from "react-admin"; | ||
import { OWNERS, PET_TYPES } from "@constants/resources"; | ||
import ownersDataProvider from "./ownersDataProvider"; | ||
import petTypesDataProvider from "./petTypesDataProvider"; | ||
|
||
const dataProviders = combineDataProviders((resource) => { | ||
switch (resource) { | ||
case OWNERS: | ||
return ownersDataProvider; | ||
case PET_TYPES: | ||
return petTypesDataProvider; | ||
default: | ||
throw new Error(`Unknown resource: ${resource}`); | ||
} | ||
}); | ||
|
||
export default dataProviders; |
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
25 changes: 25 additions & 0 deletions
25
spring-petclinic-reactjs-client/src/data-providers/petTypesDataProvider.ts
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,25 @@ | ||
import { CreateResult, DataProvider, fetchUtils, UpdateResult, DeleteResult, GetOneResult } from "react-admin"; | ||
|
||
const apiUrl = import.meta.env.VITE_SPRING_PETCLINIC_REST_API_URL; | ||
|
||
const httpClient = fetchUtils.fetchJson; | ||
|
||
export default { | ||
create: async () => Promise.resolve<CreateResult>({ data: null }), | ||
delete: () => Promise.resolve<DeleteResult>({ data: null }), | ||
deleteMany: () => Promise.resolve({ data: [] }), | ||
getList: async (resource, { signal }) => { | ||
const url = new URL(`${apiUrl}/${resource}`); | ||
|
||
const { json } = await httpClient(url, { signal }); | ||
return { | ||
data: json, | ||
total: json ? json.length : 0 | ||
}; | ||
}, | ||
getMany: () => Promise.resolve({ data: [] }), | ||
getManyReference: () => Promise.resolve({ data: [], total: 0 }), | ||
getOne: () => Promise.resolve<GetOneResult>({ data: null }), | ||
update: () => Promise.resolve<UpdateResult>({ data: null }), | ||
updateMany: () => Promise.resolve({ data: [] }) | ||
} as DataProvider; |
9 changes: 9 additions & 0 deletions
9
spring-petclinic-reactjs-client/src/models/api/CreateOrEditOwnerPetData.ts
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,9 @@ | ||
import { IApiPetType } from "@models/api/IApiPetType"; | ||
import { PetFormSchema } from "@models/form/PetFormSchema"; | ||
import { EPetForm } from "@models/enums/EPetForm"; | ||
import { CreateParams } from "react-admin"; | ||
|
||
export interface CreateOrEditOwnerPetData extends CreateParams { | ||
meta: { ownerId: number }; | ||
data: Omit<PetFormSchema, EPetForm.PET_TYPE> & { petId?: number; type: IApiPetType }; | ||
} |
7 changes: 7 additions & 0 deletions
7
spring-petclinic-reactjs-client/src/models/api/GetOwnerPetByIdParams.ts
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,7 @@ | ||
import { GetOneParams } from "react-admin"; | ||
|
||
export interface GetOwnerPetByIdParams extends GetOneParams { | ||
meta: { | ||
petId: number; | ||
}; | ||
} |
2 changes: 1 addition & 1 deletion
2
...js-client/src/models/api/GetListParams.ts → ...ent/src/models/api/GetOwnersListParams.ts
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface GetListParams { | ||
export interface GetOwnersListParams { | ||
filter?: { | ||
lastName: string; | ||
}; | ||
|
16 changes: 3 additions & 13 deletions
16
spring-petclinic-reactjs-client/src/models/api/IApiOwner.ts
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 |
---|---|---|
@@ -1,21 +1,11 @@ | ||
import { IApiPet } from "@models/api/IApiPet"; | ||
|
||
export interface IApiOwner { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
address: string; | ||
city: string; | ||
telephone: string; | ||
pets: [ | ||
{ | ||
id: number; | ||
ownerId: number; | ||
name: string; | ||
birthDate: string; | ||
visits: []; | ||
type: { | ||
id: number; | ||
name: string; | ||
}; | ||
} | ||
]; | ||
pets: IApiPet[]; | ||
} |
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,10 @@ | ||
import { IApiPetType } from "@models/api/IApiPetType"; | ||
|
||
export interface IApiPet { | ||
id: number; | ||
ownerId: number; | ||
name: string; | ||
birthDate: string; | ||
visits: []; | ||
type: IApiPetType; | ||
} |
4 changes: 4 additions & 0 deletions
4
spring-petclinic-reactjs-client/src/models/api/IApiPetType.ts
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,4 @@ | ||
export interface IApiPetType { | ||
id: number; | ||
name: string; | ||
} |
10 changes: 10 additions & 0 deletions
10
spring-petclinic-reactjs-client/src/models/api/OwnersDataProvider.ts
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,10 @@ | ||
import { DataProvider, GetOneResult } from "react-admin"; | ||
import { CreateOrEditOwnerPetData } from "@models/api/CreateOrEditOwnerPetData.ts"; | ||
import { GetOwnerPetByIdParams } from "@models/api/GetOwnerPetByIdParams.ts"; | ||
import { IApiPet } from "@models/api/IApiPet"; | ||
|
||
export interface OwnersDataProvider extends DataProvider { | ||
createPet: (resource: string, params: CreateOrEditOwnerPetData) => Promise<GetOneResult<IApiPet>>; | ||
getPet: (resource: string, params: GetOwnerPetByIdParams) => Promise<GetOneResult<IApiPet>>; | ||
editPet: (resource: string, params: CreateOrEditOwnerPetData) => Promise<GetOneResult<IApiPet>>; | ||
} |
File renamed without changes.
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,5 @@ | ||
export enum EPetForm { | ||
NAME = "name", | ||
BIRTH_DATE = "birthDate", | ||
PET_TYPE = "type" | ||
} |
2 changes: 1 addition & 1 deletion
2
spring-petclinic-reactjs-client/src/models/form/OwnerFormSchema.ts
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
7 changes: 7 additions & 0 deletions
7
spring-petclinic-reactjs-client/src/models/form/PetFormSchema.ts
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,7 @@ | ||
import { EPetForm } from "@models/enums/EPetForm"; | ||
|
||
export type PetFormSchema = { | ||
[EPetForm.NAME]: string; | ||
[EPetForm.BIRTH_DATE]: Date; | ||
[EPetForm.PET_TYPE]: number; | ||
}; |
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
Oops, something went wrong.