Unverified Commit e31d4857 authored by Julien Bouquillon's avatar Julien Bouquillon 🐫 Committed by GitHub
Browse files

feat(posts): dont edit after 4 days (#282)


Co-authored-by: Gary van Woerkens's avatarGary van Woerkens <gary.van-woerkens@sg.social.gouv.fr>
parent 65101166
......@@ -6,12 +6,15 @@ import React from "react"
import Delete from "./Delete"
import Edit from "./Edit"
const MAX_EDITABLE_POST_AGE = 1000 * 60 * 60 * 24 * 4 // 4 days
const isOldPost = post => new Date().getTime() - new Date(post.created_at).getTime() > MAX_EDITABLE_POST_AGE;
const Header = ({ post }) => {
const { team_slug } = post
const user = useUser() || {}
const teams = useTeams() || {}
const team = teams.find((team) => team.slug === post.team_slug)
const isAllowed = team && (user.isAdmin || user.teams?.includes(team_slug))
const isAllowed = team && (user.isAdmin || (user.teams?.includes(team_slug) && !isOldPost(post)))
return (
<div className="header">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment