Merge branch 'dev' into 'staging'
Dev See merge request frontend/admin!64
This commit is contained in:
commit
5a31cb5fde
@ -8,6 +8,7 @@ export type CreatePromocodeBody = {
|
|||||||
privilege: {
|
privilege: {
|
||||||
privilegeID: string;
|
privilegeID: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
|
serviceKey: string;
|
||||||
};
|
};
|
||||||
discount: {
|
discount: {
|
||||||
layer: number;
|
layer: number;
|
||||||
|
@ -36,6 +36,14 @@ type FormValues = {
|
|||||||
factor: number;
|
factor: number;
|
||||||
target: string;
|
target: string;
|
||||||
threshold: number;
|
threshold: number;
|
||||||
|
serviceKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SelectChangeProps = {
|
||||||
|
target: {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialValues: FormValues = {
|
const initialValues: FormValues = {
|
||||||
@ -50,6 +58,7 @@ const initialValues: FormValues = {
|
|||||||
factor: 0,
|
factor: 0,
|
||||||
target: "",
|
target: "",
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
|
serviceKey: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -79,7 +88,11 @@ export const CreatePromocodeForm = ({ createPromocode }: Props) => {
|
|||||||
dueTo: body.dueTo,
|
dueTo: body.dueTo,
|
||||||
activationCount: body.activationCount,
|
activationCount: body.activationCount,
|
||||||
bonus: {
|
bonus: {
|
||||||
privilege: { privilegeID: body.privilegeId, amount: body.amount },
|
privilege: {
|
||||||
|
privilegeID: body.privilegeId,
|
||||||
|
amount: body.amount,
|
||||||
|
serviceKey: body.serviceKey,
|
||||||
|
},
|
||||||
discount: {
|
discount: {
|
||||||
layer: body.layer,
|
layer: body.layer,
|
||||||
factor: factorFromDiscountValue,
|
factor: factorFromDiscountValue,
|
||||||
@ -230,6 +243,20 @@ export const CreatePromocodeForm = ({ createPromocode }: Props) => {
|
|||||||
name="target"
|
name="target"
|
||||||
as={Select}
|
as={Select}
|
||||||
label={values.layer === 1 ? "Привилегия" : "Сервис"}
|
label={values.layer === 1 ? "Привилегия" : "Сервис"}
|
||||||
|
onChange={({ target }: SelectChangeProps) => {
|
||||||
|
if (values.layer === 1) {
|
||||||
|
const currentPrivilege = privileges.find(
|
||||||
|
(item) => item.privilegeId === target.value
|
||||||
|
);
|
||||||
|
|
||||||
|
setFieldValue("serviceKey", currentPrivilege?.serviceKey);
|
||||||
|
setFieldValue("privilegeId", currentPrivilege?.privilegeId);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFieldValue("privilegeId", target.value);
|
||||||
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
border: "2px solid",
|
border: "2px solid",
|
||||||
@ -240,6 +267,7 @@ export const CreatePromocodeForm = ({ createPromocode }: Props) => {
|
|||||||
},
|
},
|
||||||
".MuiSvgIcon-root ": { fill: theme.palette.secondary.main },
|
".MuiSvgIcon-root ": { fill: theme.palette.secondary.main },
|
||||||
}}
|
}}
|
||||||
|
value={values.privilegeId}
|
||||||
children={
|
children={
|
||||||
values.layer === 1
|
values.layer === 1
|
||||||
? privileges.map(({ name, privilegeId }) => (
|
? privileges.map(({ name, privilegeId }) => (
|
||||||
|
Loading…
Reference in New Issue
Block a user