Skip to content

Commit 4c6a43e

Browse files
authored
feat: useSessionize (#171)
* feat: useSettionize * add EOL
1 parent 3d3ff1f commit 4c6a43e

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

.env.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
NEXT_PUBLIC_AUTH_PASSWORD_HASH="password_hashed_via_sha256"
2+
NEXT_PUBLIC_SESSIONIZE_ID="ih39r9wq"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"react-dom": "18.2.0",
2323
"react-i18next": "11.18.6",
2424
"react-rewards": "^2.0.4",
25+
"swr": "2.0.3",
2526
"use-local-storage-state": "18.1.1"
2627
},
2728
"devDependencies": {

src/components/pages/PageTop/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NextPage } from 'next'
22
import { Layout } from 'src/components/commons'
33
import { useTranslation } from 'react-i18next'
4+
import { useSessionize } from 'src/modules/sessionize/hooks'
45
import {
56
MainVisual,
67
TopDescription,
@@ -12,6 +13,10 @@ import {
1213
export const PageTop: NextPage = () => {
1314
const { t } = useTranslation()
1415

16+
// TODO(@maito1201): 取得したデータを基にセッションデータを表示する
17+
const { data } = useSessionize()
18+
console.log('session data', data)
19+
1520
return (
1621
<Layout>
1722
<MainVisual />

src/modules/sessionize/hooks.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import useSWR, { Fetcher } from 'swr'
2+
3+
const fetcher: Fetcher<string> = (url: string): Promise<any> => fetch(url).then(res => res.json())
4+
export const useSessionize = () => {
5+
return useSWR(`https://sessionize.com/api/v2/${process.env.NEXT_PUBLIC_SESSIONIZE_ID}/view/All`, fetcher)
6+
}

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10993,6 +10993,13 @@ supports-preserve-symlinks-flag@^1.0.0:
1099310993
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
1099410994
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
1099510995

10996+
10997+
version "2.0.3"
10998+
resolved "https://registry.yarnpkg.com/swr/-/swr-2.0.3.tgz#9fe59a17f55b0fdddccd76b7b2f723f9f8e2263e"
10999+
integrity sha512-sGvQDok/AHEWTPfhUWXEHBVEXmgGnuahyhmRQbjl9XBYxT/MSlAzvXEKQpyM++bMPaI52vcWS2HiKNaW7+9OFw==
11000+
dependencies:
11001+
use-sync-external-store "^1.2.0"
11002+
1099611003
symbol.prototype.description@^1.0.0:
1099711004
version "1.0.5"
1099811005
resolved "https://registry.yarnpkg.com/symbol.prototype.description/-/symbol.prototype.description-1.0.5.tgz#d30e01263b6020fbbd2d2884a6276ce4d49ab568"
@@ -11556,7 +11563,7 @@ [email protected]:
1155611563
resolved "https://registry.yarnpkg.com/use-local-storage-state/-/use-local-storage-state-18.1.1.tgz#40e535aebed7770258e0a3a7b6923a86d9c0c52f"
1155711564
integrity sha512-09bl6q3mkSlkEt8KeBPCmdPEWEojWYF70Qbz+7wkfQX1feaFITM9m84+h0Jr6Cnf/IvpahkFh7UbX2VNN3ioTQ==
1155811565

11559-
11566+
[email protected], use-sync-external-store@^1.2.0:
1156011567
version "1.2.0"
1156111568
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
1156211569
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==

0 commit comments

Comments
 (0)