-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df745ac
commit 5efe046
Showing
3 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
export default { | ||
name: 'AppLoginWithCode', | ||
props: { | ||
connected: null, | ||
}, | ||
data: () => { | ||
return { | ||
phone: '', | ||
submitting: false, | ||
pair_code: null, | ||
}; | ||
}, | ||
methods: { | ||
async openModal() { | ||
try { | ||
$('#modalLoginWithCode').modal({ | ||
onApprove: function() { | ||
return false; | ||
}, | ||
}).modal('show'); | ||
} catch (err) { | ||
showErrorInfo(err); | ||
} | ||
}, | ||
async handleSubmit() { | ||
if (this.submitting) return; | ||
try { | ||
this.submitting = true; | ||
const { response } = await this.submitApi(); | ||
this.pair_code = response.pair_code; | ||
} catch (err) { | ||
showErrorInfo(err); | ||
} finally { | ||
this.submitting = false; | ||
} | ||
}, | ||
|
||
async submitApi() { | ||
try { | ||
return http.get(`/app/login-with-code`, { | ||
params: { | ||
phone: this.phone, | ||
}, | ||
}); | ||
} catch (error) { | ||
if (error.response) { | ||
throw Error(error.response.data.message); | ||
} | ||
throw Error(error.message); | ||
} | ||
|
||
}, | ||
}, | ||
template: ` | ||
<div class="green card" @click="openModal" style="cursor: pointer"> | ||
<div class="content"> | ||
<div class="header">Login with Code</div> | ||
<div class="description"> | ||
Login with pairing code to get access to your devices | ||
</div> | ||
</div> | ||
</div> | ||
<!-- Modal Login --> | ||
<div class="ui small modal" id="modalLoginWithCode"> | ||
<i class="close icon"></i> | ||
<div class="header"> | ||
Getting Pair Code | ||
</div> | ||
<div class="content"> | ||
<div class="ui message info"> | ||
<div class="header">How to pair?</div> | ||
<ol> | ||
<li>Open your Whatsapp</li> | ||
<li>Link a device</li> | ||
<li>Link with pair code</li> | ||
</ol> | ||
</div> | ||
<div class="ui form"> | ||
<div class="field"> | ||
<label>Phone</label> | ||
<input type="text" v-model="phone" placeholder="Type your phone number" | ||
@keyup.enter="handleSubmit" :disabled="submitting"> | ||
<small>Enter to submit</small> | ||
</div> | ||
</div> | ||
<div class="ui grid" v-if="pair_code"> | ||
<div class="ui two column centered grid"> | ||
<div class="column center aligned"> | ||
<div class="header">Pair Code</div> | ||
<p style="font-size: 32px">{{ pair_code }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters