post User by secretary
This commit is contained in:
@ -3,36 +3,37 @@ import i18n from "../i18n.js";
|
||||
import {ref} from "vue";
|
||||
import {fetchAllResearchers} from "@/rest/ScientificPublications/ManageResearch.js";
|
||||
import {deleteResearcher, postResearcher} from "@/rest/ScientificPublications/ResearcherProfile.js";
|
||||
import {patchUser} from "@/rest/Users.js";
|
||||
const props = defineProps(['user'])
|
||||
const modifying =ref(false)
|
||||
const toModify = Object.assign({},{})
|
||||
const toCreate = Object.assign({},{})
|
||||
const allResearcher = ref( await fetchAllResearchers())
|
||||
const researcher = ref()
|
||||
const user = props.user
|
||||
const user = ref(props.user)
|
||||
const isResearcher = ref(false)
|
||||
const creating = ref(false)
|
||||
|
||||
for (let i = 0; i < allResearcher.value.length; i++) {
|
||||
if (user.regNo === allResearcher.value[i].user.regNo){
|
||||
if (user.value.regNo === allResearcher.value[i].user.regNo){
|
||||
researcher.value = allResearcher.value[i]
|
||||
isResearcher.value = true
|
||||
}
|
||||
}
|
||||
|
||||
function getPP(){
|
||||
if(user.profilePictureUrl === null){
|
||||
if(user.value.profilePictureUrl === null){
|
||||
return "/Clyde.png"
|
||||
}
|
||||
return user.profilePictureUrl
|
||||
return user.value.profilePictureUrl
|
||||
}
|
||||
|
||||
async function createResearcher(){
|
||||
toCreate.user = user
|
||||
toCreate.user = user.value
|
||||
await postResearcher(toCreate)
|
||||
creating.value = false
|
||||
for (let i = 0; i < allResearcher.value.length; i++) {
|
||||
if (user.regNo === allResearcher.value[i].user.regNo){
|
||||
if (user.value.regNo === allResearcher.value[i].user.regNo){
|
||||
researcher.value = allResearcher.value[i]
|
||||
isResearcher.value = true
|
||||
}
|
||||
@ -46,6 +47,13 @@ async function deleteResearcherById(){
|
||||
allResearcher.value = await fetchAllResearchers()
|
||||
}
|
||||
|
||||
async function modify(){
|
||||
if (modifying.value){
|
||||
user.value = await patchUser(user.value.regNo, toModify)
|
||||
}
|
||||
modifying.value =!modifying.value
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -89,7 +97,7 @@ async function deleteResearcherById(){
|
||||
</div>
|
||||
</div>
|
||||
<div></div>
|
||||
<button id="ModifyButton" @click="modifying= !modifying"> {{i18n("Modify.Data")}}</button>
|
||||
<button id="ModifyButton" @click="modify"> {{i18n("Modify.Data")}}</button>
|
||||
<div></div>
|
||||
<div>
|
||||
<button v-if="isResearcher" id="deleteButton" @click="deleteResearcherById"> {{i18n("Researcher.Delete")}}</button>
|
||||
@ -111,8 +119,6 @@ async function deleteResearcherById(){
|
||||
{{i18n("Domain")}} :
|
||||
<input type="text" v-model="toCreate.domain"></li>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -133,6 +139,7 @@ async function deleteResearcherById(){
|
||||
}
|
||||
|
||||
.container{
|
||||
margin-top: 25px;
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
|
Reference in New Issue
Block a user