Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bienfait-ijambo committed Aug 22, 2024
1 parent fb54cfd commit a606c40
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 66 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/cd-render.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Trigger Deployment


name: CI

on:
workflow_call:

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

# - name: Trigger Deployment via GET Request
# run: |
# curl -X GET https://laravel.com/docs/11.x/starter-kits
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml → .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
workflow_call:

jobs:
build:
Expand Down
Empty file added .github/workflows/main.yml
Empty file.
2 changes: 1 addition & 1 deletion src/components/__tests__/CreateIncomeOrExpenseForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('CreateIncomeOrExpenseForm', () => {


const form = mount(CreateIncomeOrExpenseForm, {
props: { loading: false },
props: { loading: false ,userAccountStatus: 'active'},
global: {
plugins: [createPinia()]
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type LoginResponseType = {
accessToken: string
refreshToken: string
}
userAccount:{
userAccount?:{
leftDays:string
account_status:userAccountStatusType
}
Expand Down
10 changes: 8 additions & 2 deletions src/http/App.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// export const APP = {
// baseURL: 'http://127.0.0.1:8000',
// apiBaseURL: 'http://127.0.0.1:8000/api'
// }

export const APP = {
baseURL: 'http://127.0.0.1:8000',
apiBaseURL: 'http://127.0.0.1:8000/api'
baseURL: 'http://143.244.157.28',
apiBaseURL: 'http://143.244.157.28/api'
}

2 changes: 1 addition & 1 deletion src/http/makeHttpReq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function makeHttpReq<TInput, TResponse>(
}),
httpTimeOut('Server Error')
])

const data: TResponse = await (res as Response).json()

if (!(res as Response).ok) {
Expand Down
9 changes: 0 additions & 9 deletions src/views/pages/auth/LoginPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import { onMounted } from 'vue';
import LoginButton from './components/LoginButton.vue'
import { APP } from '@/http/App'
Expand All @@ -9,15 +8,7 @@ function loginOrSignUpUser() {
onMounted(()=>{
setTimeout(()=>{
window.Echo.channel("countProject")
.listen("NewProjectCreated",(e) => {
console.log(e)
});
},200)
})
</script>
<template>
<div class="row">
Expand Down
85 changes: 40 additions & 45 deletions src/views/pages/auth/TokenPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { getUserData, setUserData, UserRole, type userAccountStatusType } from '@/helper/auth'
import { showError } from '@/helper/toastnotification'
import { APP } from '@/http/App'
import { makeHttpReq, makeHttpReq2 } from '@/http/makeHttpReq'
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'
Expand All @@ -23,16 +24,13 @@ type OauthTokenResponseType = {
access_token: string
}
type userResponseType = {
id: string
name: string
email: string
role: UserRole
}
async function getAccessTokenAndRefreshToken() {
const userData = getUserData()
Expand All @@ -44,57 +42,54 @@ async function getAccessTokenAndRefreshToken() {
code_verifier: codeVerifier,
code: userData?.authorizationCode as string
}
const [token,{user,userAccount}] = await Promise.all([
makeHttpReq2<OauthTokenInputType, OauthTokenResponseType>(
'oauth/token',
'POST',
input
),
makeHttpReq<OauthTokenInputType, {user:userResponseType,userAccount:{
leftDays:string,
account_status:userAccountStatusType
}}>(
'user_data',
'POST',
input
)
const [token, { user, userAccount }] = await Promise.all([
makeHttpReq2<OauthTokenInputType, OauthTokenResponseType>('oauth/token', 'POST', input),
makeHttpReq<
OauthTokenInputType,
{
user: userResponseType
userAccount: {
leftDays: string
account_status: userAccountStatusType
}
}
>('user_data', 'POST', input)
])
if(userAccount?.account_status==='Active'){
if (userAccount?.account_status === 'Active') {
setUserData({
user: {
name:user?.name,
email: user?.email,
userId: user?.id,
role:user?.role
},
userAccount:{
leftDays:userAccount?.leftDays,
account_status:userAccount?.account_status
},
token: {
accessToken: token?.access_token,
refreshToken: token?.refresh_token
}
})
window.location.href = '/dashboard'
}else{
user: {
name: user?.name,
email: user?.email,
userId: user?.id,
role: user?.role
},
userAccount: {
leftDays: userAccount?.leftDays,
account_status: userAccount?.account_status
},
token: {
accessToken: token?.access_token,
refreshToken: token?.refresh_token
}
})
window.location.href = '/dashboard'
} else {
window.location.href = '/user_blocked'
}
} catch (error) {
showError((error as Error).message)
if ((error as Error).message === 'Unexpected end of JSON input') {
showError('Failed Login ..., please try again...')
setTimeout(() => (window.location.href = APP.baseURL + '/auth/redirect'), 1500)
} else {
showError((error as Error).message)
}
}
}
onMounted(async () => {
await getAccessTokenAndRefreshToken()
})
Expand Down
7 changes: 7 additions & 0 deletions src/views/pages/auth/UserBlockedPage.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<script lang="ts" setup>
import { onMounted } from 'vue'
onMounted(()=>{
localStorage.clear();
})
</script>
<template>
<br>
<br>
Expand Down

0 comments on commit a606c40

Please sign in to comment.