1
+ 'use client'
1
2
import React from "react" ;
2
3
import Link from "next/link" ;
3
4
import Image from "next/image" ;
4
5
import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb" ;
5
6
import { Metadata } from "next" ;
6
7
import DefaultLayout from "@/components/Layouts/DefaultLayout" ;
7
8
import StudentsPresentCard from "@/components/StudentsPresentCard" ;
9
+ import { useEffect , useState } from "react" ;
10
+ import { db } from "@/firebase/config"
11
+ import { collection , getDocs } from "firebase/firestore" ;
8
12
// reg no, name, phone number, room number
9
13
10
14
@@ -31,7 +35,25 @@ const brandData = [
31
35
] ;
32
36
33
37
34
- const Attendance : React . FC = ( ) => {
38
+ const Attendance = ( ) => {
39
+
40
+ const [ students , setStudents ] = useState ( [ ] ) ;
41
+
42
+ useEffect ( ( ) => {
43
+ const getStudents = async ( ) => {
44
+ const studentsCol = collection ( db , "students" ) ;
45
+ const studentSnapshot = await getDocs ( studentsCol ) ;
46
+ const studentList = studentSnapshot . docs . map ( doc => doc . data ( ) ) ;
47
+ console . log ( studentList ) ;
48
+ setStudents ( studentList ) ;
49
+ }
50
+ getStudents ( ) ;
51
+
52
+ console . log ( "students : " , students ) ;
53
+ } , [ ] ) ;
54
+
55
+ console . log ( students ) ;
56
+
35
57
return (
36
58
< DefaultLayout >
37
59
< h1 className = "text-3xl py-5" > Hostel Attendance</ h1 >
0 commit comments