Skip to content

Commit

Permalink
Chore/data management (#39)
Browse files Browse the repository at this point in the history
merge main into chore/data-management
  • Loading branch information
garciafdezpatricia authored Jun 8, 2024
1 parent e9de2ba commit 15509e1
Show file tree
Hide file tree
Showing 9 changed files with 1,235 additions and 85 deletions.
2 changes: 1 addition & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pnpm dev
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Open [https://garciafdezpatricia.github.io/TidyTime](https://garciafdezpatricia.github.io/TidyTime) with your browser to see the result.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.

Expand Down
2 changes: 1 addition & 1 deletion client/pages/api/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export function useGoogleHandler() {

const isAuthenticatedUser = async (emailParam:string) => {
try {
const fetchResponse = await fetch('http://localhost:8080/google/auth/email', {
const fetchResponse = await fetch('https://tidytime.onrender.com/google/auth/email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
50 changes: 27 additions & 23 deletions client/pages/api/inrupt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useInruptHandler() {

const serverCheck = async () => {
try {
const response = await fetch("http://localhost:8080/health-check", {method: 'GET'});
const response = await fetch("https://tidytime.onrender.com/health-check", {method: 'GET'});
if (response.ok) {
return true;
} else {
Expand All @@ -44,7 +44,7 @@ export function useInruptHandler() {
try {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/user/session", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/user/session", {
method: 'GET',
credentials: 'include',
});
Expand Down Expand Up @@ -91,7 +91,7 @@ export function useInruptHandler() {
const getProfile = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/user/profile", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/user/profile", {
method: 'GET',
credentials: 'include',
});
Expand All @@ -113,7 +113,7 @@ export function useInruptHandler() {
const checkConfiguration = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/configuration/health-check", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/configuration/health-check", {
method: 'GET',
credentials: 'include'
})
Expand All @@ -130,7 +130,7 @@ export function useInruptHandler() {
const getAllConfiguration = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/configuration", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/configuration", {
method: 'GET',
credentials: 'include'
})
Expand All @@ -156,7 +156,7 @@ export function useInruptHandler() {
serverCheck()
.then(response => {
if (response) {
fetch("http://localhost:8080/solid/configuration/store", {
fetch("https://tidytime.onrender.com/solid/configuration/store", {
method: 'POST',
credentials: 'include',
headers: {
Expand Down Expand Up @@ -187,7 +187,7 @@ export function useInruptHandler() {
const getCalendarConfiguration = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/configuration/calendar", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/configuration/calendar", {
method: 'GET',
credentials: 'include'
});
Expand All @@ -212,7 +212,7 @@ export function useInruptHandler() {
const getTasks = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/tasks/get", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/tasks/get", {
method: 'GET',
credentials: 'include'
})
Expand All @@ -222,6 +222,7 @@ export function useInruptHandler() {
let names:string[] = [];
// listnames
if (data.data.data.listNames && data.data.data.listNames.length > 0) {
// @ts-ignore
data.data.data.listNames.forEach((list, index) => {
taskLists[index] = {key: list.id, value: []};
names[index] = list.name;
Expand All @@ -230,6 +231,7 @@ export function useInruptHandler() {
// tasks
if (data.data.data.tasks && data.data.data.tasks.length > 0) {
taskLists.map((list, index) => {
// @ts-ignore
const tasksOfTheList = data.data.data.tasks.filter((task) => {
return task.listIndex === list.key
})
Expand All @@ -254,7 +256,7 @@ export function useInruptHandler() {
const getEvents = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/events/get", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/events/get", {
method: 'GET',
credentials: 'include'
})
Expand Down Expand Up @@ -283,7 +285,7 @@ export function useInruptHandler() {
const getBoardColumns = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/configuration/board", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/configuration/board", {
method: 'GET',
credentials: 'include'
})
Expand All @@ -303,7 +305,7 @@ export function useInruptHandler() {
const getLabels = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/labels/get", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/labels/get", {
method: 'GET',
credentials: 'include'
})
Expand All @@ -324,7 +326,7 @@ export function useInruptHandler() {
const listNamesAndIds = listNames.map((listname, index) => {
return {name: listname, id: tasks[index].key};
})
fetch("http://localhost:8080/solid/data/store/listNames", {
fetch("https://tidytime.onrender.com/solid/data/store/listNames", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -347,7 +349,7 @@ export function useInruptHandler() {
const listNamesAndIds = listNames.map((listname, index) => {
return {name: listname, id: tasks[index].key};
})
fetch("http://localhost:8080/solid/data/store/lists/delete", {
fetch("https://tidytime.onrender.com/solid/data/store/lists/delete", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -371,7 +373,7 @@ export function useInruptHandler() {
try {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/get", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/get", {
method: 'GET',
credentials: 'include',
});
Expand All @@ -382,6 +384,7 @@ export function useInruptHandler() {
if (data.status === "success") {
// listnames
if (data.data.tasks.listNames && data.data.tasks.listNames.length > 0) {
// @ts-ignore
data.data.tasks.listNames.forEach((list, index) => {
taskLists[index] = {key: list.id, value: []};
names[index] = list.name;
Expand All @@ -390,6 +393,7 @@ export function useInruptHandler() {
// tasks
if (data.data.tasks.tasks && data.data.tasks.tasks.length > 0) {
taskLists.map((list, index) => {
// @ts-ignore
const tasksOfTheList = data.data.tasks.tasks.filter((task) => {
return task.listIndex === list.key
})
Expand Down Expand Up @@ -427,7 +431,7 @@ export function useInruptHandler() {
const createTask = async (task:Task) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/tasks/create", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/create", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -449,7 +453,7 @@ export function useInruptHandler() {
const createEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/events/create", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/create", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -471,7 +475,7 @@ export function useInruptHandler() {
const updateTaskDoneUndone = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/task/done", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/task/done", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -493,7 +497,7 @@ export function useInruptHandler() {
const updateTask = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/tasks/update", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/update", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -515,7 +519,7 @@ export function useInruptHandler() {
const updateEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/events/update", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/update", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -537,7 +541,7 @@ export function useInruptHandler() {
const updateTaskStatus = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/task/status", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/task/status", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -559,7 +563,7 @@ export function useInruptHandler() {
const deleteTask = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/tasks/delete", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/delete", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -581,7 +585,7 @@ export function useInruptHandler() {
const deleteEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/events/delete", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/delete", {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -603,7 +607,7 @@ export function useInruptHandler() {
const storeBoardColumns = async (boardColumns: string[]) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("http://localhost:8080/solid/data/store/boardColumns", {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/boardColumns", {
method: 'POST',
credentials: 'include',
headers: {
Expand Down
4 changes: 4 additions & 0 deletions client/pages/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export default function List() {
// if there's no task list created for this list, add it
const listIndex = lists.indexOf(repo);
if (!tasklists[listIndex]) {
// TODO: update GH with new tasklist schema
// @ts-ignore
tasklists[listIndex] = [];
}
const task:Task = {
Expand All @@ -120,9 +122,11 @@ export default function List() {
done: false,
githubHtml: issue.html_url,
githubUrl: issue.url,
// @ts-ignore
listIndex: listIndex,
status: 0,
};
// @ts-ignore
tasklists[listIndex].push(task);
});
setListNames(lists);
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Board({handleCardClick} : Props) {

const mapTasksToColumns = () => {
let result: Task[][] = [];
tasks.forEach((taskList, listIndex) => {
tasks?.forEach((taskList, listIndex) => {
taskList.value.forEach((task, taskIndex) => {
if (!result[task.status]) {
result[task.status] = [];
Expand Down Expand Up @@ -70,6 +70,7 @@ export default function Board({handleCardClick} : Props) {
}

const handleCreateNewColumn = async () => {
// @ts-ignore
const newColumns = [...boardColumns, "New column"];
setBoardColumns(newColumns);
await storeBoardColumns(newColumns);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Board/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Card({cardIndex, title, list, columnIndex, handleMoveTas
return (
<article key={cardIndex} className="board-column-content-item">
<div className="item-header">
<p>#{listNames[listIndex]}</p>
<p>#{listNames !== undefined && listNames[listIndex]}</p>
<div className="move-to-icon">
<TbArrowMoveRight
onClick={handleMovingTask}
Expand Down
1 change: 1 addition & 0 deletions client/src/components/Board/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function Column({sectionWidth, content, index, name, handleMoveTa
}

const renameList = async () => {
// @ts-ignore
let newColumns = [...boardColumns];
newColumns[index] = renameListName;
setBoardColumns(newColumns);
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Panel/ListPreferences/ListPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default function ListPanel() {


const handleLabelRename = (value:string, index:number) => {
// @ts-ignore
let result = [...labels];
let updatedColumn = result[index];
updatedColumn.name = value;
Expand All @@ -20,16 +21,18 @@ export default function ListPanel() {
}

const handleLabelDeletion = (index:number) => {
let result = labels.filter((label, labelIndex) => index !== labelIndex);
let result = labels?.filter((label, labelIndex) => index !== labelIndex);
setLabels(result);
}

const addNewInput = () => {
// @ts-ignore
let result = [...labels, {name: `New label ${labels.length + 1}`, color: "#000000"}];
setLabels(result);
}

const handleLabelColor = (color:string, index:number) => {
// @ts-ignore
let result = [...labels];
let updatedColumn = result[index];
updatedColumn.color = color;
Expand Down
Loading

0 comments on commit 15509e1

Please sign in to comment.