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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 11 deletions

View file

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

View file

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

View file

@ -5,7 +5,7 @@ import * as yup from "yup";
import Mousetrap from "mousetrap";
import { Icon, StudioSelect, DetailsEditNavbar } from "src/components/Shared";
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 { useFormik } from "formik";
import { Prompt } from "react-router-dom";
@ -74,6 +74,7 @@ export const StudioEditPanel: React.FC<IStudioEditPanel> = ({
function getStudioInput(values: InputValues) {
const input: Partial<GQL.StudioCreateInput | GQL.StudioUpdateInput> = {
...values,
stash_ids: getStashIDs(values.stash_ids),
};
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 downloadFile } from "./download";
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,
}));