From 02511fa550ee90f35b89f4d4788069e7cd2e45bd Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Fri, 18 Mar 2022 15:28:51 +0330 Subject: [PATCH] reza connected blog join --- src/redux/actions/blog.js | 2 ++ src/redux/reducers/blog.js | 34 +++------------------- src/views/Blogs/layouts/Hashtags.js | 4 +-- src/views/Blogs/layouts/Join.js | 44 +++++++++++++++++++++++------ 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/redux/actions/blog.js b/src/redux/actions/blog.js index 0301cbe..0cd3123 100644 --- a/src/redux/actions/blog.js +++ b/src/redux/actions/blog.js @@ -8,6 +8,8 @@ const blog = { await proxy.get("public/blogInfo", data, { dispatch }), active: (data) => async (dispatch) => await dispatch({ type: "public/active", data }), + letterAdd: (data) => async (dispatch) => + await proxy.post("news/LetterAdd", data, { dispatch }), }; export default blog; diff --git a/src/redux/reducers/blog.js b/src/redux/reducers/blog.js index b96dde6..56e0b3c 100644 --- a/src/redux/reducers/blog.js +++ b/src/redux/reducers/blog.js @@ -5,36 +5,7 @@ const initialState = { error: null, list: [], info: null, - hashtags: [ - { - title: "فناوری اطلاعات", - color: "#019BC3", - }, - { - title: "سخت افزار", - color: "#7CC301", - }, - { - title: "آموزشی", - color: "#C5B90C", - }, - { - title: "فرهنگی", - color: "#C2684D", - }, - { - title: "معرفی کتاب", - color: "#8B4DC2", - }, - { - title: "مهارت آموزی", - color: "#780D6D", - }, - { - title: "پیشرفت شخصی", - color: "#E63F15", - }, - ], + hashtags : [], active: null, }; export default function blog(state = initialState, action) { @@ -57,6 +28,9 @@ export default function blog(state = initialState, action) { }; case "public/blogInfo": return { ...state, loading: false, error: null, blog: data }; + case "news/LetterAdd": + toast.success('.به خبرنامه دانوین خوش آمدید'); + return { ...state, loading: false, error: null }; case "blog/loading": return { ...state, loading: true }; case "blog/error": diff --git a/src/views/Blogs/layouts/Hashtags.js b/src/views/Blogs/layouts/Hashtags.js index c74052a..50ff0af 100644 --- a/src/views/Blogs/layouts/Hashtags.js +++ b/src/views/Blogs/layouts/Hashtags.js @@ -10,8 +10,8 @@ export const Hashtags = ({ hashtags }) => { diff --git a/src/views/Blogs/layouts/Join.js b/src/views/Blogs/layouts/Join.js index 1082de1..ca43a1b 100644 --- a/src/views/Blogs/layouts/Join.js +++ b/src/views/Blogs/layouts/Join.js @@ -1,10 +1,17 @@ import React from "react"; import { connect } from "react-redux"; +import { blog } from "../../../redux/actions"; //assets import picImage from "../pic.svg"; -export const Join = ({ isMobile }) => { +export const Join = ({ isMobile, join, userId }) => { + const [email, setEmail] = React.useState(""); + + const submit = (e) => { + e.preventDefault(); + userId ? join({ userId, email }) : join({ email }); + }; return (
{ alt="" style={{ height: isMobile ? "calc(100vw / 2.5)" : "115%", - transform: isMobile ? "translateY(15%) translateX(25%)" : "translateY(-15%)", + transform: isMobile + ? "translateY(15%) translateX(25%)" + : "translateY(-15%)", }} /> {isMobile && (
-
+ submit(e)} + > setEmail(e.target.value)} /> @@ -35,30 +49,41 @@ export const Join = ({ isMobile }) => {
)}
- اینجا خبری از اسپم نیست! + + اینجا خبری از اسپم نیست! + خبرنامه وبلاگ دانوین -

+

بهترین و آخرین اخبار علمی و آموزشی را در ایمیل خودتون دریافت کنید. هر زمان هم که لازم نداشتید می تونید عضویت رو لغو کنید

{!isMobile && (
- + submit(e)} + > setEmail(e.target.value)} />