* setup application for contract

This commit is contained in:
2023-01-16 17:29:26 +01:00
parent 0b3a261ecf
commit 7d03a8563a
7 changed files with 39 additions and 27 deletions

View File

@@ -74,6 +74,7 @@ export default {
deregister() {
misapply(this.selectedContract)
this.closeModal()
this.$router.go()
}
}
}

View File

@@ -60,12 +60,15 @@ export default {
},
methods: {
...mapActions(['closeModal']),
apply(role) {
async apply(role) {
const id = this.selectedContract
if (id === null) {
router.push('/error?message=' + 'Contract not found' + '&code=404')
}
applyContract(id, role)
//contractID, prefRole, userName, userPhone, userEmail
await applyContract(id, role, this.$store.state.keycloak.keycloak.tokenParsed.name, '', this.$store.state.keycloak.keycloak.tokenParsed.email)
this.closeModal()
this.$router.go()
}
}
}

View File

@@ -73,7 +73,7 @@
<td class="text align-top text-xl pl-4 max-sm:text-base py-2">Mitarbeiter:</td>
<td class="w-full pl-2 text-lg max-sm:text-base py-2">
<ul class="list-disc pl-4">
<li v-for="person in contract.mitarbeiter" :key="person.name">
<li v-for="person in contract.employees" :key="person.name">
{{ person.name }}({{ person.role }}) {{ person.phone }}
<a :href="'mailto:' + person.email">
<font-awesome-icon class="pl-1 h-5 mt-1" icon="fa-solid fa-envelope" />

View File

@@ -31,7 +31,7 @@ export async function getOpenContracts() {
}
}) //TODO: provide here auth header
.then(resp => {
return resp.data.openContracts
return resp.data
})
.catch(error => {
router.push('/error?message=' + error.message + '&code=' + error.code)
@@ -60,12 +60,15 @@ export async function getContractById(identifier, authToken) {
})
}
export async function applyContract(contractID, prefRole) {
export async function applyContract(contractID, prefRole, userName, userPhone, userEmail) {
return HttpClient.post(
'/contract/apply',
{
id: contractID,
role: prefRole
role: prefRole,
name: userName,
phone: userPhone,
email: userEmail
},
{
headers: {
@@ -84,17 +87,14 @@ export async function applyContract(contractID, prefRole) {
}
export async function misapply(contractID) {
return HttpClient.post(
'/contract/misapply',
{
id: contractID
},
{
return HttpClient.post('/contract/' + contractID + '/misapply', {
id : contractID,
email : store.state.keycloak.keycloak.tokenParsed.email
}, {
headers: {
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
}
}
)
})
.then(resp => {
//TODO: send also auth token with request
return resp.data

View File

@@ -33,7 +33,15 @@ export default {
return state.currentContract
},
async fetchOpenContracts({ commit }) {
const openContracts = await getOpenContracts()
let openContracts = await getOpenContracts()
for (let i = 0; i < openContracts.length; ++i) {
openContracts[i]["registered"] = false
for (let j = 0; j < openContracts[i].employees.length; ++j) {
if (openContracts[i].employees[j].email === store.state.keycloak.keycloak.tokenParsed.email)
openContracts[i]["registered"] = true
}
}
store.state.keycloak.keycloak.tokenParsed.email
commit('initOpenContracts', openContracts)
}
},

View File

@@ -52,8 +52,8 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
contract.status.name
}}</span>
</td>
<td class="py-3 px-4 text-center" v-if:="contract.mitarbeiter">
{{ contract.mitarbeiter.join(', ') }}
<td class="py-3 px-4 text-center" v-if:="contract.employees">
{{ contract.employees.map(function(item){return item['name'];}).join(', ') }}
</td>
<td class="py-3 px-4 text-center" v-else:>Not found</td>
<td class="py-3 px-4 text-center">

View File

@@ -22,7 +22,7 @@ import Navbar from '../components/Navbar.vue'
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Id</th>
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Name</th>
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Status</th>
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Planed Date</th>
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Created Date</th>
<th class="w-1/3 py-3 px-4 uppercase font-semibold text-sm text-center">Notes</th>
<th class="py-3 px-4 uppercase font-semibold text-sm text-center">Aktion</th>
</tr>
@@ -37,15 +37,15 @@ import Navbar from '../components/Navbar.vue'
<td class="py-3 px-4 text-center">
<!-- TODO: set color specific from status. for colors use https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/css/labels -->
<span class="text-emerald-600 bg-emerald-200 rounded-full py-1 px-2">{{
contract.status
contract.status.name
}}</span>
</td>
<td class="py-3 px-4 text-center">
{{ new Date(contract.appointment).toDateString() }}
{{ new Date(contract.updatedAt).toDateString() }}
</td>
<td class="py-3 px-4 text-center">{{ contract.notes }}</td>
<td class="text-left py-2">
<RouterLink to="/contract?id=TESTID">
<RouterLink :to="'/contract?id=' + contract.id">
<button
class="bg-blue-500 text-white active:bg-emerald-600 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button">
@@ -53,7 +53,7 @@ import Navbar from '../components/Navbar.vue'
</button>
</RouterLink>
<button
v-if="contract.registered"
v-if="!contract.registered"
class="bg-emerald-500 text-white active:bg-emerald-600 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button"
@click="
@@ -63,7 +63,7 @@ import Navbar from '../components/Navbar.vue'
Anmelden
</button>
<button
v-if="!contract.registered"
v-if="contract.registered"
class="bg-red-500 text-white active:bg-red-600 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button"
@click="