Skip to content

Commit

Permalink
Adding Tidier view (#41)
Browse files Browse the repository at this point in the history
tidier done
  • Loading branch information
garciafdezpatricia authored Jun 27, 2024
1 parent 429f329 commit 3ec0943
Show file tree
Hide file tree
Showing 16 changed files with 885 additions and 101 deletions.
16 changes: 8 additions & 8 deletions client/pages/api/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function useGithubHandler() {

const serverCheck = async () => {
try {
const response = await fetch("https://tidytime.onrender.com/health-check", {method: 'GET'});
const response = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/health-check`, {method: 'GET'});
if (response.ok) {
return true;
} else {
Expand All @@ -24,7 +24,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
window.location.assign("https://tidytime.onrender.com/github/auth");
window.location.assign(`${process.env.NEXT_PUBLIC_BACK_URL}/github/auth`);
} else {
toast.error('Server appears to be down');
}
Expand All @@ -37,7 +37,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const userResponse = await fetch('https://tidytime.onrender.com/github/logout', {
const userResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/logout`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -61,7 +61,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const userResponse = await fetch('https://tidytime.onrender.com/github/user/data', {
const userResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/user/data`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -87,7 +87,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const issues = await fetch('https://tidytime.onrender.com/github/issues/get?user=' + user, {
const issues = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/issues/get?user=` + user, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -108,7 +108,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const issues = await fetch('https://tidytime.onrender.com/github/issues/close', {
const issues = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/issues/close`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -137,7 +137,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const issues = await fetch('https://tidytime.onrender.com/github/issues/open', {
const issues = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/issues/open`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -166,7 +166,7 @@ export function useGithubHandler() {
try {
const response = await serverCheck();
if (response) {
const issues = await fetch('https://tidytime.onrender.com/github/issues/update', {
const issues = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/github/issues/update`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
16 changes: 8 additions & 8 deletions client/pages/api/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function useGoogleHandler() {
const { events, setEvents } = useEventContext();

const serverCheck = () => {
return fetch("https://tidytime.onrender.com/health-check", { method: 'GET' })
return fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/health-check`, { method: 'GET' })
.then(response => {
if (response.ok) {
return true;
Expand All @@ -26,7 +26,7 @@ export function useGoogleHandler() {
serverCheck()
.then(response => {
if (response) {
fetch('https://tidytime.onrender.com/google/auth/logout', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/auth/logout`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -66,7 +66,7 @@ export function useGoogleHandler() {
serverCheck()
.then(response => {
if (response) {
fetch('https://tidytime.onrender.com/google/auth/url', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/auth/url`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -128,7 +128,7 @@ export function useGoogleHandler() {
.then(response => {
if (response) {
return new Promise<boolean>((resolve, reject) => {
fetch('https://tidytime.onrender.com/google/calendar/list', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/calendar/list`, {
method: 'GET',
credentials: 'include',
})
Expand Down Expand Up @@ -171,7 +171,7 @@ export function useGoogleHandler() {
.then(response => {
if (response) {
return new Promise<boolean>((resolve, reject) => {
fetch('https://tidytime.onrender.com/google/events/get', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/events/get`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json'},
Expand Down Expand Up @@ -252,7 +252,7 @@ export function useGoogleHandler() {
// format date to google format
const ISOStartDate = new Date(new Date(eventToShare.start).getTime() - (new Date(eventToShare.start).getTimezoneOffset() * 60000)).toISOString();
const ISOEndDate = new Date(new Date(eventToShare.end).getTime() - (new Date(eventToShare.end).getTimezoneOffset() * 60000)).toISOString();
fetch('https://tidytime.onrender.com/google/events/insert', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/events/insert`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -311,7 +311,7 @@ export function useGoogleHandler() {
// format date to google format
const ISOStartDate = new Date(new Date(eventToUpdate.start).getTime() - (new Date(eventToUpdate.start).getTimezoneOffset() * 60000)).toISOString();
const ISOEndDate = new Date(new Date(eventToUpdate.end).getTime() - (new Date(eventToUpdate.end).getTimezoneOffset() * 60000)).toISOString();
fetch('https://tidytime.onrender.com/google/events/update', {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/events/update`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -352,7 +352,7 @@ export function useGoogleHandler() {

const isAuthenticatedUser = async (emailParam:string) => {
try {
const fetchResponse = await fetch('https://tidytime.onrender.com/google/auth/email', {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/google/auth/email`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
50 changes: 25 additions & 25 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("https://tidytime.onrender.com/health-check", {method: 'GET'});
const response = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/health-check`, {method: 'GET'});
if (response.ok) {
return true;
} else {
Expand All @@ -33,7 +33,7 @@ export function useInruptHandler() {
serverCheck()
.then(response => {
if (response) {
window.location.assign("https://tidytime.onrender.com/solid/login");
window.location.assign(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/login`);
} else {
toast.error('Server appears to be down');
}
Expand All @@ -44,7 +44,7 @@ export function useInruptHandler() {
try {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/user/session", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/user/session`, {
method: 'GET',
credentials: 'include',
});
Expand All @@ -70,7 +70,7 @@ export function useInruptHandler() {
serverCheck()
.then(response => {
if (response) {
fetch("https://tidytime.onrender.com/solid/logout", {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/logout`, {
method: 'GET',
credentials: 'include',
})
Expand All @@ -91,7 +91,7 @@ export function useInruptHandler() {
const getProfile = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/user/profile", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/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("https://tidytime.onrender.com/solid/configuration/health-check", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/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("https://tidytime.onrender.com/solid/configuration", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/configuration`, {
method: 'GET',
credentials: 'include'
})
Expand All @@ -156,7 +156,7 @@ export function useInruptHandler() {
serverCheck()
.then(response => {
if (response) {
fetch("https://tidytime.onrender.com/solid/configuration/store", {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/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("https://tidytime.onrender.com/solid/configuration/calendar", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/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("https://tidytime.onrender.com/solid/data/tasks/get", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/tasks/get`, {
method: 'GET',
credentials: 'include'
})
Expand Down Expand Up @@ -256,7 +256,7 @@ export function useInruptHandler() {
const getEvents = async () => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/events/get", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/events/get`, {
method: 'GET',
credentials: 'include'
})
Expand Down Expand Up @@ -285,7 +285,7 @@ export function useInruptHandler() {
const getBoardColumns = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/configuration/board", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/configuration/board`, {
method: 'GET',
credentials: 'include'
})
Expand All @@ -305,7 +305,7 @@ export function useInruptHandler() {
const getLabels = async () => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/labels/get", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/labels/get`, {
method: 'GET',
credentials: 'include'
})
Expand All @@ -326,7 +326,7 @@ export function useInruptHandler() {
const listNamesAndIds = listNames.map((listname, index) => {
return {name: listname, id: tasks[index].key};
})
fetch("https://tidytime.onrender.com/solid/data/store/listNames", {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/listNames`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -349,7 +349,7 @@ export function useInruptHandler() {
const listNamesAndIds = listNames.map((listname, index) => {
return {name: listname, id: tasks[index].key};
})
fetch("https://tidytime.onrender.com/solid/data/store/lists/delete", {
fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/lists/delete`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -373,7 +373,7 @@ export function useInruptHandler() {
try {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/get", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/get`, {
method: 'GET',
credentials: 'include',
});
Expand Down Expand Up @@ -431,7 +431,7 @@ export function useInruptHandler() {
const createTask = async (task:Task) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/create", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/tasks/create`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -453,7 +453,7 @@ export function useInruptHandler() {
const createEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/create", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/events/create`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -475,7 +475,7 @@ export function useInruptHandler() {
const updateTaskDoneUndone = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/task/done", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/task/done`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -497,7 +497,7 @@ export function useInruptHandler() {
const updateTask = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/update", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/tasks/update`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -519,7 +519,7 @@ export function useInruptHandler() {
const updateEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/update", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/events/update`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -541,7 +541,7 @@ export function useInruptHandler() {
const updateTaskStatus = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/task/status", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/task/status`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -563,7 +563,7 @@ export function useInruptHandler() {
const deleteTask = async (task:Task) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/tasks/delete", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/tasks/delete`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -585,7 +585,7 @@ export function useInruptHandler() {
const deleteEvent = async (event: Event) => {
const response = await serverCheck();
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/events/delete", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/events/delete`, {
method: 'POST',
credentials: 'include',
headers: {
Expand All @@ -607,7 +607,7 @@ export function useInruptHandler() {
const storeBoardColumns = async (boardColumns: string[]) => {
const response = await serverCheck()
if (response) {
const fetchResponse = await fetch("https://tidytime.onrender.com/solid/data/store/boardColumns", {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BACK_URL}/solid/data/store/boardColumns`, {
method: 'POST',
credentials: 'include',
headers: {
Expand Down
Loading

0 comments on commit 3ec0943

Please sign in to comment.