Skip to content

Commit

Permalink
Merge pull request #32 from KNU-AEYE/31-report-generation-page
Browse files Browse the repository at this point in the history
31-report-generation-page
  • Loading branch information
ilp-sys authored May 23, 2024
2 parents c03d784 + fa9c66b commit 537db17
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
43 changes: 43 additions & 0 deletions aeye/app/(nav)/report/generateButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use client";
import { useState } from "react";
import fetchWithInterception from "@/app/fetchWrapper";
import Alert from "@mui/material/Alert";
import CheckIcon from "@mui/icons-material/Check";
import { Button, Box } from "@mui/material";

export default function GenerateButton() {
const [showAlert, setShowAlert] = useState(false);

const sendRequest = () => {
fetchWithInterception("https://api.a-eye.live/email", { method: "POST" })
.then((response) => response.json())
.then((jsonData) => {
if (jsonData.code === 200) {
setShowAlert(true);
setTimeout(() => {
setShowAlert(false);
}, 2000); // Hide alert after 1 second
}
console.log(jsonData);
});
};

return (
<>
{showAlert && (
<Alert
icon={<CheckIcon fontSize="inherit" />}
severity="success"
sx={{ marginTop: "5px" }}
>
이메일이 성공적으로 전송되었습니다.
</Alert>
)}
<Box display="flex" justifyContent="flex-end" mb={2} mt={2}>
<Button variant="contained" onClick={sendRequest}>
생성하기
</Button>
</Box>
</>
);
}
8 changes: 5 additions & 3 deletions aeye/app/(nav)/report/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import * as React from "react";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
import Typography from "@mui/material/Typography";
import { Box } from "@mui/material";
import { Box, Container } from "@mui/material";
import GenerateButton from "@/app/(nav)/report/generateButton";

const columns: GridColDef[] = [
{ field: "id", headerName: "ID", width: 70 },
Expand Down Expand Up @@ -89,7 +90,7 @@ export default async function Report() {
}/${today.getFullYear()}`;

return (
<>
<Container>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Typography variant="h4" gutterBottom>
관제일지
Expand All @@ -99,6 +100,7 @@ export default async function Report() {
</Typography>
</Box>
<DataTable />
</>
<GenerateButton />
</Container>
);
}
2 changes: 1 addition & 1 deletion aeye/app/recoil-states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ const selectedTagsState = atom<string[]>({
default: [],
});

export { searchQueryState, memberState, selectedTagsState };
export { searchQueryState, memberState, selectedTagsState };

0 comments on commit 537db17

Please sign in to comment.