-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'part2-고학영' into part2-고학영-week11
- Loading branch information
Showing
6 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const URL = "https://bootcamp-api.codeit.kr"; | ||
|
||
export async function getUserData() { | ||
try { | ||
const response = await fetch(`${URL}/api/sample/user`, { | ||
method: "GET", | ||
}); | ||
if (!response.ok) { | ||
throw new Error("이용자정보 불러오기 실패!"); | ||
} | ||
const result = await response.json(); | ||
return result; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
export async function getFolderData() { | ||
try { | ||
const response = await fetch(`${URL}/api/sample/folder`, { | ||
method: "GET", | ||
}); | ||
if (!response.ok) { | ||
throw new Error("내용 불러오기 실패!"); | ||
} | ||
const result = await response.json(); | ||
return result; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
.CardLinkList { | ||
padding: 0; | ||
display: grid; | ||
grid-template-columns: repeat(3, 340px); | ||
place-items: center; | ||
justify-content: center; | ||
grid-gap: 25px 20px; | ||
list-style: none; | ||
} | ||
.CardLinkList { | ||
padding: 0; | ||
display: grid; | ||
grid-template-columns: repeat(3, 340px); | ||
place-items: center; | ||
justify-content: center; | ||
grid-gap: 25px 20px; | ||
list-style: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export function formatDate(value) { | ||
const date = new Date(value); | ||
return `${date.getFullYear()}. ${date.getMonth() + 1}. ${date.getDate()}`; | ||
} | ||
|
||
const HOURS = 60; | ||
const DAYS = HOURS * 24; | ||
const MONTH = DAYS * 30; | ||
const YEARS = MONTH * 12; | ||
|
||
export function calculatePostTimeElapsed(value) { | ||
const now = new Date(); | ||
const date = new Date(value); | ||
const timeDifference = (now - date) / (1000 * 60); | ||
if (timeDifference < 2) { | ||
return "1 minute ago"; | ||
} else if (timeDifference < HOURS) { | ||
return `${Math.floor(timeDifference)} minutes ago`; | ||
} else if (timeDifference < DAYS) { | ||
const hours = Math.floor(timeDifference / HOURS); | ||
return `${hours} ${hours === 1 ? "hour" : "hours"} ago`; | ||
} else if (timeDifference < MONTH) { | ||
const days = Math.floor(timeDifference / DAYS); | ||
return `${days} ${days === 1 ? "day" : "days"} ago`; | ||
} else if (timeDifference < YEARS) { | ||
const months = Math.floor(timeDifference / MONTH); | ||
return `${months} ${months === 1 ? "month" : "months"} ago`; | ||
} else { | ||
const years = Math.floor(timeDifference / YEARS); | ||
return `${years} ${years === 1 ? "year" : "years"} ago`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export function formatDate(value) { | ||
const date = new Date(value); | ||
return `${date.getFullYear()}. ${date.getMonth() + 1}. ${date.getDate()}`; | ||
} | ||
|
||
export function calculatePostTimeElapsed(value) { | ||
const now = new Date(); | ||
const date = new Date(value); | ||
const timeDifference = (now - date) / (1000 * 60); | ||
if (timeDifference < 2) { | ||
return "1 minute ago"; | ||
} else if (timeDifference <= 59) { | ||
return `${Math.floor(timeDifference)} minutes ago`; | ||
} else if (timeDifference < 60 * 24) { | ||
if (Math.floor(timeDifference / 60) === 1) { | ||
return "1 hour ago"; | ||
} else { | ||
return `${Math.floor(timeDifference / 60)} hours ago`; | ||
} | ||
} else if (timeDifference <= 60 * 24 * 30) { | ||
if (Math.floor(timeDifference / (60 * 24)) === 1) { | ||
return "1 day ago"; | ||
} else { | ||
return `${Math.floor(timeDifference / (60 * 24))} days ago`; | ||
} | ||
} else if (timeDifference < 60 * 24 * 30 * 12) { | ||
if (Math.floor(timeDifference / (60 * 24 * 30)) === 1) { | ||
return "1 month ago"; | ||
} else { | ||
return `${Math.floor(timeDifference / (60 * 24 * 30))} months ago`; | ||
} | ||
} else if (timeDifference <= 60 * 24 * 30 * 12 * 11) { | ||
if (Math.floor(timeDifference / (60 * 24 * 30 * 12)) === 1) { | ||
return "1 year ago"; | ||
} else { | ||
return `${Math.floor(timeDifference / (60 * 24 * 30 * 12))} years ago`; | ||
} | ||
} else { | ||
return `${Math.floor(timeDifference / (60 * 24 * 30 * 12))} years ago`; | ||
} | ||
} |