Skip to content

Commit

Permalink
Add datepicker for editing dates
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinsonZ committed Nov 14, 2023
1 parent df20390 commit 41e7568
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 36 deletions.
158 changes: 157 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"path-browserify": "^1.0.1",
"react-beautiful-dnd": "^13.1.1",
"react-contenteditable": "^3.3.7",
"react-date-picker": "^10.5.2",
"react-use": "^17.4.0",
"uuid": "^9.0.1"
},
Expand Down
79 changes: 56 additions & 23 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function App(): JSX.Element {
{
type: "day",
id: uuidv4(),
day: "sept 19",
day: "sept 19 2023",
},
{
type: "file",
Expand Down Expand Up @@ -148,12 +148,14 @@ function App(): JSX.Element {
>
New Column
</button>
{showDev && <button
className="bg-blue-200 inline mx-2 p-1 rounded text-xl"
onClick={() => setData(fakeCardData())}
>
reset cards
</button>}
{showDev && (
<button
className="bg-blue-200 inline mx-2 p-1 rounded text-xl"
onClick={() => setData(fakeCardData())}
>
reset cards
</button>
)}
</h1>
</div>
</header>
Expand Down Expand Up @@ -229,23 +231,54 @@ function App(): JSX.Element {

return {
...col,
cards: col.cards.map((card) => {
if (card.id !== id) {
return card;
}
cards: col.cards.reduce(
(filtered, card) => {
if (card.id !== id) {
filtered.push(card);
return filtered;
}

if (card.type === "day") {
return {
...card,
day: newName,
};
} else {
return {
...card,
fileName: newName,
};
}
}),
if (newName == "") {
return filtered;
}

if (card.type === "day") {
filtered.push({
...card,
day: newName,
});
} else {
filtered.push({
...card,
fileName: newName,
});
}
return filtered;
},
[] as (SlateFile | SlateDayHeader)[]
),
};
}),
}))
}
addNewDate={() =>
setData((old) => ({
...old,
columns: old.columns.map((col) => {
if (col.id !== colData.id) {
return col;
}

return {
...col,
cards: [
...col.cards,
{
type: "day",
id: uuidv4(),
day: new Date().toString(),
},
],
};
}),
}))
Expand Down
Loading

0 comments on commit 41e7568

Please sign in to comment.