feat: Enhance EditRedemption component with default name handling
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
showError,
|
showError,
|
||||||
showSuccess,
|
showSuccess,
|
||||||
} from '../../helpers';
|
} from '../../helpers';
|
||||||
import { renderQuotaWithPrompt } from '../../helpers/render';
|
import { getQuotaPerUnit, renderQuota, renderQuotaWithPrompt } from '../../helpers/render';
|
||||||
import {
|
import {
|
||||||
AutoComplete,
|
AutoComplete,
|
||||||
Button,
|
Button,
|
||||||
@@ -66,11 +66,16 @@ const EditRedemption = (props) => {
|
|||||||
}, [props.editingRedemption.id]);
|
}, [props.editingRedemption.id]);
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (!isEdit && inputs.name === '') return;
|
let name = inputs.name;
|
||||||
|
if (!isEdit && inputs.name === '') {
|
||||||
|
// set default name
|
||||||
|
name = '兑换码-' + renderQuota(quota);
|
||||||
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
let localInputs = inputs;
|
let localInputs = inputs;
|
||||||
localInputs.count = parseInt(localInputs.count);
|
localInputs.count = parseInt(localInputs.count);
|
||||||
localInputs.quota = parseInt(localInputs.quota);
|
localInputs.quota = parseInt(localInputs.quota);
|
||||||
|
localInputs.name = name;
|
||||||
let res;
|
let res;
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
res = await API.put(`/api/redemption/`, {
|
res = await API.put(`/api/redemption/`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user