You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
import React, {useState} from "react"; |
|
import { connect } from "react-redux"; |
|
import { userFactor } from "../../../redux/actions"; |
|
|
|
function Code({ codeId, setCodeId, userId, factorId }) { |
|
const [value, setValue] = React.useState(codeId || ""); |
|
|
|
const setOff = () => { |
|
setCodeId({ offCodeValue: value, userId: userId, id: factorId }); |
|
} |
|
|
|
return ( |
|
<form className="flex w-full flex-row border border-blueC0 border-solid rounded-md mt-3 mb-4 overflow-hidden lg:w-2/5 lg:mt-5"> |
|
<input |
|
type="text" |
|
className="border-0 flex-1 text-right pr-3 font-medium text-tiny dark:bg-gray2077 placeholder:text-blue5F dark:text-white outline-none lg:text-base lg:font-bold" |
|
placeholder={"کد تخفیف دارید ؟"} |
|
/> |
|
<button className={"py-3 px-4 lg:py-4 text-tiny bg-blueC0 text-white border border-blueC0 border-solid lg:font-bold"} onClick={setOff}>ثبت کد</button> |
|
</form> |
|
); |
|
} |
|
|
|
const mapStateToProps = (state) => ({ |
|
codeId: state.userFactor.info?.codeId, |
|
userId: state.user.status.id, |
|
factorId: state.userFactor.info?.id, |
|
}); |
|
|
|
const mapDispatchToProps = { |
|
setCodeId: userFactor.update, |
|
} |
|
|
|
export default connect( |
|
mapStateToProps, |
|
mapDispatchToProps |
|
)(Code); |