Skip to content

Commit

Permalink
Fix update aliases checkbox state for edit updates (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored Jul 12, 2023
1 parent 221da5d commit 2a5cf01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/src/pages/performers/PerformerEditUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const PerformerEditUpdate: FC<{ edit: EditUpdate }> = ({ edit }) => {
<PerformerForm
performer={edit.target}
initial={edit.details}
options={edit.options}
callback={doUpdate}
saving={saving}
/>
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/pages/performers/performerForm/PerformerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
BreastTypeEnum,
EthnicityEnum,
PerformerEditDetailsInput,
PerformerEditOptionsInput,
ValidSiteTypeEnum,
PerformerFragment as Performer,
} from "src/graphql";
Expand Down Expand Up @@ -121,6 +122,7 @@ interface PerformerProps {
id?: string
) => void;
initial?: InitialPerformer;
options?: PerformerEditOptionsInput | null;
saving: boolean;
}

Expand All @@ -129,6 +131,7 @@ const PerformerForm: FC<PerformerProps> = ({
callback,
initial,
saving,
options,
}) => {
const initialAliases = initial?.aliases ?? performer?.aliases ?? [];
const {
Expand Down Expand Up @@ -182,7 +185,7 @@ const PerformerForm: FC<PerformerProps> = ({
});

const [activeTab, setActiveTab] = useState("personal");
const [updateAliases, setUpdateAliases] = useState(false);
const [updateAliases, setUpdateAliases] = useState<boolean>();
const [file, setFile] = useState<File | undefined>();

const fieldData = watch();
Expand All @@ -202,10 +205,6 @@ const PerformerForm: FC<PerformerProps> = ({
newChanges.name !== null &&
performer?.name?.trim() !== newChanges.name;

useEffect(() => {
setUpdateAliases(changedName);
}, [changedName, setUpdateAliases]);

const showBreastType =
fieldData.gender !== GenderEnum.MALE &&
fieldData.gender !== GenderEnum.TRANSGENDER_MALE;
Expand Down Expand Up @@ -263,7 +262,7 @@ const PerformerForm: FC<PerformerProps> = ({
)
performerData.breast_type = BreastTypeEnum.NA;

callback(performerData, data.note, updateAliases, data.id);
callback(performerData, data.note, updateAliases ?? false, data.id);
};

const countryObj = [
Expand Down Expand Up @@ -341,6 +340,7 @@ const PerformerForm: FC<PerformerProps> = ({
<Form.Check
id="update-modify-aliases"
checked={updateAliases}
defaultChecked={options?.set_modify_aliases ?? false}
onChange={() => setUpdateAliases(!updateAliases)}
label="Set unset performance aliases to old name"
className="d-inline-block"
Expand Down

0 comments on commit 2a5cf01

Please sign in to comment.