Skip to content

Commit

Permalink
fix bugs and issues ver3
Browse files Browse the repository at this point in the history
  • Loading branch information
jamshidi799 committed Mar 16, 2021
1 parent d3b7c46 commit 29892fc
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 40 deletions.
4 changes: 4 additions & 0 deletions api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export const sendGoogleAuthCode = (axios, data) => {
export const activeAccount = (axios, eid, token) => {
return axios.$get(`/accounts/activate/${eid}/${token}`);
};

export const isAccountActivated = (axios, email) => {
return axios.$post('/accounts/is-active', { email });
};
1 change: 1 addition & 0 deletions components/PasswordInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:type="show ? 'text' : 'password'"
:rules="requiredRules"
required
class="autofill-bg"
outlined
:autofocus="autofocus"
dir="ltr"
Expand Down
110 changes: 102 additions & 8 deletions components/dashboard/settings/EditProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,51 @@
</v-col>
</v-row>
<v-row>
<v-col class="py-0 mb-6" cols="12">
<v-col class="py-0 mb-3" cols="12">
<v-text-field
v-model="information.phone_number"
:rules="requiredRules"
required
label="شماره تماس"
v-bind="filedProps"
:rules="phoneRules"
validate-on-blur
></v-text-field>
</v-col>
</v-row>
<v-text-field
<!-- <v-text-field
v-model="information.university"
:label="$t('form.educationPlace')"
required
:rules="requiredRules"
v-bind="filedProps"
class="mb-6"
/>
/> -->
<v-row>
<v-col class="py-0 mb-3" cols="12">
<v-text-field v-model="information.birth_date" v-bind="filedProps" required :rules="requiredRules" label="سال ورودی" />
<v-autocomplete
v-model="information.university"
:items="universityItems"
:loading="isLoading"
:search-input.sync="search"
hide-no-data
hide-selected
:label="$t('form.educationPlace')"
return-object
outlined
:rules="requiredRules"
></v-autocomplete>
</v-col>
</v-row>
<v-row>
<v-col class="py-0 mb-3" cols="12">
<v-text-field
type="int"
v-model="information.birth_date"
v-bind="filedProps"
required
:rules="requiredRules"
label="سال ورودی"
/>
</v-col>
</v-row>
<v-row>
Expand All @@ -57,13 +81,26 @@
</v-col>
</v-row>

<v-row>
<v-col class="py-0 mb-3" cols="12">
<v-select
v-model="information.programming_language"
:rules="requiredRules"
:items="languageSelectItem"
label="زبان برنامه نویسی"
outlined
></v-select>
</v-col>
</v-row>

<v-row class="px-3">
<v-checkbox
v-model="information.hide_profile_info"
required
label="اطلاعاتم برای سایر شرکت کننده ها قابل جستجو باشد."
label="اطلاعاتم برای سایر شرکت کننده ها قابل جستجو نباشد."
></v-checkbox>
</v-row>

<div class="d-flex mt-8">
<div style="flex: 0 1 93px; margin-left: 24px">
<v-btn block color="black" style="flex-basis: 20%" @click="resetForm">لغو</v-btn>
Expand All @@ -81,14 +118,14 @@
</template>

<script>
import { emailRules, requiredRules } from '../../../mixins/formValidations';
import { emailRules, requiredRules, phoneRules } from '../../../mixins/formValidations';
import { primaryButtonProps } from '../../../mixins/buttonProps';
import { fieldProps } from '../../../mixins/fieldProps';
import SectionHeader from '~/components/SectionHeader';
import SectionContainer from '~/components/SectionContainer';
export default {
mixins: [requiredRules, emailRules, primaryButtonProps, fieldProps],
mixins: [requiredRules, emailRules, primaryButtonProps, fieldProps, phoneRules],
components: { SectionHeader, SectionContainer },
props: {
information: Object,
Expand All @@ -99,6 +136,22 @@ export default {
data() {
return {
valid: false,
isLoading: false,
search: null,
languageSelectItem: [
{
text: 'java',
value: 'java',
},
{
text: '++C',
value: 'cpp',
},
{
text: 'python',
value: 'py3',
},
],
degreeItem: [
{
text: 'دانش آموز',
Expand All @@ -117,7 +170,48 @@ export default {
value: 'DO',
},
],
universityItems: [],
};
},
// async fetch() {
// },
methods: {
async getUniversityItems() {
this.isLoading = true;
this.$axios.get(`/accounts/university-search?q=${this.information.university}`).then(res => {
console.log(res);
this.isLoading = false;
});
},
// getUniversityItems() {
// this.$axios.get(`/accounts/university-search?q=${this.information.university}`).then(res => {
// console.log(res)
// });
// },
},
watch: {
search(val) {
// Items have already been loaded
if (this.universityItems.length > 0) return;
// Items have already been requested
if (this.isLoading) return;
this.isLoading = true;
// Lazily load input items
this.$axios
.get(`/accounts/university-search?q=${this.search}`)
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
})
.finally(() => (this.isLoading = false));
},
},
};
</script>
22 changes: 1 addition & 21 deletions components/dashboard/settings/resume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
</v-col>
</v-row>

<v-row>
<v-col class="py-0 mb-3" cols="12">
<v-select v-model="information.programming_language" :items="languageSelectItem" label="زبان برنامه نویسی" outlined></v-select>
</v-col>
</v-row>
<v-row class="px-3">
<v-checkbox
v-bind="filedProps"
Expand Down Expand Up @@ -140,22 +135,7 @@ export default {
mixins: [requiredRules, emailRules, fieldProps],
components: { SectionHeader, SectionContainer },
data() {
return {
languageSelectItem: [
{
text: 'java',
value: 'java',
},
{
text: '++C',
value: 'cpp',
},
{
text: 'python',
value: 'py3',
},
],
};
return {};
},
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/team/TeamInvitationAndHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<div class="history">
<div>{{ list.user.profile.firstname_fa }} {{ list.user.profile.lastname_fa }}</div>
<div
v-bind:class="{
:class="{
blueFont: list.status === 'pending',
orangeFont: list.status === 'rejected',
greenFont: list.status === 'accepted',
Expand Down
1 change: 1 addition & 0 deletions components/userForms/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
validate-on-blur
height="36px"
aria-autocomplete="email"
class="autofill-bg"
></v-text-field>
<password-input v-model="password" />
<v-row>
Expand Down
25 changes: 21 additions & 4 deletions components/userForms/signUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@
dir="ltr"
height="36px"
validate-on-blur
class="autofill-bg"
@focus="clearError('email')"
></v-text-field>

<v-text-field label="شماره تلفن" v-model="form.phone_number" required outlined dir="ltr" height="36px"></v-text-field>
<v-text-field
label="شماره تلفن"
v-model="form.phone_number"
required
outlined
dir="ltr"
class="autofill-bg"
height="36px"
:rules="phoneRules"
validate-on-blur
></v-text-field>

<password-input v-model="form.password_1" />
<password-input v-model="form.password_2" label="form.passwordRepeat" />
<v-checkbox required outlined v-model="termsAndConditions" :label="$t('form.termsAndConditions')"></v-checkbox>
<v-checkbox
required
outlined
v-model="termsAndConditions"
:rules="requiredRules"
:label="$t('form.termsAndConditions')"
></v-checkbox>
<v-row>
<v-col>
<v-btn
Expand Down Expand Up @@ -68,14 +85,14 @@
</template>

<script>
import { emailRules, requiredRules } from '../../mixins/formValidations';
import { emailRules, requiredRules, phoneRules } from '../../mixins/formValidations';
import PasswordInput from '../../components/PasswordInput';
import { signup } from '../../api';
import { sendGoogleAuthCode } from '~/api/auth';
export default {
components: { PasswordInput },
mixins: [requiredRules, emailRules],
mixins: [requiredRules, emailRules, phoneRules],
data() {
return {
Expand Down
1 change: 1 addition & 0 deletions locales/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
},
"validation": {
"email": "ایمیل معتبر نیست",
"phoneNumber": "شماره تفلن معتبر نیست. باید شامل ۱۱ عدد باشد",
"required": "اجباری"
},
"time": {
Expand Down
16 changes: 12 additions & 4 deletions mixins/formValidations.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
export const emailRules = {
computed: {
emailRules() {
return [v => !!v || '', v => /.+@.+\..+/.test(v) || this.$t('validation.email')]
return [v => !!v || '', v => /.+@.+\..+/.test(v) || this.$t('validation.email')];
},
},
}
};

export const requiredRules = {
computed: {
requiredRules() {
return [v => !!v]
return [v => !!v];
},
},
}
};

export const phoneRules = {
computed: {
phoneRules() {
return [v => !!v || '', v => /^[\d]{11}$/.test(v) || this.$t('validation.phoneNumber')];
},
},
};
13 changes: 11 additions & 2 deletions store/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { login, getUser, logout } from '~/api/auth';
import { login, getUser, logout, isAccountActivated } from '~/api/auth';

export const state = () => ({
token: null,
Expand All @@ -15,7 +15,16 @@ export const actions = {
},
async login({ commit, dispatch }, payload) {
commit('loading');
let res = await login(this.$axios, payload).catch(e => this.$toast.error('ایمیل یا رمز اشتباه است'));
let res = await login(this.$axios, payload).catch(e => {
isAccountActivated(this.$axios, payload.username).then(res => {
if (res.status_code === 200) {
if (!res.is_active) this.$toast.error('قبل از ورود باید حساب‌کاربری خود را فعال کنید');
else this.$toast.error('رمز اشتباه است');
} else if (res.status_code === 404) {
this.$toast.error('ایمیل موردنظر یافت نشد');
}
});
});
commit('loaded');
if (res.token) {
commit('setToken', res);
Expand Down

0 comments on commit 29892fc

Please sign in to comment.