mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix payloads for stringified data
This commit is contained in:
parent
9c732ac3b1
commit
6a01fce9c1
@ -43,9 +43,11 @@ export const StylePresetForm = ({
|
||||
const handleClickSave = useCallback<SubmitHandler<StylePresetFormData>>(
|
||||
async (data) => {
|
||||
const payload = {
|
||||
name: data.name,
|
||||
positive_prompt: data.positivePrompt,
|
||||
negative_prompt: data.negativePrompt,
|
||||
data: {
|
||||
name: data.name,
|
||||
positive_prompt: data.positivePrompt,
|
||||
negative_prompt: data.negativePrompt,
|
||||
},
|
||||
image: data.image,
|
||||
};
|
||||
|
||||
|
@ -10,8 +10,8 @@ import {
|
||||
} from '@invoke-ai/ui-library';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { convertImageUrlToBlob } from 'common/util/convertImageUrlToBlob';
|
||||
import type { PrefilledFormData } from 'features/stylePresets/store/stylePresetModal';
|
||||
import { $stylePresetModalState } from 'features/stylePresets/store/stylePresetModal';
|
||||
import type { PrefilledFormData } from 'features/stylePresets/store/types';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
|
@ -11,7 +11,7 @@ const initialState: StylePresetModalState = {
|
||||
*/
|
||||
export const $stylePresetModalState = atom<StylePresetModalState>(initialState);
|
||||
|
||||
export type StylePresetModalState = {
|
||||
type StylePresetModalState = {
|
||||
isModalOpen: boolean;
|
||||
updatingStylePresetId: string | null;
|
||||
prefilledFormData: PrefilledFormData | null;
|
||||
|
@ -1,16 +1,3 @@
|
||||
export type StylePresetModalState = {
|
||||
isModalOpen: boolean;
|
||||
updatingStylePresetId: string | null;
|
||||
prefilledFormData: PrefilledFormData | null;
|
||||
};
|
||||
|
||||
export type PrefilledFormData = {
|
||||
name: string;
|
||||
positivePrompt: string;
|
||||
negativePrompt: string;
|
||||
imageUrl: string | null;
|
||||
};
|
||||
|
||||
export type StylePresetState = {
|
||||
activeStylePresetId: string | null;
|
||||
searchTerm: string;
|
||||
|
@ -37,15 +37,15 @@ export const stylePresetsApi = api.injectEndpoints({
|
||||
}),
|
||||
createStylePreset: build.mutation<
|
||||
paths['/api/v1/style_presets/']['post']['responses']['200']['content']['application/json'],
|
||||
paths['/api/v1/style_presets/']['post']['requestBody']['content']['multipart/form-data']
|
||||
{ data: { name: string; positive_prompt: string; negative_prompt: string }; image: Blob | null }
|
||||
>({
|
||||
query: ({ name, positive_prompt, negative_prompt, image }) => {
|
||||
query: ({ data, image }) => {
|
||||
const formData = new FormData();
|
||||
if (image) {
|
||||
formData.append('image', image);
|
||||
}
|
||||
|
||||
formData.append('data', JSON.stringify({ name, positive_prompt, negative_prompt }));
|
||||
formData.append('data', JSON.stringify(data));
|
||||
|
||||
return {
|
||||
url: buildStylePresetsUrl(),
|
||||
@ -60,16 +60,14 @@ export const stylePresetsApi = api.injectEndpoints({
|
||||
}),
|
||||
updateStylePreset: build.mutation<
|
||||
paths['/api/v1/style_presets/i/{style_preset_id}']['patch']['responses']['200']['content']['application/json'],
|
||||
paths['/api/v1/style_presets/i/{style_preset_id}']['patch']['requestBody']['content']['multipart/form-data'] & {
|
||||
id: string;
|
||||
}
|
||||
{ data: { name: string; positive_prompt: string; negative_prompt: string }; image: Blob | null; id: string }
|
||||
>({
|
||||
query: ({ id, name, positive_prompt, negative_prompt, image }) => {
|
||||
query: ({ id, data, image }) => {
|
||||
const formData = new FormData();
|
||||
if (image) {
|
||||
formData.append('image', image);
|
||||
}
|
||||
formData.append('data', JSON.stringify({ name, positive_prompt, negative_prompt }));
|
||||
formData.append('data', JSON.stringify(data));
|
||||
|
||||
return {
|
||||
url: buildStylePresetsUrl(`i/${id}`),
|
||||
|
Loading…
Reference in New Issue
Block a user