-
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 #35 from aswanthabam/dev
feat (admin): admin panel updated
- Loading branch information
Showing
11 changed files
with
491 additions
and
11 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
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,55 @@ | ||
import React, { useState } from "react"; | ||
import { _Event, _EventCreateData } from "../../../../utils/types"; | ||
import { useToast } from "../../../../components/toast/useToast"; | ||
import { addAdmin } from "../../../../apis/adminApi"; | ||
|
||
const AddAdmin: React.FC = () => { | ||
const [formData, setFormData] = useState({ | ||
email: "", | ||
}); | ||
const { setToastStatus } = useToast(); | ||
const handleChange = ( | ||
e: React.ChangeEvent< | ||
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | ||
> | ||
) => { | ||
console.log(e.target.id, e.target.value); | ||
setFormData({ | ||
...formData, | ||
[e.target.id]: e.target.value, | ||
}); | ||
}; | ||
|
||
const handleSubmit = async (event: React.FormEvent) => { | ||
event.preventDefault(); | ||
console.log("Form submitted!"); | ||
console.log(formData); | ||
await addAdmin(formData, setToastStatus); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h3 className="underline start" style={{ marginBottom: "30px" }}> | ||
Add A new Administrator | ||
</h3> | ||
<form onSubmit={handleSubmit} method="post"> | ||
<div className="mb-3"> | ||
<label htmlFor="title" className="form-label"> | ||
Target Email ID: | ||
</label> | ||
<input | ||
type="email" | ||
id="email" | ||
className="form-control" | ||
value={formData.email} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</div> | ||
<button className="btn btn-primary">Add Admin</button> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AddAdmin; |
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,68 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { | ||
_AdminErrorLog, | ||
_Event, | ||
_EventCreateData, | ||
_EventInfo, | ||
} from "../../../../utils/types"; | ||
import { errorLog } from "../../../../apis/adminApi"; | ||
|
||
const ErrorLog: React.FC = () => { | ||
const [logs, setLogs] = useState<_AdminErrorLog[]>([]); | ||
const [limit, setLimit] = useState<number>(10); | ||
const getLogs = (limit = 10) => { | ||
errorLog(limit).then((res) => { | ||
console.log(res); | ||
setLogs(res ? res : []); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
getLogs(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h3 className="underline start" style={{ marginBottom: "30px" }}> | ||
Error Logs | ||
</h3> | ||
<input | ||
type="number" | ||
placeholder="Limit" | ||
onChange={(e) => { | ||
setLimit(parseInt(e.target.value)); | ||
}} | ||
/> | ||
<input | ||
type="button" | ||
value="Refresh" | ||
onClick={() => { | ||
getLogs(limit); | ||
}} | ||
/> | ||
{logs.map((l) => { | ||
return ( | ||
<div className="card m-2"> | ||
<div className="card-body"> | ||
<h6 className="card-title ">URL : {l.url}</h6> | ||
<p className="card-text"> | ||
Requested At :{" "} | ||
<code>{new Date(l.requestTime).toLocaleString()}</code> | ||
<br /> | ||
Response At :{" "} | ||
<code>{new Date(l.responseTime).toLocaleString()}</code> | ||
<br /> | ||
Error : <code>{l.error}</code> | ||
<br /> | ||
Response : <code>{l.stack}</code> | ||
<br /> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ErrorLog; |
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,78 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { | ||
_AdminRequestLog, | ||
_Event, | ||
_EventCreateData, | ||
_EventInfo, | ||
} from "../../../../utils/types"; | ||
import { requestLog } from "../../../../apis/adminApi"; | ||
|
||
const RequestLog: React.FC = () => { | ||
const [logs, setLogs] = useState<_AdminRequestLog[]>([]); | ||
const [limit, setLimit] = useState<number>(10); | ||
const getLogs = (limit = 10) => { | ||
requestLog(limit).then((res) => { | ||
console.log(res); | ||
setLogs(res ? res : []); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
getLogs(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h3 className="underline start" style={{ marginBottom: "30px" }}> | ||
Request Logs | ||
</h3> | ||
<input | ||
type="number" | ||
placeholder="Limit" | ||
onChange={(e) => { | ||
setLimit(parseInt(e.target.value)); | ||
}} | ||
/> | ||
<input | ||
type="button" | ||
value="Refresh" | ||
onClick={() => { | ||
getLogs(limit); | ||
}} | ||
/> | ||
{logs.map((l) => { | ||
return ( | ||
<div className="card m-2"> | ||
<div className="card-body"> | ||
<h6 className="card-title "> | ||
URL : {l.url} ({l.status}) | ||
</h6> | ||
Requested At :{" "} | ||
<code>{new Date(l.requestTime).toLocaleString()}</code> | ||
<br /> | ||
Response At :{" "} | ||
<code>{new Date(l.responseTime).toLocaleString()}</code> | ||
<br /> | ||
<p className="card-text"> | ||
Request :{" "} | ||
<code> | ||
{l.data ? JSON.stringify(l.data, [], 2) : "No data"} | ||
</code> | ||
<br /> | ||
Response :{" "} | ||
<code> | ||
{l.response | ||
? JSON.stringify(l.response, null, 2) | ||
: "No Response"} | ||
</code> | ||
<br /> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default RequestLog; |
Oops, something went wrong.