aboutsummaryrefslogtreecommitdiff
path: root/components/admin/dashboard/index.js
blob: 64a1d6f73b018f40abdeb32818d9058cd8fb6fff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import React, { useState } from "react";

export default function AdminDashboard({
  animeCount,
  infoCount,
  metaCount,
  report,
}) {
  const [message, setMessage] = useState("");
  const [selectedTime, setSelectedTime] = useState("");
  const [unixTimestamp, setUnixTimestamp] = useState(null);

  const handleSubmit = (e) => {
    e.preventDefault();

    if (selectedTime) {
      const unixTime = Math.floor(new Date(selectedTime).getTime() / 1000);
      setUnixTimestamp(unixTime);
    }
  };
  return (
    <div className="flex flex-col gap-5 px-5 py-10 h-full">
      <div className="flex flex-col gap-2">
        <p className="font-semibold">Stats</p>
        <div className="grid grid-cols-3 gap-5">
          <div className="flex-center flex-col bg-secondary rounded p-5">
            <p className="font-karla text-4xl">{animeCount}</p>
            <p className="font-karla text-xl">Anime</p>
          </div>
          <div className="flex-center flex-col bg-secondary rounded p-5">
            <p className="font-karla text-4xl">{infoCount}</p>
            <p className="font-karla text-xl">detail info</p>
          </div>
          <div className="flex-center flex-col bg-secondary rounded p-5">
            <p className="font-karla text-4xl">{metaCount}</p>
            <p className="font-karla text-xl">Metadata</p>
          </div>
        </div>
      </div>
      <div className="grid grid-cols-2 gap-5 h-full">
        <div className="flex flex-col gap-2">
          <p className="font-semibold">Broadcast</p>
          <div className="flex flex-col justify-between bg-secondary rounded p-5 h-full">
            <form onSubmit={handleSubmit}>
              <div className="mb-4">
                <label
                  htmlFor="message"
                  className="block text-txt font-light mb-2"
                >
                  Message
                </label>
                <input
                  type="text"
                  id="message"
                  value={message}
                  onChange={(e) => setMessage(e.target.value)}
                  required
                  className="w-full px-3 py-2 border rounded-md focus:outline-none text-black"
                />
              </div>
              <div className="mb-4">
                <label
                  htmlFor="selectedTime"
                  className="block text-txt font-light mb-2"
                >
                  Select Time
                </label>
                <input
                  type="datetime-local"
                  id="selectedTime"
                  value={selectedTime}
                  onChange={(e) => setSelectedTime(e.target.value)}
                  required
                  className="w-full px-3 py-2 border rounded-md focus:outline-none text-black"
                />
              </div>
              <button
                type="submit"
                className="bg-image text-white py-2 px-4 rounded-md hover:bg-opacity-80 transition duration-300"
              >
                Submit
              </button>
            </form>
            {unixTimestamp && (
              <p>
                Unix Timestamp: <strong>{unixTimestamp}</strong>
              </p>
            )}
          </div>
        </div>
        <div className="flex flex-col gap-2">
          <p className="font-semibold">Recent Reports</p>
          <div className="bg-secondary rounded p-5 h-full">
            <div className="rounded overflow-hidden w-full h-full">
              {report?.map((i, index) => (
                <div
                  key={index}
                  className="odd:bg-primary/80 even:bg-primary/40 p-2 flex justify-between items-center"
                >
                  {i.desc}{" "}
                  {i.severity === "Low" && (
                    <span className="relative w-5 h-5 flex-center shrink-0">
                      {/* <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-500 opacity-75"></span> */}
                      <span className="relative inline-flex rounded-full h-3 w-3 bg-green-500"></span>
                    </span>
                  )}
                  {i.severity === "Medium" && (
                    <span className="relative w-5 h-5 flex-center shrink-0">
                      {/* <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-500 opacity-75"></span> */}
                      <span className="relative inline-flex rounded-full h-3 w-3 bg-amber-500"></span>
                    </span>
                  )}
                  {i.severity === "High" && (
                    <span className="relative w-5 h-5 flex-center shrink-0">
                      {/* <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-500 opacity-75"></span> */}
                      <span className="relative animate-pulse inline-flex rounded-full h-3 w-3 bg-rose-500"></span>
                    </span>
                  )}
                  {i.severity === "Critical" && (
                    <span className="relative w-5 h-5 flex-center shrink-0">
                      <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-900 opacity-75"></span>
                      <span className="relative inline-flex rounded-full h-3 w-3 bg-red-900"></span>
                    </span>
                  )}
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
      <div className="w-full h-full">a</div>
    </div>
  );
}