Skip to content

Commit

Permalink
Archetype form, use null instead of undefined
Browse files Browse the repository at this point in the history
Signed-off-by: Scott J Dickerson <sdickers@redhat.com>
  • Loading branch information
sjd78 committed Sep 11, 2023
1 parent f634db9 commit 684136b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions client/src/app/pages/archetypes/archetypes-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ const Archetypes: React.FC = () => {
const [openCreateArchetype, setOpenCreateArchetype] =
useState<boolean>(false);

const [archetypeToEdit, setArchetypeToEdit] = useState<Archetype>();
const [archetypeToEdit, setArchetypeToEdit] = useState<Archetype | null>(
null
);

const { archetypes, isFetching, error: fetchError } = useFetchArchetypes();

Expand Down Expand Up @@ -292,12 +294,12 @@ const Archetypes: React.FC = () => {
title={t("dialog.title.updateArchetype")}
variant="medium"
isOpen={!!archetypeToEdit}
onClose={() => setArchetypeToEdit(undefined)}
onClose={() => setArchetypeToEdit(null)}
>
<ArchetypeForm
key={archetypeToEdit?.id ?? -1}
toEdit={archetypeToEdit}
onClose={() => setArchetypeToEdit(undefined)}
onClose={() => setArchetypeToEdit(null)}
/>
</Modal>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ interface ArchetypeFormValues {
}

export interface ArchetypeFormProps {
toEdit?: Archetype;
toEdit: Archetype | null;
onClose: () => void;
}

export const ArchetypeForm: React.FC<ArchetypeFormProps> = ({
toEdit = undefined,
toEdit = null,
onClose,
}) => {
const isCreate = toEdit === undefined;
const isCreate = toEdit === null;
const { t } = useTranslation();

const {
archetype,
archetype, // TODO: Use this or just rely on `toEdit`?
existingArchetypes,
tags,
createArchetype,
Expand Down

0 comments on commit 684136b

Please sign in to comment.