Subscriptions v2

This commit is contained in:
David Bomba 2022-12-09 16:50:48 +11:00
parent be2d6afc63
commit 1ca6810132
3 changed files with 40 additions and 41 deletions

View File

@ -222,24 +222,16 @@ class BillingPortalPurchasev2 extends Component
} }
public function updatedLogin()
public function handleLogin($log)
{ {
nlog($this->login); nlog($log);
} }
public function handleLogin()
{
nlog($this->all());
nlog($this->login);
nlog($this->otp);
nlog($this->value);
}
public function handleEmail() public function handleEmail()
{ {
$this->validateOnly('email', ['email' => 'required|bail|email:rfc']); $this->validateOnly('email', ['email' => 'required|bail|email:rfc']);
$rand = rand(100000,999999); $rand = rand(100000,999999);
$email_hash = "{$this->email}:" . $rand; $email_hash = "{$this->email}:" . $rand;

View File

@ -145,8 +145,6 @@ class UpdateReminder extends AbstractService
$reminder_date = $this->addTimeInterval($this->invoice->last_sent_date, (int) $this->settings->endless_reminder_frequency_id); $reminder_date = $this->addTimeInterval($this->invoice->last_sent_date, (int) $this->settings->endless_reminder_frequency_id);
if ($reminder_date) { if ($reminder_date) {
// $reminder_date->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date))) { if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date))) {
$date_collection->push($reminder_date); $date_collection->push($reminder_date);
} }

View File

@ -258,8 +258,10 @@
</form> </form>
@endif @endif
@if($email && !$errors->has('email'))
<div class="py-6 px-6 w-80 border mx-auto text-center my-6"> <div class="py-6 px-6 w-80 border mx-auto text-center my-6">
<form wire:submit.prevent="handleLogin" action="#" class="" x-data="otpForm()"> <form wire:submit.prevent="handleLogin" class="" x-data="otpForm()">
<p class="mb-4">Enter the code we emailed</p>
<div class="flex justify-between"> <div class="flex justify-between">
<template x-for="(input, index) in length" :key="index"> <template x-for="(input, index) in length" :key="index">
<input <input
@ -273,31 +275,27 @@
/> />
</template> </template>
</div> </div>
<input type="hidden" wire:model.defer="login" x-model="value" x-data="value"> <button x-on:click="buttonDisabled = true" x-bind:disabled="buttonDisabled" class="btn-primary mx-auto block bg-gray-500 w-full p-2 mt-2 text-white">
<button type="submit" class="btn-primary mx-auto block bg-gray-500 w-full p-2 mt-2 text-white"> {{ ctrans('texts.verify') }}
{{ ctrans('texts.login') }}
</button> </button>
<p class="absolute bottom-0" x-text="`value: ${value}`"></p>
</form> </form>
</div> </div>
@endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<script> <script>
function otpForm() { function otpForm() {
return { return {
length: 6, length: 6,
value: "", login: "",
buttonDisabled: true,
handleInput(e) { handleInput(e) {
const input = e.target; const input = e.target;
this.value = Array.from(Array(this.length), (element, i) => { this.login = Array.from(Array(this.length), (element, i) => {
return this.$refs[i].value || ""; return this.$refs[i].value || "";
}).join(""); }).join("");
@ -305,6 +303,15 @@
input.nextElementSibling.focus(); input.nextElementSibling.focus();
input.nextElementSibling.select(); input.nextElementSibling.select();
} }
if(this.login.length == 6){
this.$wire.handleLogin(this.login);
this.buttonDisabled = false;
}
else{
this.buttonDisabled = true;
}
}, },
handlePaste(e) { handlePaste(e) {
@ -325,3 +332,5 @@
}; };
} }
</script> </script>
</div>