import * as React from "react"
import { CONSTANTS, STYLES } from "../constants"
import { IFilterUserAdvs } from "../types"
import { startModalAlert } from "../common"

export const FilterUserAdvs: React.FC<IFilterUserAdvs> = props => {
	const { userId, objExchange, getMerchantAdvs, handlerPopupWindow } = props

	const { id, name, shortName } = objExchange

	return (
		<div className="container">
			<div className="row mb-3">
				<div className="input-group input-group-sm col-6">
					<div className="input-group-apSpend">
						<button
							className="btn btn-sm btn-info"
							type="button"
							id="button-getMyOrders"
							disabled={false}
							onClick={() => {
								const requestHeader = ""
								if (requestHeader !== null) {
									const objParamAdvs = {
										userId,
										exchangeId: id,
										exchangeName: name,
										shortName,
										objParams: {
											page: 1,
											rows: 20,
										},
									}
									getMerchantAdvs(objParamAdvs)
								} else {
									handlerPopupWindow(STYLES.WARNING, CONSTANTS.COOKIE_EMPTY)
									startModalAlert()
								}
							}}
						>
							Get Advs
						</button>
					</div>
				</div>
			</div>
		</div>
	)
}
