Initial commit

This commit is contained in:
2025-08-04 16:33:07 +03:30
commit f798e8e35c
9595 changed files with 1208683 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
import avatar1 from '@images/avatars/avatar-1.png'
import avatar2 from '@images/avatars/avatar-2.png'
import avatar3 from '@images/avatars/avatar-3.png'
import treePot from '@images/pages/tree-pot.png'
export const database = {
boards: [
{
id: 1,
title: 'In Progress',
itemsIds: [1, 2],
},
{
id: 2,
title: 'In Review',
itemsIds: [3, 4],
},
{
id: 3,
title: 'Done',
itemsIds: [5, 6],
},
],
items: [
{
id: 1,
title: 'Research FAQ page UX',
dueDate: '',
labels: ['UX'],
members: [{ img: avatar1, name: 'John Doe' }, { img: avatar2, name: 'Jane Smith' }, { img: avatar3, name: 'Robert Johnson' }],
comments: 'FAQ page design is ready and needs to be implemented.',
attachments: 2,
commentsCount: 1,
image: '',
},
{
id: 2,
title: 'Review JavaScript code',
dueDate: '',
labels: ['Code Review'],
members: [{ img: avatar1, name: 'John Doe' }, { img: avatar2, name: 'Jane Smith' }],
comments: 'JavaScript code needs to be reviewed and refactored.',
attachments: 2,
commentsCount: 4,
image: '',
},
{
id: 3,
title: 'Review completed Apps',
dueDate: '',
labels: ['Dashboard'],
members: [{ img: avatar1, name: 'John Doe' }, { img: avatar2, name: 'Jane Smith' }],
comments: 'Apps design is ready and needs to be implemented.',
image: '',
attachments: 5,
commentsCount: 10,
},
{
id: 4,
title: 'Find new images for pages',
dueDate: '',
labels: ['Image'],
members: [{ img: avatar1, name: 'John Doe' }, { img: avatar2, name: 'Jane Smith' }, { img: avatar3, name: 'Robert Johnson' }],
comments: 'New images need to be found for the new pages.',
image: treePot,
attachments: 5,
commentsCount: 4,
},
{
id: 5,
title: 'Forms & tables section',
dueDate: '',
labels: ['App'],
members: [{ img: avatar1, name: 'John Doe' }, { img: avatar2, name: 'Jane Smith' }],
comments: 'Forms and tables need to be updated.',
attachments: 7,
commentsCount: 2,
image: '',
},
{
id: 6,
title: 'Completed charts & maps',
dueDate: '',
labels: ['Charts & Maps'],
members: [{ img: avatar1, name: 'John Doe' }],
comments: 'Charts and maps need to be updated.',
attachments: 1,
commentsCount: 10,
image: '',
},
],
}

View File

@@ -0,0 +1,148 @@
import { HttpResponse, http } from 'msw'
import { database } from '@db/apps/kanban/db'
export const handlerAppsKanban = [
// 👉 get all kanban data
http.get('/api/apps/kanban', () => {
return HttpResponse.json(database, { status: 200 })
}),
// 👉 rename board
http.put('/api/apps/kanban/board/rename', async ({ request }) => {
const boardData = await request.json()
database.boards = database.boards.map(board => {
if (board.id === boardData.boardId)
board.title = boardData.newName
return board
})
return new HttpResponse(null, { status: 201 })
}),
// 👉 delete board
http.delete('/api/apps/kanban/board/:id', async ({ params }) => {
const boardId = Number(params.id)
database.boards = database.boards.filter(board => board.id !== boardId)
return new HttpResponse(null, { status: 204 })
}),
// 👉 add new board
http.post('/api/apps/kanban/board/add', async ({ request }) => {
const boardName = await request.json()
const getNewBoardId = () => {
const newBoardId = database.boards.length + 1
if (!(database.boards.some(board => board.id === newBoardId)))
return newBoardId
else
return newBoardId + 1
}
if (database.boards.some(board => board.title === boardName.title)) {
return HttpResponse.error()
}
else {
database.boards.push({
id: getNewBoardId(),
title: boardName.title,
itemsIds: [],
})
return new HttpResponse(null, { status: 201 })
}
}),
// 👉 add new item
http.post('/api/apps/kanban/item/add', async ({ request }) => {
const newItem = await request.json()
const itemId = database.items[database.items.length - 1].id + 1
if (newItem.itemTitle && newItem.boardName) {
// Add the new item to the items list
database.items.push({
id: itemId,
title: newItem.itemTitle,
attachments: 0,
comments: '',
commentsCount: 0,
dueDate: '',
labels: [],
members: [],
})
// find the index of board in the database
const boardId = database.boards.findIndex(board => board.id === newItem.boardId)
// Add the new item to the board
database.boards[boardId].itemsIds.push(itemId)
}
else {
return HttpResponse.error()
}
return new HttpResponse(null, { status: 201 })
}),
// 👉 update item
http.put('/api/apps/kanban/item/update', async ({ request }) => {
const itemData = await request.json()
database.items.forEach(item => {
if (itemData.item && item.id === itemData.item.id) {
item.title = itemData.item.title
item.attachments = itemData.item.attachments
item.comments = itemData.item.comments
item.commentsCount = itemData.item.commentsCount
item.dueDate = itemData.item.dueDate
item.labels = itemData.item.labels
item.members = itemData.item.members
}
})
return new HttpResponse(null, { status: 201 })
}),
// 👉 delete item
http.delete('/api/apps/kanban/item/:id', async ({ params }) => {
const itemId = Number(params.id)
database.items = database.items.filter(item => item.id !== itemId)
database.boards.forEach(board => {
board.itemsIds = board.itemsIds.filter(id => id !== itemId)
})
return new HttpResponse(null, { status: 204 })
}),
// 👉 update item state
http.put('/api/apps/kanban/item/state-update', async ({ request }) => {
const stateData = await request.json()
database.boards.forEach(board => {
if (board.id === stateData.boardId)
board.itemsIds = stateData.ids
})
return new HttpResponse(null, { status: 201 })
}),
// 👉 update board state
http.put('/api/apps/kanban/board/state-update', async ({ request }) => {
const boardState = await request.json()
// sort board as per boardState
const sortedBoards = boardState.map(boardId => {
return database.boards.find(board => board.id === boardId)
})
database.boards = sortedBoards
return new HttpResponse(null, { status: 201 })
}),
]

View File

@@ -0,0 +1 @@
export {}