@@ -11,12 +11,12 @@ import { Loading } from "@/components/common/Loading";
11
11
import { FirstView } from "@/app/features/top/FirstView" ;
12
12
import { ToggleContents } from "@/app/features/top/ToggleContents" ;
13
13
import { RecordStatusModal } from "@/app/features/top/RecordStatusModal" ;
14
-
15
- // 仮
16
- const loginUserId = 1 ;
17
-
14
+ import { useSearchParams } from "next/navigation" ;
18
15
19
16
export const Top : FC = ( ) => {
17
+ const searchParams = useSearchParams ( ) ;
18
+ const uuid = searchParams . get ( "id" ) ;
19
+
20
20
const [ isModalOpened , setIsModalOpened ] = useState ( false )
21
21
const [ isEntered , setIsEntered ] = useState ( false ) ;
22
22
const [ usersData , setUsersData ] = useState < User [ ] > ( [ ] ) ;
@@ -27,18 +27,23 @@ export const Top: FC = () => {
27
27
useEffect ( ( ) => {
28
28
const fetchUsersData = async ( ) => {
29
29
const usersWithStatusesDataRes = await getUsersWithTodayStatuses ( ) ;
30
- const loginUserWithStatusesData = usersWithStatusesDataRes . filter ( ( userData : User ) => userData . id === loginUserId ) ;
30
+ const loginUserWithStatusesData = usersWithStatusesDataRes . filter ( ( userData : User ) => userData . auth_id === uuid ) ;
31
31
const placesDataRes = await getPlaces ( ) ;
32
32
const workingStatusesDataRes = await getWorkingStatuses ( ) ;
33
33
34
34
setUsersData ( usersWithStatusesDataRes ) ;
35
35
setLoginUserData ( loginUserWithStatusesData [ 0 ] ) ;
36
36
setPlacesData ( placesDataRes ) ;
37
37
setWorkingStatusesData ( workingStatusesDataRes ) ;
38
- setIsEntered ( loginUserWithStatusesData [ 0 ] . statuses . length > 0 ? loginUserWithStatusesData [ 0 ] . statuses [ 0 ] . is_entered : false ) ;
38
+ if ( loginUserWithStatusesData . length === 0 ) {
39
+ window . location . href = '/login' ;
40
+ setIsEntered ( false ) ;
41
+ } else {
42
+ setIsEntered ( loginUserWithStatusesData [ 0 ] . statuses . length > 0 ? loginUserWithStatusesData [ 0 ] . statuses [ 0 ] . is_entered : false ) ;
43
+ }
39
44
}
40
45
fetchUsersData ( ) ;
41
- } , [ ] ) ;
46
+ } , [ uuid ] ) ;
42
47
43
48
return (
44
49
< >
0 commit comments