Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | <template> <section class="container"> <div class="grid md:grid-cols-1 mt-5 mb-5"> <div class="w-full max-w-md my-0 mx-auto"> <form class="px-8 pt-6 pb-8 mb-4" :class=" username || email || password ? 'was-validated' : 'needs-validation' " autocomplete="off" novalidate @submit.stop.prevent="handleSubmit" > <div class="mb-4"> <input id="username" type="text" placeholder="Enter your username" v-model.trim="username" autocomplete="off" required autofocus="true" :pattern=" isUsername ? '^[a-zA-Z0-9]{1000000}$' : '^[a-zA-Z0-9]{8,}$' " title="Invalid email address" class=" form-control appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline " /> <div class="valid-feedback">Looks good!</div> <div class="invalid-feedback"> {{ isUsername ? "Username has been already exist" : "Username nust be least 8 or more characters" }} </div> </div> <div class="mb-4"> <input id="email" type="email" placeholder="Enter your email" v-model.trim="email" required autofocus="true" autocomplete="off" :pattern=" isEmail ? '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{10000}$' : '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$' " title="Invalid email address" class=" form-control appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline " /> <div class="valid-feedback">Looks good!</div> <div class="invalid-feedback"> {{ isEmail ? "Email has been already exist" : "Email must contain @" }} </div> </div> <div class="mb-4"> <input id="password" type="password" placeholder="Enter your password" v-model.trim="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" autofocus="true" autocomplete="off" class=" form-control appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline " /> <div class="valid-feedback">Looks good!</div> <div class="invalid-feedback"> Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters </div> </div> <div class="flex items-center justify-between"> <button class=" border-0 bg-blue-500 hover:bg-blue-700 text-white gold-background font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline " type="submit" > Submit </button> </div> <p class="text-center mt-3"> Already have an account? <nuxt-link event="" v-on:click.native="linkClick" to="/login"> Login </nuxt-link> </p> </form> </div> </div> </section> </template> <script> import { mapActions } from "vuex"; export default { name: "SingUp", props: { isMenu: Boolean, toggle: Function }, data: () => ({ username: "", email: "", password: "", isUsername: false, isEmail: false, timer: null, }), watch: { username: function () { this.checkUs(); }, email: function () { this.checkUs(); }, }, methods: { ...mapActions({ createCustomer: "auth/createCustomer", checkUser: "auth/checkUser", }), checkUs: async function () { const { username, email } = this; if (username || email) { clearInterval(this.timer); this.timer = null; this.timer = setTimeout(async () => { const { isUsername, isEmail } = await this.checkUser({ username, email, }); this.isEmail = isEmail; this.isUsername = isUsername; }, 1000); } else { clearInterval(this.timer); this.timer = null; } }, linkClick() { if (this.isMenu) { this.toggle(); return; } this.$router.push("/login"); }, async handleSubmit() { const { isEmail, isUsername, email, username, password } = this; if (!isEmail && !isUsername && email && username && password) { const data = { email, username, password }; await this.createCustomer(data); } }, }, destroyed() { if (this.timer) { clearTimeout(this.timer); this.timer = null; } }, }; </script> <style lang="scss" scoped> input { width: 100%; max-width: 450px; } </style> |