Skip to content

Commit

Permalink
Merge branch 'api-platform:main' into formId-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSuwinski authored Mar 27, 2024
2 parents 95678d7 + 4645fb5 commit 7d62034
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/CreateGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export const IntrospectedCreateGuesser = ({
const response = await create(
resource,
{
data: { ...data, extraInformation: { hasFileField } },
data,
meta: { hasFileField },
},
{ returnPromise: true },
);
Expand Down
7 changes: 2 additions & 5 deletions src/EditGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export const IntrospectedEditGuesser = ({
resource,
{
id,
data: { ...data, extraInformation: { hasFileField } },
data,
meta: { hasFileField },
},
{ returnPromise: true },
);
Expand Down Expand Up @@ -200,10 +201,6 @@ export const IntrospectedEditGuesser = ({
mutationMode={mutationMode}
redirect={redirectTo}
component={viewComponent}
transform={(data: Partial<RaRecord>) => ({
...data,
extraInformation: { hasFileField },
})}
{...props}>
<FormType
id={formId}
Expand Down
12 changes: 6 additions & 6 deletions src/hydra/dataProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ describe('Transform a React Admin request to an Hydra request', () => {
data: {
bar: 'baz',
foo: 'foo',
extraInformation: {
hasFileField: true,
},
},
meta: {
hasFileField: true,
},
});
const url = mockFetchHydra.mock.calls?.[0]?.[0] ?? new URL('https://foo');
Expand Down Expand Up @@ -360,9 +360,9 @@ describe('Transform a React Admin request to an Hydra request', () => {
foo: 'foo',
bar: 'baz',
qux: null,
extraInformation: {
hasFileField: true,
},
},
meta: {
hasFileField: true,
},
previousData: {
id: '/entrypoint/resource/1',
Expand Down
5 changes: 2 additions & 3 deletions src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ function dataProvider(
}
});
let extraInformation: { hasFileField?: boolean } = {};
if ('data' in params && params.data.extraInformation) {
extraInformation = params.data.extraInformation;
delete params.data.extraInformation;
if ('meta' in params) {
extraInformation = params.meta;
}
const updateHttpMethod = extraInformation.hasFileField ? 'POST' : 'PUT';

Expand Down

0 comments on commit 7d62034

Please sign in to comment.