Skip to content

Commit

Permalink
enhancement(EditTier): show default receipt title if none set
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Dec 11, 2024
1 parent 52f2623 commit 07416f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/edit-collective/tiers/EditTierModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ function getTierTypeOptions(intl, collectiveType) {
return [...simplifiedTierTypes, membershipTierType];
}

function getReceiptTemplates(host) {
function getReceiptTemplates(intl, host) {
const receiptTemplates = host?.settings?.invoice?.templates;

const receiptTemplateTitles = [];
if (receiptTemplates?.default) {
receiptTemplateTitles.push({
value: 'default',
label: receiptTemplates.default.title,
label: intl.formatMessage(
{ defaultMessage: '{value} (default)', id: 'OgbGHX' },
{ value: receiptTemplates.default.title },
),
});
}
if (receiptTemplates?.alternative) {
Expand Down Expand Up @@ -102,7 +105,7 @@ function FormFields({ collective, values, hideTypeSelect }) {
},
];

const receiptTemplateOptions = getReceiptTemplates(collective.host);
const receiptTemplateOptions = getReceiptTemplates(intl, collective.host);

const taxes = getApplicableTaxes(collective, collective.host, values.type);

Expand Down Expand Up @@ -520,7 +523,7 @@ function FormFields({ collective, values, hideTypeSelect }) {
onChange={({ value }) => form.setFieldValue(field.name, value)}
isLoading={loading}
options={receiptTemplateOptions}
value={receiptTemplateOptions.find(option => option.value === field.value)}
value={receiptTemplateOptions.find(option => option.value === (field.value ?? 'default'))}
/>
)}
</StyledInputFormikField>
Expand Down

0 comments on commit 07416f5

Please sign in to comment.