You've already forked isop-mirror
fix: incorrect API calls and failing to refresh InternshipStatusHistoryView and InternshipStatusEditor
This commit is contained in:
@@ -14,10 +14,10 @@ const user = useSanctumUser<User>();
|
|||||||
const rules = {
|
const rules = {
|
||||||
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
||||||
};
|
};
|
||||||
const possible_states = possibleNextStates(props.internship.status.status, user.value!.role).map((state) => ({
|
const possible_states = computed(() => possibleNextStates(props.internship.status.status, user.value!.role).map((state) => ({
|
||||||
title: prettyInternshipStatus(state),
|
title: prettyInternshipStatus(state),
|
||||||
value: state
|
value: state
|
||||||
}));
|
})));
|
||||||
|
|
||||||
const isValid = ref(false);
|
const isValid = ref(false);
|
||||||
const new_state = ref(null as InternshipStatus | null);
|
const new_state = ref(null as InternshipStatus | null);
|
||||||
@@ -26,7 +26,6 @@ const note = ref("");
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const error = ref(null as null | string);
|
const error = ref(null as null | string);
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const client = useSanctumClient();
|
const client = useSanctumClient();
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
@@ -39,7 +38,7 @@ async function submit() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client(`/api/internships/${route.params.id}/status`, {
|
await client(`/api/internships/${props.internship.id}/status`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: new_status
|
body: new_status
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { prettyInternshipStatus, type InternshipStatusData } from '~/types/internship_status';
|
import { prettyInternshipStatus, type InternshipStatusData } from '~/types/internship_status';
|
||||||
|
import type { Internship } from '~/types/internships';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps<{
|
||||||
internship: {
|
internship: Internship
|
||||||
type: Number,
|
}>();
|
||||||
required: true,
|
|
||||||
default: -1
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
{ title: 'Stav', key: 'status', align: 'left' },
|
{ title: 'Stav', key: 'status', align: 'left' },
|
||||||
@@ -16,8 +13,11 @@ const headers = [
|
|||||||
{ title: 'Zmenu vykonal', key: 'modified_by', align: 'left' },
|
{ title: 'Zmenu vykonal', key: 'modified_by', align: 'left' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const route = useRoute();
|
const { data, error, pending, refresh } = await useSanctumFetch<InternshipStatusData[]>(`/api/internships/${props.internship.id}/statuses`);
|
||||||
const { data, error, pending } = await useSanctumFetch<InternshipStatusData[]>(`/api/internships/${route.params.id}/statuses`);
|
|
||||||
|
watch(() => props.internship, () => {
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const { data, error, refresh } = await useSanctumFetch<Internship>(`/api/interns
|
|||||||
<hr />
|
<hr />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div :key="refreshKey">
|
<div>
|
||||||
<h2>Stav</h2>
|
<h2>Stav</h2>
|
||||||
<h4>Aktuálny stav</h4>
|
<h4>Aktuálny stav</h4>
|
||||||
<p>{{ prettyInternshipStatus(data?.status.status!) }}</p>
|
<p>{{ prettyInternshipStatus(data?.status.status!) }}</p>
|
||||||
@@ -82,12 +82,12 @@ const { data, error, refresh } = await useSanctumFetch<Internship>(`/api/interns
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h4>História</h4>
|
<h4>História</h4>
|
||||||
<InternshipStatusHistoryView :internship="data?.id" />
|
<InternshipStatusHistoryView :internship="data!" />
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h4>Zmena stavu</h4>
|
<h4>Zmena stavu</h4>
|
||||||
<InternshipStatusEditor :internship="data!"
|
<InternshipStatusEditor :key="`e-${refreshKey}`" :internship="data!"
|
||||||
@successful-submit="() => { refresh(); refreshKey++; }" />
|
@successful-submit="() => { refresh(); refreshKey++; }" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user