import React, { useContext } from 'react'; import { Link } from 'react-router-dom'; import axios from 'axios'; import { Card, Accordion, Col, AccordionContext, useAccordionToggle, Button } from 'react-bootstrap'; import styled from 'styled-components'; const Text = styled(Card.Body)` & .WRAP { display: inline-block; text-overflow: ellipsis; width: 100%; white-space: initial; } ` function Notice({ card_id, card_index, title, date, content, admin, remove }) { function ContextAwareToggle({ children, eventKey, callback }) { const currentEventKey = useContext(AccordionContext); const decoratedOnClick = useAccordionToggle( eventKey, () => callback && callback(eventKey), ); const isCurrentEventKey = currentEventKey === eventKey; return (
{children}
); } function dateForm(day) { const post_day = new Date(day); let year = post_day.getFullYear(); let month = post_day.getMonth() + 1; let date = post_day.getDate(); month = month < 10 ? '0' + month : month; date = date < 10 ? '0' + date : date; const new_date = year + "-" + month + "-" + date; return new_date } return ( {title} {dateForm(date)} {content.split("\n").map((i, key) => { return
{i}
; })} {admin === "admin" ? (
) : null}
) } export default Notice;