Fix studio editing (#1668)

This commit is contained in:
InfiniteTF
2021-08-24 03:23:25 +02:00
committed by GitHub
parent 7b3b2ae9ba
commit 0d4ab7f6f3
5 changed files with 12 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ import {
Modal, Modal,
TagSelect, TagSelect,
} from "src/components/Shared"; } from "src/components/Shared";
import { ImageUtils } from "src/utils"; import { ImageUtils, getStashIDs } from "src/utils";
import { getCountryByISO } from "src/utils/country"; import { getCountryByISO } from "src/utils/country";
import { useToast } from "src/hooks"; import { useToast } from "src/hooks";
import { Prompt, useHistory } from "react-router-dom"; import { Prompt, useHistory } from "react-router-dom";
@@ -380,10 +380,7 @@ export const PerformerEditPanel: React.FC<IPerformerDetails> = ({
variables: { variables: {
input: { input: {
...input, ...input,
stash_ids: performerInput?.stash_ids?.map((s) => ({ stash_ids: getStashIDs(performerInput?.stash_ids),
endpoint: s.endpoint,
stash_id: s.stash_id,
})),
}, },
}, },
}); });

View File

@@ -30,7 +30,7 @@ import {
ImageInput, ImageInput,
} from "src/components/Shared"; } from "src/components/Shared";
import { useToast } from "src/hooks"; import { useToast } from "src/hooks";
import { ImageUtils, FormUtils, TextUtils } from "src/utils"; import { ImageUtils, FormUtils, TextUtils, getStashIDs } from "src/utils";
import { MovieSelect } from "src/components/Shared/Select"; import { MovieSelect } from "src/components/Shared/Select";
import { useFormik } from "formik"; import { useFormik } from "formik";
import { Prompt } from "react-router"; import { Prompt } from "react-router";
@@ -110,10 +110,7 @@ export const SceneEditPanel: React.FC<IProps> = ({
}), }),
tag_ids: (scene.tags ?? []).map((t) => t.id), tag_ids: (scene.tags ?? []).map((t) => t.id),
cover_image: undefined, cover_image: undefined,
stash_ids: (scene.stash_ids ?? []).map((s) => ({ stash_ids: getStashIDs(scene.stash_ids),
stash_id: s.stash_id,
endpoint: s.endpoint,
})),
}; };
type InputValues = typeof initialValues; type InputValues = typeof initialValues;

View File

@@ -5,7 +5,7 @@ import * as yup from "yup";
import Mousetrap from "mousetrap"; import Mousetrap from "mousetrap";
import { Icon, StudioSelect, DetailsEditNavbar } from "src/components/Shared"; import { Icon, StudioSelect, DetailsEditNavbar } from "src/components/Shared";
import { Button, Form, Col, Row } from "react-bootstrap"; import { Button, Form, Col, Row } from "react-bootstrap";
import { FormUtils, ImageUtils } from "src/utils"; import { FormUtils, ImageUtils, getStashIDs } from "src/utils";
import { RatingStars } from "src/components/Scenes/SceneDetails/RatingStars"; import { RatingStars } from "src/components/Scenes/SceneDetails/RatingStars";
import { useFormik } from "formik"; import { useFormik } from "formik";
import { Prompt } from "react-router-dom"; import { Prompt } from "react-router-dom";
@@ -74,6 +74,7 @@ export const StudioEditPanel: React.FC<IStudioEditPanel> = ({
function getStudioInput(values: InputValues) { function getStudioInput(values: InputValues) {
const input: Partial<GQL.StudioCreateInput | GQL.StudioUpdateInput> = { const input: Partial<GQL.StudioCreateInput | GQL.StudioUpdateInput> = {
...values, ...values,
stash_ids: getStashIDs(values.stash_ids),
}; };
if (studio && studio.id) { if (studio && studio.id) {

View File

@@ -12,3 +12,4 @@ export { default as getISOCountry } from "./country";
export { default as useFocus } from "./focus"; export { default as useFocus } from "./focus";
export { default as downloadFile } from "./download"; export { default as downloadFile } from "./download";
export * from "./data"; export * from "./data";
export { getStashIDs } from "./stashIds";

View File

@@ -0,0 +1,5 @@
export const getStashIDs = (ids?: { stash_id: string; endpoint: string }[]) =>
(ids ?? []).map(({ stash_id, endpoint }) => ({
stash_id,
endpoint,
}));