-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from kk-watanabe/add_connect_API_and_page
Add connect api and page
- Loading branch information
Showing
12 changed files
with
234 additions
and
304 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
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,35 @@ | ||
import React from "react"; | ||
|
||
import styled from "styled-components"; | ||
import tw from "twin.macro"; | ||
|
||
const LoadingContainer = styled.header` | ||
${tw` | ||
w-full | ||
h-screen | ||
flex | ||
justify-center | ||
content-center | ||
`} | ||
`; | ||
|
||
const LoadingIcon = styled.div` | ||
${tw` | ||
animate-spin | ||
h-10 | ||
w-10 | ||
border-4 | ||
border-sky-500 | ||
rounded-full | ||
border-t-transparent | ||
`} | ||
`; | ||
const Loading = () => { | ||
return ( | ||
<LoadingContainer> | ||
<LoadingIcon /> | ||
</LoadingContainer> | ||
); | ||
}; | ||
|
||
export default Loading; |
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 @@ | ||
import useSWR from "swr"; | ||
import { collection, getDocs, query } from "firebase/firestore"; | ||
import { firestore } from "@/providers/FirebaseProvider"; | ||
import { buildCosts } from "@/utils/type-utils"; | ||
|
||
const useFetcher = async (url: string) => { | ||
const costsResult = await getDocs(query(collection(firestore, url))); | ||
|
||
return costsResult.docs.map(buildCosts); | ||
}; | ||
|
||
/** | ||
* useSWR を使用する | ||
* @returns | ||
*/ | ||
export const useFetchCostsWithSWR = (url: string) => { | ||
const { | ||
data, | ||
error, | ||
mutate: setCosts, | ||
} = useSWR(url, useFetcher, { | ||
revalidateIfStale: false, | ||
revalidateOnFocus: false, | ||
revalidateOnReconnect: false, | ||
}); | ||
const costs = data === undefined ? [] : data; | ||
const isLoading = !error && !data; | ||
const isError = error; | ||
|
||
return { costs, isLoading, isError, setCosts }; | ||
}; |
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
Oops, something went wrong.
84769d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
my-cost-check – ./
my-cost-check-git-main-kk-watanabe.vercel.app
my-cost-check.vercel.app
my-cost-check-kk-watanabe.vercel.app