{% extends 'base/module.twig' %}

{% block content %}

	<div class="container-fluid">
		<div v-show="tabs[0].active">
			<div class="row">
				<div class="col-xs-12">
					<div
						class="row">
						{# DEFAULT CONTENT #}
						<div class="col-xs-12 col-sm-8">
							<base-card class="padding-large">
								<div class="bottom-margin-large">
									<span v-text="text_info"></span>
								</div>
								{# CNPJ VERIFICATION #}
								<validation-provider class="flex between-xs" style="align-items: end" tag="div" rules="required|cnpj" name="pixpdv_cnpj" ref="provider" v-slot="{ errors, valid }">
									<base-input style="width: 100%" :label="text_cnpj" name="pixpdv_cnpj" mask="cnpj" v-model="configurations.pixpdv_account_info.cnpj" required :error="errors[0]" :valid="valid"></base-input>
								</validation-provider>
								<div
									class="top-margin-large">
									{# TOKEN #}
									<validation-provider tag="div" rules="required" name="pixpdv_token" v-slot="{ errors, valid }">
										<base-input class="bottom-margin-medium" :label="text_token" v-model="configurations.pixpdv_account_info.token" required :error="errors[0]" :valid="valid"></base-input>
									</validation-provider>
									{# SECRET #}
									<validation-provider tag="div" rules="required" name="pixpdv_secret" v-slot="{ errors, valid }">
										<base-input class="bottom-margin-medium" :label="text_secret" v-model="configurations.pixpdv_account_info.secret" required :error="errors[0]" :valid="valid"></base-input>
									</validation-provider>			
								</div>
							</base-card>
						</div>

						{# SIDE OPTIONS #}
						<div class="col-xs-12 col-sm-4 last-sm first-xs">
							<base-card class="padding-large">
								<validation-provider tag="div" rules="required" name="pixpdv_status" v-slot="{ errors, valid }">
									<base-select :label="text_status" name="pixpdv_status" v-model="configurations.pixpdv_status" :error="errors[0]" :valid="valid">
										<option v-for="(value, key) in Type_Status" :key="key" :value="key">
											{ value }
										</option>
									</base-select>
								</validation-provider>

								<validation-provider tag="div" class="top-margin-large" name="pixpdv_order" v-slot="{ errors, valid }">
									<base-input :label="text_order" name="pixpdv_order" maxlength="2" v-model="configurations.pixpdv_order" mask="integer" :error="errors[0]" :valid="valid"></base-input>
								</validation-provider>

								<validation-provider
									tag="div"
									rules="required"
									class="top-margin-large"
									name="pixpdv_api_ambiente"
									v-slot="{ errors, valid }">
									<base-select
										:label="text_environment"
										name="pixpdv_api_ambiente"
										v-model="configurations.pixpdv_api_ambiente"
										:error="errors[0]"
										:valid="valid"
										@change="changeEnvironment(configurations.pixpdv_api_ambiente)">
										<option
										v-for="(value, key) in Type_Environment"
										:key="key"
										:value="key">
										{ value }
										</option>
									</base-select>
								</validation-provider>

								<validation-provider tag="div" class="top-margin-large" name="config_pixpdv_log" rules="" v-slot="{ errors, valid }">
									<base-checkbox :label="entry_pixpdv_log" :description="entry_pixpdv_log_obs" name="config_pixpdv_log" v-model="configurations.config_pixpdv_log" value="1" unchecked-value="0" :disabled="disableForm"></base-checkbox>
								</validation-provider>
							</base-card>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div v-show="tabs[1].active">
			<div class="row">
				<div class="col-xs-12 col-sm-8">
					<base-card class="padding-large">
						<validation-provider tag="div" name="pixpdv_order_status_replicar" v-slot="{ errors, valid }">
							<base-select :label="text_status_replicar" name="pixpdv_order_status_replicar" v-model="configurations.pixpdv_order_status_replicar" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_created" v-slot="{ errors, valid }">
							<base-select :label="text_created_status" name="pixpdv_order_status_created" v-model="configurations.pixpdv_order_status_created" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_open" v-slot="{ errors, valid }">
							<base-select :label="text_open_payment_status" name="pixpdv_order_status_open" v-model="configurations.pixpdv_order_status_open" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_approved" v-slot="{ errors, valid }">
							<base-select :label="text_approved_status" name="pixpdv_order_status_approved" v-model="configurations.pixpdv_order_status_approved" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_partial" v-slot="{ errors, valid }">
							<base-select :label="text_partial_status" name="pixpdv_order_status_partial" v-model="configurations.pixpdv_order_status_partial" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_overfilled" v-slot="{ errors, valid }">
							<base-select :label="text_overfilled_status" name="pixpdv_order_status_overfilled" v-model="configurations.pixpdv_order_status_overfilled" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_rejected" v-slot="{ errors, valid }">
							<base-select :label="text_rejected_status" name="pixpdv_order_status_rejected" v-model="configurations.pixpdv_order_status_rejected" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_canceled" v-slot="{ errors, valid }">
							<base-select :label="text_canceled_status" name="pixpdv_order_status_canceled" v-model="configurations.pixpdv_order_status_canceled" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>

						<validation-provider tag="div" class="top-margin-large" name="pixpdv_order_status_error" v-slot="{ errors, valid }">
							<base-select :label="text_error_status" name="pixpdv_order_status_error" v-model="configurations.pixpdv_order_status_error" :error="errors[0]" :valid="valid">
								<option v-for="(order_status, key) in order_statuses" :key="order_status.order_status_id" :value="order_status.order_status_id">
									{ order_status.name }
								</option>
							</base-select>
						</validation-provider>
					</base-card>
				</div>
			</div>
		</div>

		<div v-show="tabs[2].active">
			<div
				class="row">
				{# CONFIG PIX #}
				<div class="col-xs-12 col-md-8">
					<base-card class="padding-large">
						<span class="text-large text-dark visible-block bottom-margin-medium">{{ text_pix }}</span>

						<validation-provider tag="div" name="pixpdv_title" rules="required" v-slot="{ errors, valid }">
							<base-input :label="text_title" name="pixpdv_title" mask="alphanumeric" maxlength="70" v-model="configurations.pixpdv_pix.title" :error="errors[0]" :valid="valid" required></base-input>
						</validation-provider>

						<validation-provider tag="div" name="pixpdv_expires_at" rules="required|min_value:5" v-slot="{ errors, valid }">
							<base-input class="top-margin-large" name="pixpdv_expires_at" :label="text_expire" :error="errors[0]" maxlength="3" :valid="valid" mask="number" v-model="configurations.pixpdv_pix.expires_at" required></base-input>
						</validation-provider>

						<div class="row small-space-xs bottom-xs top-margin-medium">
							<validation-provider tag="div" class="col-xs" name="pixpdv_valor_minimo" v-slot="{ errors, valid }">
								<base-input :label="text_min_value" name="pixpdv_valor_minimo" v-model="configurations.pixpdv_pix.valor_minimo" mask="brazilCurrency" :error="errors[0]" :valid="valid"></base-input>
							</validation-provider>

							<validation-provider tag="div" class="col-xs" name="pixpdv_pix_desconto" v-slot="{ errors, valid }">
								<base-input :label="text_discount" name="pixpdv_pix_desconto" v-model="configurations.pixpdv_pix.desconto" :mask="configurations.pixpdv_pix.tipo_desconto == 1 ? 'brazilCurrency' : 'percentage'" :error="errors[0]" :valid="valid"></base-input>
							</validation-provider>

							<validation-provider tag="div" class="col-xs" name="pixpdv_pix_tipo_desconto" v-slot="{ errors, valid }">
								<base-select name="pixpdv_pix_tipo_desconto" :label="text_discount_type" v-model="configurations.pixpdv_pix.tipo_desconto" :valid="valid" :error="errors[0]">
									<option v-for="(value, key) in Type_MarketplaceAdjustmentPrice" :key="key" :value="key">
										{ value }
									</option>
								</base-select>
							</validation-provider>
						</div>

					</base-card>
				</div>
			</div>
		</div>
	</div>

{% endblock %}