mot de passe oublié
continuous-integration/drone/push Build encountered an error Details

master
Noan07 2 years ago
parent 245383a11e
commit 9a0117fb1d

@ -5,15 +5,41 @@ import { addPost, getPosts } from '../actions/post.actions';
import { UidContext } from './AppContext'; import { UidContext } from './AppContext';
import IconeFavor from '../assets/img/logo.png'; import IconeFavor from '../assets/img/logo.png';
const AjoutLien = () => { const AjoutLien = () => {
const uid = useContext(UidContext); const uid = useContext(UidContext);
const userData = useSelector((state) => state.user.user); const userData = useSelector((state) => state.user.user);
const [displayAdd, setDisplayAdd] = useState(false); const [displayAdd, setDisplayAdd] = useState(false);
const [lien, setLien] = useState(""); const [lien, setLien] = useState("");
const [privee, setPrivee] = useState(false);
const [image, setImage] = useState("");
const [publique, setPublique] = useState(false);
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [tag, setTag] = useState(''); const [tag, setTag] = useState('');
const [tags, setTags] = useState([]); const [tags, setTags] = useState([]);
const dispatch = useDispatch(); const dispatch = useDispatch();
const [preview, setPreview] = useState({ image: '', title: '', description: '' });
const apiPost = () => {
//const key = '9f24d981b6f0ddfce993ce4a20d58867';
const keyApi = '2865b6b9d9571dc00bf940fad5728248';
const fullLink = `http://api.linkpreview.net/?key=${keyApi}&q=${lien}`;
axios
.get(fullLink)
.then((res) => setPreview(res.data))
.catch((err) => console.error(err));
if(preview.image === "") {
setImage("");
}
else {
console.log(typeof preview.image);
setImage(preview.image);
};
};
const handleSubmit = (e) => { const handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
@ -22,10 +48,10 @@ const AjoutLien = () => {
} }
const handlePost = async () => { const handlePost = async () => {
if(isValidUrl(lien)){ if(isValidUrl(lien)){
if ((description || lien) && tags.length > 0){ if ((description || lien) && tags.length > 0){
apiPost();
putData(); putData();
dispatch(getPosts()); dispatch(getPosts());
cancelPost(); cancelPost();
@ -48,7 +74,7 @@ const AjoutLien = () => {
const putData = async() => { const putData = async() => {
axios axios
.post(`${process.env.REACT_APP_API_URL}api/post/`, { postedId: userData._id, message: description, lien: lien, tags: tags} .post(`${process.env.REACT_APP_API_URL}api/post/`, { postedId: userData._id, message: description, lien: lien, tags: tags, publique: publique, privee:privee, image: image,}
) )
.then((res) => { .then((res) => {
// if (res.data.errors) { // if (res.data.errors) {
@ -65,7 +91,7 @@ const AjoutLien = () => {
}catch { }catch {
return false; return false;
} }
} };
return ( return (
<> <>
@ -118,6 +144,22 @@ const AjoutLien = () => {
/> />
</div> </div>
<fieldset>
<legend>Type publication:</legend>
<div>
<input type="checkbox" id="scales" name="scales" onChange={(e) => setPrivee(e.target.value)}
value={true}/>
<label for="scales">Privée</label>
</div>
<div>
<input type="checkbox" id="horns" name="horns" onChange={(e) => setPublique(e.target.value)}
value={true}/>
<label for="horns">Public</label>
</div>
</fieldset>
<input <input
type="text" type="text"
value={tag} value={tag}

@ -27,6 +27,7 @@ const LinkPreview = ({ link }) => {
return (<div className='alignementLien'><a className="LienPostHome" href={link}>{link}</a></div>); return (<div className='alignementLien'><a className="LienPostHome" href={link}>{link}</a></div>);
} }
else { else {
console.log(typeof preview.image);
return ( return (
<> <>
<div className='alignementLien'> <div className='alignementLien'>
@ -49,7 +50,7 @@ const Post = ( { post } ) => {
useEffect(() => { useEffect(() => {
!isEmpty(usersData[0]) && !isEmpty(userData) && setIsLoading(false) !isEmpty(usersData) && !isEmpty(userData) && setIsLoading(false)
}) })
return ( return (

@ -25,6 +25,9 @@ module.exports.createPost = async (req, res) => {
lien: req.body.lien, lien: req.body.lien,
likers: [], likers: [],
tags: req.body.tags, tags: req.body.tags,
image: req.body.image,
publique: req.body.publique,
privee: req.body.privee,
comments: [], comments: [],
}); });

@ -20,11 +20,21 @@ const postSchema = new mongoose.Schema(
likers: { likers: {
type: [String], type: [String],
required: true required: true
}, },-
tags: { tags: {
type: [String], type: [String],
required: true required: true
}, },
image:{
type: String,
},
publique: {
type: Boolean
},
privee: {
type: Boolean
},
comments: { comments: {
type: [ type: [
{ {

@ -12,7 +12,11 @@ router.post('/login', authController.signIn);
//router.post('/send-verification-email', authController.verifEmail); //router.post('/send-verification-email', authController.verifEmail);
//retirer le token (cookie) //retirer le token (cookie)
router.get('/logout', authController.logout); router.get('/logout', authController.logout);
router.post('/verify-email',authController.verifyEmail);
router.post('/forgotpassword',authController.forgotPassword);
router.post('/reset/:token',authController.resetPost);
router.get('/reset/:token',authController.resetGet);
router.post('/send-verification-email',authController.sendVerificationEmail);
// user // user
router.get('/', userController.getAllUsers); router.get('/', userController.getAllUsers);

Loading…
Cancel
Save