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>>(
|
const handleClickSave = useCallback<SubmitHandler<StylePresetFormData>>(
|
||||||
async (data) => {
|
async (data) => {
|
||||||
const payload = {
|
const payload = {
|
||||||
name: data.name,
|
data: {
|
||||||
positive_prompt: data.positivePrompt,
|
name: data.name,
|
||||||
negative_prompt: data.negativePrompt,
|
positive_prompt: data.positivePrompt,
|
||||||
|
negative_prompt: data.negativePrompt,
|
||||||
|
},
|
||||||
image: data.image,
|
image: data.image,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ import {
|
|||||||
} from '@invoke-ai/ui-library';
|
} from '@invoke-ai/ui-library';
|
||||||
import { useStore } from '@nanostores/react';
|
import { useStore } from '@nanostores/react';
|
||||||
import { convertImageUrlToBlob } from 'common/util/convertImageUrlToBlob';
|
import { convertImageUrlToBlob } from 'common/util/convertImageUrlToBlob';
|
||||||
|
import type { PrefilledFormData } from 'features/stylePresets/store/stylePresetModal';
|
||||||
import { $stylePresetModalState } 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 { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ const initialState: StylePresetModalState = {
|
|||||||
*/
|
*/
|
||||||
export const $stylePresetModalState = atom<StylePresetModalState>(initialState);
|
export const $stylePresetModalState = atom<StylePresetModalState>(initialState);
|
||||||
|
|
||||||
export type StylePresetModalState = {
|
type StylePresetModalState = {
|
||||||
isModalOpen: boolean;
|
isModalOpen: boolean;
|
||||||
updatingStylePresetId: string | null;
|
updatingStylePresetId: string | null;
|
||||||
prefilledFormData: PrefilledFormData | 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 = {
|
export type StylePresetState = {
|
||||||
activeStylePresetId: string | null;
|
activeStylePresetId: string | null;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
|
@ -37,15 +37,15 @@ export const stylePresetsApi = api.injectEndpoints({
|
|||||||
}),
|
}),
|
||||||
createStylePreset: build.mutation<
|
createStylePreset: build.mutation<
|
||||||
paths['/api/v1/style_presets/']['post']['responses']['200']['content']['application/json'],
|
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();
|
const formData = new FormData();
|
||||||
if (image) {
|
if (image) {
|
||||||
formData.append('image', image);
|
formData.append('image', image);
|
||||||
}
|
}
|
||||||
|
|
||||||
formData.append('data', JSON.stringify({ name, positive_prompt, negative_prompt }));
|
formData.append('data', JSON.stringify(data));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: buildStylePresetsUrl(),
|
url: buildStylePresetsUrl(),
|
||||||
@ -60,16 +60,14 @@ export const stylePresetsApi = api.injectEndpoints({
|
|||||||
}),
|
}),
|
||||||
updateStylePreset: build.mutation<
|
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']['responses']['200']['content']['application/json'],
|
||||||
paths['/api/v1/style_presets/i/{style_preset_id}']['patch']['requestBody']['content']['multipart/form-data'] & {
|
{ data: { name: string; positive_prompt: string; negative_prompt: string }; image: Blob | null; id: string }
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
>({
|
>({
|
||||||
query: ({ id, name, positive_prompt, negative_prompt, image }) => {
|
query: ({ id, data, image }) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (image) {
|
if (image) {
|
||||||
formData.append('image', image);
|
formData.append('image', image);
|
||||||
}
|
}
|
||||||
formData.append('data', JSON.stringify({ name, positive_prompt, negative_prompt }));
|
formData.append('data', JSON.stringify(data));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: buildStylePresetsUrl(`i/${id}`),
|
url: buildStylePresetsUrl(`i/${id}`),
|
||||||
|
Loading…
Reference in New Issue
Block a user