Skip to content

Commit

Permalink
defined interfaces for the data
Browse files Browse the repository at this point in the history
  • Loading branch information
nabilasherif committed Aug 28, 2024
1 parent 1cf18f3 commit e811ea3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
3 changes: 1 addition & 2 deletions client/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ declare module 'vue' {
export interface GlobalComponents {
Login: typeof import('./components/Login.vue')['default']
LoginGithub: typeof import('./components/LoginGithub.vue')['default']
TFLogin: typeof import('./components/TFLogin.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Test: typeof import('./components/test.vue')['default']

TFLogin: typeof import('./components/TFLogin.vue')['default']
}
}
35 changes: 20 additions & 15 deletions client/src/pages/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
:disabled="!isFormValid"
size="large"
variant="outlined"
@click="SumbitLogIn"
@click="SubmitLogIn"
>
Log In
</v-btn>
Expand Down Expand Up @@ -111,12 +111,12 @@
</div>
</template>

<script>
import axios from '../api/axios.ts'
<script lang="ts">
import axios from '../api/axios'
import { useRouter } from 'vue-router'
import { useNotifier } from 'vue3-notifier'
import { emailRules, passwordRules } from '@/utilities/validators'
import { logInInfo } from '@/types/types.ts'
import type { logInInfo } from '@/types/types.ts'
// import LoginGithub from '@/components/LoginGithub.vue'
// import TFLogin from '@/components/TFLogin.vue'
Expand All @@ -130,39 +130,44 @@
const notifier = useNotifier('top right')
const userInfo = ref < logInInfo > ({
const userInfo = ref<logInInfo>({
email: '',
password: '',
})
const passwordVisible = ref(true)
async function SumbitLogIn () {
async function SubmitLogIn () {
try {
localStorage.removeItem('TEST_TRACKER_REFRESH_TOKEN')
await axios.LogInUser(userInfo.value)
if (localStorage.getItem('TEST_TRACKER_REFRESH_TOKEN') != null) {
router.push(`/`)
}
} catch (error) {
notifier.notify({
title: 'Fail',
description: error.detail,
showProgressBar: true,
timeout: 7_000,
type: 'error',
})
console.log('here', error)
// to be resolved
// notifier.notify({
// title: 'Fail',
// description: error,
// showProgressBar: true,
// timeout: 7_000,
// type: 'error',
// })
}
}
const form = ref(null)
const isFormValid = computed(() => form.value ? form.value.isValid : false)
const isFormValid = computed(() => form.value ? (form.value as any).isValid : false)
// const isFormValid = computed(() => form.value ? form.value.isValid : false)
function CreateAccount () {
router.push(`/signup`)
}
return {
SumbitLogIn,
SubmitLogIn,
CreateAccount,
userInfo,
passwordVisible,
Expand Down
23 changes: 12 additions & 11 deletions client/src/pages/SignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@
</div>
</template>

<script>
import axios from '../api/axios.ts'
<script lang="ts">
import axios from '../api/axios'
import { useNotifier } from 'vue3-notifier'
import { useRouter } from 'vue-router'
import { emailRules, nameRules, passwordRules } from '@/utilities/validators'
import Login from '@/components/Login.vue'
import { signUpInfo } from '@/types/types'
// import LoginGithub from '@/components/LoginGithub.vue'
// import TFLogin from '@/components/TFLogin.vue'
Expand All @@ -120,7 +121,7 @@
const router = useRouter()
const loading = ref(false)
const newUser = ref({
const newUser = ref<signUpInfo>({
first_name: '',
last_name: '',
email: '',
Expand All @@ -143,20 +144,20 @@
})
router.push(`/login`)
} catch (error) {
notifier.notify({
title: 'Fail',
description: error.message,
showProgressBar: true,
timeout: 7_000,
type: 'error',
})
// notifier.notify({
// title: 'Fail',
// description: error.message,
// showProgressBar: true,
// timeout: 7_000,
// type: 'error',
// })
console.error(error)
} finally {
loading.value = false
}
}
const form = ref(null)
const isFormValid = computed(() => form.value ? form.value.isValid : false)
const isFormValid = computed(() => form.value ? (form.value as any).isValid : false)
return {
RegisterNewUser,
Expand Down
8 changes: 4 additions & 4 deletions client/src/pages/SignUpInvitation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<v-row>
<v-col>
<v-text-field
v-model="userPassword.password1"
v-model="userPassword.password"
:append-inner-icon="showPassword ? 'mdi-eye-off' : 'mdi-eye'"
density="compact"
placeholder="Password"
Expand Down Expand Up @@ -105,7 +105,7 @@
const notifier = useNotifier('top right')
const userPassword = ref({
password1: '',
password: '',
password2: '',
})
Expand All @@ -117,7 +117,7 @@
async function RegisterUser () {
try {
await axios.SignUpInvitation(userPassword.value)
await axios.SignUpInvitation(userPassword.value.password)
notifier.notify({
title: 'Success',
description: 'successful sign up',
Expand All @@ -141,7 +141,7 @@
}
const isFormValid = computed(() => form.value ? form.value.isValid : false)
const confirmedPasswordRules = computed(() => confirmedPasswordRule(userPassword.value.password1))
const confirmedPasswordRules = computed(() => confirmedPasswordRule(userPassword.value.password))
const form = ref(null)
Expand Down
13 changes: 10 additions & 3 deletions client/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export interface logInInfo {
email: string,
password: string,
}
email: string;
password: string;
}

export interface signUpInfo{
first_name: string;
last_name: string;
email: string;
password: string;
}

0 comments on commit e811ea3

Please sign in to comment.