diff --git a/apps/site-projects/src/components/modules/Projects/Project/EditorNotification/EditorNotification.js b/apps/site-projects/src/components/modules/Projects/Project/EditorNotification/EditorNotification.js index 39c2c215b..ffe37fc8a 100644 --- a/apps/site-projects/src/components/modules/Projects/Project/EditorNotification/EditorNotification.js +++ b/apps/site-projects/src/components/modules/Projects/Project/EditorNotification/EditorNotification.js @@ -25,17 +25,21 @@ function hasEditingAccess(user, project) { } const EditorNotification = ({ project }) => { - + const [isClosed, setIsClosed] = React.useState(false) const user = useUserDataContext().userData; - if (!hasEditingAccess(user, project)) { + if (!hasEditingAccess(user, project) || isClosed) { return (<>); } + function closeEditor() { + setIsClosed(true) + } + return (
- +

It looks like you have editing permissions for this page!

Head to the dashboard in Strapi to make changes to the content of this page. diff --git a/apps/site-projects/src/components/modules/Projects/Project/Project.js b/apps/site-projects/src/components/modules/Projects/Project/Project.js index 824d631ec..6c2555e70 100644 --- a/apps/site-projects/src/components/modules/Projects/Project/Project.js +++ b/apps/site-projects/src/components/modules/Projects/Project/Project.js @@ -2,6 +2,7 @@ import React, { useRef } from "react"; // import Link from "next/link"; // import Image from "next/image"; +import { DateTime } from "luxon"; import { withTheme } from "styled-components"; import { useRouter } from "next/router"; import Button from "../../../common/Button"; @@ -30,6 +31,15 @@ function isOnTeam(id, team) { return leadersIds.includes(id) || membersIds.includes(id); } +function hasPassedOneMonth(dateString) { + const currentDate = DateTime.local(); + const completionDate = DateTime.fromISO(dateString); + + const oneMonthLater = completionDate.plus({ months: 1 }); + + return currentDate >= oneMonthLater; +} + const Project = ({ project, theme }) => { const router = useRouter(); const roleRef = useRef(); @@ -46,6 +56,7 @@ const Project = ({ project, theme }) => { const checkIfIsOnTeam = isOnTeam(userData.userData.id, project.team); const isLogged = userData.userData.id === 0 ? false : true + const milestoneIsOutdated = hasPassedOneMonth(project.board.ProjectMilestone[0].task[0].completionDate) return ( @@ -69,7 +80,7 @@ const Project = ({ project, theme }) => { images={project?.Images} /> {/*}{*/} - {isLogged && checkIfIsOnTeam ? : null} + {isLogged && checkIfIsOnTeam && !milestoneIsOutdated ? : null} {} ( key={leader.id} > - - - +

( key={member.id} > - - - +
{ + console.log({ event }); + }, + isInitallyOpen: true, + }, + decorators: [ + (story) => {story()}, + ], } as ComponentMeta; export const NotificationAlert: ComponentStory = (args) => ( diff --git a/packages/UI/src/components/molecules/Alert/Alert.tsx b/packages/UI/src/components/molecules/Alert/Alert.tsx index be528842b..e3a7e2d2b 100644 --- a/packages/UI/src/components/molecules/Alert/Alert.tsx +++ b/packages/UI/src/components/molecules/Alert/Alert.tsx @@ -4,13 +4,32 @@ import Typography from '../../atoms/Typography'; import { Container } from './StyledAlert'; import type { AlertProps } from '.'; +const variants = { + open: { opacity: 1, y: 0 }, + closed: { opacity: 0, y: '-100%' }, +}; + const Alert: React.FC> = ({ signal = 'notify', + handleClose, + isInitallyOpen = true, children, ...rest }) => { + const [isOpen, setIsOpen] = React.useState(isInitallyOpen); return ( - + {signal === 'error' ? ( ) : signal === 'success' ? ( @@ -21,7 +40,14 @@ const Alert: React.FC> = ({ <> )} {children} - + ); }; diff --git a/packages/UI/src/components/molecules/Alert/StyledAlert.ts b/packages/UI/src/components/molecules/Alert/StyledAlert.ts index 2a0e61e5f..bc477f8df 100644 --- a/packages/UI/src/components/molecules/Alert/StyledAlert.ts +++ b/packages/UI/src/components/molecules/Alert/StyledAlert.ts @@ -1,9 +1,10 @@ +import { m } from 'framer-motion'; import styled from 'styled-components'; import type { AlertProps } from '.'; type Styles = Omit, 'text'>; -export const Container = styled.div` +export const Container = styled(m.div)` display: flex; align-items: center; gap: 1rem; @@ -28,4 +29,10 @@ export const Container = styled.div` `; }} } + + & > button { + border: none; + background: none; + cursor: pointer; + } `; diff --git a/packages/UI/src/components/molecules/Alert/index.ts b/packages/UI/src/components/molecules/Alert/index.ts index 15e83376e..5a0fea3da 100644 --- a/packages/UI/src/components/molecules/Alert/index.ts +++ b/packages/UI/src/components/molecules/Alert/index.ts @@ -1,4 +1,6 @@ export interface AlertProps { signal?: 'notify' | 'success' | 'error'; + handleClose?: (e?: React.MouseEvent) => void; + isInitallyOpen?: boolean; } export { default } from './Alert';