fix: username sanitization, canvas creation modal fixes, and auth headers for tasks
This commit is contained in:
@@ -159,7 +159,7 @@ const fetchGroup = async () => {
|
||||
headers: { Authorization: `Bearer ${auth.token.value}` }
|
||||
})
|
||||
group.value = data.group
|
||||
members.value = data.members || []
|
||||
members.value = data.group.members || []
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch group', e)
|
||||
navigateTo('/admin/groups')
|
||||
|
||||
+18
-10
@@ -9,13 +9,13 @@
|
||||
|
||||
<div class="flex items-center justify-between mb-8">
|
||||
<h1 class="text-2xl font-bold text-slate-100">Мои Карты</h1>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex items-center gap-3">
|
||||
<button @click="triggerImport" class="px-4 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-lg font-medium transition">
|
||||
Импорт .canvas
|
||||
</button>
|
||||
<input ref="importInput" type="file" accept=".canvas,.json" class="hidden" @change="handleImport" />
|
||||
<button @click="showCreateModal = true" class="px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white rounded-lg font-medium transition">
|
||||
+ Новая Карта
|
||||
<button @click="openCreateModal" class="px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white rounded-lg font-bold shadow-lg shadow-blue-900/20 transition flex items-center gap-2">
|
||||
<span>➕</span> Создать
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -223,11 +223,19 @@ const showCreateModal = ref(false)
|
||||
const importInput = ref(null)
|
||||
const activeTab = ref('personal')
|
||||
|
||||
const newCanvas = reactive({
|
||||
name: '',
|
||||
visibility: 'private',
|
||||
groupId: ''
|
||||
})
|
||||
const newCanvas = reactive({
|
||||
name: '',
|
||||
visibility: 'private',
|
||||
groupId: ''
|
||||
})
|
||||
|
||||
const openCreateModal = () => {
|
||||
newCanvas.name = ''
|
||||
newCanvas.visibility = 'private'
|
||||
newCanvas.groupId = ''
|
||||
showSettingsModal.value = false
|
||||
showCreateModal.value = true
|
||||
}
|
||||
|
||||
const showSettingsModal = ref(false)
|
||||
const saving = ref(false)
|
||||
@@ -293,9 +301,9 @@ const filteredCanvases = computed(() => {
|
||||
|
||||
switch (activeTab.value) {
|
||||
case 'personal':
|
||||
return canvases.value.filter(c => c.ownerId === userId && !c.groupId)
|
||||
return canvases.value.filter(c => c.ownerId === userId && (!c.groupId || c.groupId === ''))
|
||||
case 'team':
|
||||
return canvases.value.filter(c => !!c.groupId)
|
||||
return canvases.value.filter(c => c.groupId && c.groupId !== '')
|
||||
case 'public':
|
||||
return canvases.value.filter(c => c.isPublic)
|
||||
default:
|
||||
|
||||
+13
-14
@@ -163,21 +163,18 @@ const columns = [
|
||||
// Fetch all tasks for current user
|
||||
const fetchTasks = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/tasks', {
|
||||
const data = await $fetch('/api/tasks', {
|
||||
headers: { Authorization: `Bearer ${auth.token.value}` }
|
||||
})
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
tasks.value = data.tasks || []
|
||||
|
||||
// Split tasks into columns
|
||||
columns.forEach(col => {
|
||||
columnsData[col.id] = tasks.value.filter(t => {
|
||||
const taskState = t.state || t.data?.state || 'todo'
|
||||
return taskState === col.id
|
||||
})
|
||||
tasks.value = data.tasks || []
|
||||
|
||||
// Split tasks into columns
|
||||
columns.forEach(col => {
|
||||
columnsData[col.id] = tasks.value.filter(t => {
|
||||
const taskState = t.state || t.data?.state || 'todo'
|
||||
return taskState === col.id
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Failed to load tasks', e)
|
||||
} finally {
|
||||
@@ -187,8 +184,10 @@ const fetchTasks = async () => {
|
||||
|
||||
const fetchCanvases = async () => {
|
||||
try {
|
||||
const res = await $fetch('/api/canvas')
|
||||
availableCanvases.value = res.canvases || []
|
||||
const data = await $fetch('/api/canvas', {
|
||||
headers: { Authorization: `Bearer ${auth.token.value}` }
|
||||
})
|
||||
availableCanvases.value = data.canvases || []
|
||||
if (availableCanvases.value.length > 0) {
|
||||
newTask.canvasId = availableCanvases.value[0].id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user