Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/routes/MemberRecuritment/components/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import localStorageUtils from '@/utils/localStorageUtils';
import productApi from '@/utils/productApi';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import PublicIcon from '@mui/icons-material/Public';
import PublicOffIcon from '@mui/icons-material/PublicOffOutlined';

function Element({ event }) {
const [showMileStone, setShowMileStone] = useState(false);
Expand All @@ -39,7 +40,12 @@ function Element({ event }) {
var newDate = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' ';
return newDate;
}

function isDateValid(dateString) {
const currentDate = new Date();
const [day, month, year] = dateString.split('/');
const inputDate = new Date(year, month - 1, day); // month is 0-based in Date constructor
return inputDate <= currentDate;
}
const [edit, setEdit] = useState(false);
const handleOpenEdit = (event) => {
event.stopPropagation();
Expand Down Expand Up @@ -94,7 +100,11 @@ function Element({ event }) {
<LeftSide>
<Hero>
<section>
<PublicIcon />
{isDateValid(ChangeFormatDate(event.startTime)) ? (
<PublicIcon />
) : (
<PublicOffIcon style={{ color: 'gray' }} />
)}
</section>
<h5> {event.title}</h5>
</Hero>
Expand Down Expand Up @@ -133,7 +143,11 @@ function Element({ event }) {
<LeftSide>
<Hero>
<section>
<PublicIcon />
{isDateValid(ChangeFormatDate(event.startTime)) ? (
<PublicIcon />
) : (
<PublicOffIcon style={{ color: 'gray' }} />
)}
</section>
<h5> {event.title}</h5>
</Hero>
Expand Down