Skip to content

Commit

Permalink
fix(idea/frontend): code only and no programs voucher issue (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov authored Jun 10, 2024
1 parent a13e70f commit 1426dd0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ const IssueVoucherModal = ({ programId, close, onSubmit = () => {} }: Props) =>
setPrograms(defaultPrograms);
}, [voucherType, form, defaultPrograms]);

const getProgramIdsToIssue = () => {
if (isCodeVoucher) return [];

return programs.length ? programs : undefined;
};

const handleSubmit = async ({ address, value }: Schema) => {
if (!isApiReady) throw new Error('API is not initialized');

enableLoading();

const isCodeUploadEnabled = voucherType !== VOUCHER_TYPE.PROGRAM;
const programIds = isCodeVoucher ? undefined : programs;

const programIds = getProgramIdsToIssue();
const { extrinsic } = await api.voucher.issue(address, value, Number(duration), programIds, isCodeUploadEnabled);

const onSuccess = () => {
Expand Down

0 comments on commit 1426dd0

Please sign in to comment.