Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script src="/config.js"></script>
</body>

</html>
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"core-js": "^3.37.1",
"roboto-fontface": "*",
"vue": "^3.4.31",
"vuetify": "^3.6.11"
"vuetify": "^3.6.11",
"vue3-notifier":"1.0.3"
},
"devDependencies": {
"@babel/types": "^7.24.7",
Expand Down
3 changes: 3 additions & 0 deletions client/public/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.env = {
SERVER_DOMAIN_NAME_API: 'http://127.0.0.1:8000/api',
}
6 changes: 1 addition & 5 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<template>
<v-app>
<v-main>
<router-view />
</v-main>
</v-app>
<p>To be implemented</p>
</template>

<script lang="ts" setup>
Expand Down
17 changes: 0 additions & 17 deletions client/src/api/axios.ts

This file was deleted.

15 changes: 15 additions & 0 deletions client/src/api/clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios, { AxiosInstance } from 'axios'

export const AuthClient: AxiosInstance = axios.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIzOTk0NzQ5LCJpYXQiOjE3MjM5ODU0NDksImp0aSI6ImRjMWRjMDU1ZTgzZjQ0NGQ4NDU1NTAwMGMyNDUwMTJhIiwidXNlcl9pZCI6NCwiZW1haWwiOiJib3VkaWVAYm91ZGllLmNvbSJ9.OgeODfFg5GxP1QxAAyu2FFlOMx2suAdWvjBtkK5eT0U',
},
})

export const BaseClient: AxiosInstance = axios.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
})
18 changes: 18 additions & 0 deletions client/src/api/projectService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AuthClient } from './clients'
import { Project } from '@/types/types'

export async function postProject (project :Partial<Project>) {
return AuthClient.post('/dashboard/projects/', project)
}

export async function getProjects (page :number) {
return AuthClient.get('/dashboard/projects/', {
params: {
cursor: page,
},
})
}

export async function searchProject (searchInput: string) {
await AuthClient.get(`/project/search/${searchInput}`)
}
1 change: 1 addition & 0 deletions client/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module 'vue' {
export interface GlobalComponents {
AppFooter: typeof import('./components/AppFooter.vue')['default']
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
ProjectForm: typeof import('./components/projects/ProjectForm.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Test: typeof import('./components/test.vue')['default']
Expand Down
122 changes: 122 additions & 0 deletions client/src/components/projects/ProjectForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<template>
<v-form
ref="form"
fast-fail
@submit.prevent
>
<v-text-field
v-model="project.title"
base-color="blue"
clearable
color="blue"
label="Title"
required
:rules="titleRules"
/>

<v-text-field
v-model="project.short_description"
base-color="blue"
clearable
color="blue"
label="Description"
required
:rules="descriptionRules"
/>
<v-switch
v-model="githubRepo"
base-color="blue"
label="Github repository"
/>

<v-text-field
v-if="githubRepo"
v-model="project.repo_link"
clearable
label="Git repository"
:rules="githubRepoRules"
/>

<v-btn
block
class="me-4"
color="blue"
:disabled="!form?.isValid"
text="Submit"
type="submit"
variant="tonal"
@click="createProject"
/>
</v-form>
</template>

<script lang="ts">
import { ref } from 'vue'
import { postProject } from '@/api/projectService'
import { Project } from '@/types/types'
import { descriptionRules, githubRepoRules, titleRules } from '@/utilities/validators'
import { useNotifier } from 'vue3-notifier'

export default {

name: 'ProjectForm',
setup () {
const notifier = useNotifier('top right')

const githubRepo = ref<boolean>(false)

const form = ref()

const project = ref<Partial<Project>>(
{
title: '',
short_description: '',
repo_link: '',
}
)

const createProject = async () => {
let projectObject: Partial<Project> = {
title: project.value.title,
short_description: project.value.short_description,
}
if (project.value.repo_link !== '') {
projectObject = {
...projectObject,
repo_link: project.value.repo_link,
}
}
postProject(projectObject)
.then((response: any) => {
notifier.notify({
title: 'Success',
description: 'Project created Successfully',
showProgressBar: true,
timeout: 7_000,
type: 'success',
})
})
.catch((err: any) => {
notifier.notify({
title: 'Fail',
description: 'Can not create project',
showProgressBar: true,
timeout: 7_000,
type: 'error',
})
console.error(err)
})
}

return {
form,
project,
githubRepo,
titleRules,
descriptionRules,
githubRepoRules,
createProject,
}
},
}
</script>
9 changes: 9 additions & 0 deletions client/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {}

declare global {
interface Window {
env: {
SERVER_DOMAIN_NAME_API: string;
};
}
}
2 changes: 2 additions & 0 deletions client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* Bootstraps Vuetify and other plugins then mounts the App`
*/
// Styles
import 'vue3-notifier/style.css'

// Plugins
import { registerPlugins } from '@/plugins'
Expand Down
17 changes: 17 additions & 0 deletions client/src/pages/projects/ProjectDetailsView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<p>To be implemented</p>
</template>

<script lang="ts">

export default {

name: 'ProjectDetailsView',
components: {
},
setup () {
return {
}
},
}
</script>
Loading