Skip to content

Commit

Permalink
Merge pull request #3634 from KBVE/patch-atomic-kanban-react-changes-…
Browse files Browse the repository at this point in the history
…12-25-2024-1735130028

[CI] Merge patch-atomic-kanban-react-changes-12-25-2024-1735130028 into dev
  • Loading branch information
h0lybyte authored Dec 26, 2024
2 parents cb06aca + d7990b6 commit 028e8db
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 186 deletions.
17 changes: 16 additions & 1 deletion apps/kbve.com/src/content/journal/12-25.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ import { Adsense, Tasks } from '@kbve/astropad';
Getting it all operational is the goal for today, then I will shift over to adding additional features.
Okay we need to push forward with some of the minor updates and get the new docker image built out!
Let me move the rust and react code up for now and loop back around, hopefully resolving the CORS issue.
The docker image of 1.02 was published, so now I am going to update the helm chart and have it deploy the new one.
The docker image of 1.02 was published, so now I am going to update the helm chart and have it deploy the new one.

- 07:33AM

**React**

Okay we got the communication between the kanban and the react component going, now we just need to figure out how to maintain that easy flow.
Right now its not pulling the right data from the api state, so I am going to focus on resolving that next.

- 02:21PM

**MerryXMas**

Happy holidays!
Forgot to include that in my notes, xD
I am thinking of redoing the whole kanban system to help keep track of the notes a bit better, maybe even expanding the item collection that would be involved.
21 changes: 21 additions & 0 deletions apps/kbve.com/src/content/journal/12-26.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: 'Decemeber: 26th'
category: Daily
date: 2024-12-26 12:00:00
client: Self
unsplash: 1511512578047-dfb367046420
img: https://images.unsplash.com/photo-1511512578047-dfb367046420?crop=entropy&cs=srgb&fm=jpg&ixid=MnwzNjM5Nzd8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODE3NDg2ODY&ixlib=rb-4.0.3&q=85
description: Decemeber 26th.
tags:
- daily
---

import { Adsense, Tasks } from '@kbve/astropad';

## 2024

- 09:30AM

**SPY**

$600 for SPY!? This is great!
43 changes: 29 additions & 14 deletions apps/kbve.com/src/engine/kanban/KanbanBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export class KanbanBase extends Kilobase {
this.itemPositionsStore.set(resetPositions); // Save the reset structure
console.log('Item positions reset to:', resetPositions);
}

/**
* Load board data by board_id from the API.
* Saves the fetched data to local storage.
* @param boardId - The board_id to load data for.
* @returns Promise<Record<string, { id: string; container: string }[]> | null> - The board data if found, or null if not found.
*/
Expand All @@ -102,7 +102,6 @@ export class KanbanBase extends Kilobase {
);

if (!response.ok) {
// If the response is not ok, log an error and return null
console.error(
`Failed to fetch board data for board ID: ${boardId}`,
);
Expand All @@ -111,17 +110,24 @@ export class KanbanBase extends Kilobase {

const result = await response.json();

// Validate the structure of the response
if (
result &&
typeof result === 'object' &&
'todo' in result &&
'in_progress' in result &&
'done' in result
) {
this.itemPositionsStore.set(result); // Cache the data locally
console.log(`Loaded board data for board ID: ${boardId}`);
return result;
// Save to local storage
const formattedResult = {
TODO: result.todo || [],
'IN-PROGRESS': result.in_progress || [],
DONE: result.done || [],
};
this.itemPositionsStore.set(formattedResult);
console.log(
`Loaded and saved board data for board ID: ${boardId}`,
);
return formattedResult;
}

console.error(
Expand All @@ -130,7 +136,7 @@ export class KanbanBase extends Kilobase {
return null;
} catch (error) {
console.error('Error loading board data:', error);
return null; // Return null on error
return null;
}
}

Expand All @@ -144,18 +150,26 @@ export class KanbanBase extends Kilobase {
boardId: string,
data: Record<string, { id: string; container: string }[]>,
): Promise<void> {
// Save to local storage
this.itemPositionsStore.set(data);
console.log(`Saved board data to local storage for ${boardId}`);

// Save to the API
try {
const currentPositions = this.itemPositionsStore.get();

// Ensure data structure matches what the API expects

const formattedData = {
board_id: boardId,
todo: currentPositions.TODO || [],
in_progress: currentPositions['IN-PROGRESS'] || [],
done: currentPositions.DONE || [],
};
console.log('Saving to API with data:', formattedData);

// Save to the API
const response = await fetch(
`https://kanban.kbve.com/api/get_board`,
`https://kanban.kbve.com/api/save_board`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ board_id: boardId, ...data }),
body: JSON.stringify(formattedData),
},
);

Expand All @@ -166,6 +180,7 @@ export class KanbanBase extends Kilobase {
console.log(`Saved board data to API for ${boardId}`);
} catch (error) {
console.error('Error saving board data:', error);
throw error;
}
}

Expand Down
Loading

0 comments on commit 028e8db

Please sign in to comment.