From f492f8380facf0d5090f716a0e632da59235ac01 Mon Sep 17 00:00:00 2001 From: harsh12-99 Date: Wed, 4 Oct 2023 17:55:04 +0530 Subject: [PATCH 01/18] moved cards simuntaneously --- .../Video/components/SubtitleBoxes.jsx | 85 ++++++++++++------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/src/containers/Organization/Video/components/SubtitleBoxes.jsx b/src/containers/Organization/Video/components/SubtitleBoxes.jsx index 2959d059..933a413b 100644 --- a/src/containers/Organization/Video/components/SubtitleBoxes.jsx +++ b/src/containers/Organization/Video/components/SubtitleBoxes.jsx @@ -7,7 +7,6 @@ import React, { } from "react"; import isEqual from "lodash/isEqual"; import DT from "duration-time-conversion"; -import { useParams } from "react-router-dom"; import { useDispatch, useSelector } from "react-redux"; import { copySubs, @@ -34,7 +33,6 @@ import C from "redux/constants"; import { APITransport, FetchTranscriptPayloadAPI, - SaveTranscriptAPI, setSubtitles, } from "redux/actions"; @@ -48,6 +46,8 @@ function magnetically(time, closeTime) { let lastTarget = null; let lastSub = null; +let previousTarget = null; +let nextTarget = null; let lastType = ""; let lastX = 0; let lastIndex = -1; @@ -57,7 +57,6 @@ let isDroging = false; export default memo( function ({ render, currentTime }) { - const { taskId } = useParams(); const classes = VideoLandingStyle(); const dispatch = useDispatch(); @@ -103,20 +102,6 @@ export default memo( // eslint-disable-next-line }, [subtitles, currentIndex, isPlaying(player)]); - const saveTranscript = async (taskType, subs = subtitles) => { - const reqBody = { - task_id: taskId, - offset: currentPage, - limit: limit, - payload: { - payload: subs, - }, - }; - - const obj = new SaveTranscriptAPI(reqBody, taskType); - dispatch(APITransport(obj)); - }; - const removeSub = useCallback( (sub) => { const index = hasSub(sub); @@ -137,25 +122,31 @@ export default memo( [limit, currentPage] ); - const updateSub = (sub, obj) => { - const index = hasSub(sub); - const copySub = [...subtitles]; + const updateSub = useCallback( + (sub, obj) => { + const index = hasSub(sub); + const copySub = [...subtitles]; - if (index < 0) return; + if (index < 0) return; - Object.assign(sub, obj); + Object.assign(sub, obj); - copySub[index] = sub; - dispatch(setSubtitles(copySub, C.SUBTITLES)); - }; + copySub[index] = sub; + dispatch(setSubtitles(copySub, C.SUBTITLES)); + }, + // eslint-disable-next-line + [subtitles] + ); - const onMouseDown = (sub, event, type) => { - lastSub = sub; + const onMouseDown = (index, event, type) => { + previousTarget = $subsRef.current.children[index - 1]; + lastSub = subtitles[index]; + nextTarget = $subsRef.current.children[index + 1]; if (event.button !== 0) return; isDroging = true; lastType = type; lastX = event.pageX; - lastIndex = subtitles.indexOf(sub); + lastIndex = index; lastTarget = $subsRef.current.children[lastIndex]; lastWidth = parseFloat(lastTarget.style.width); }; @@ -189,7 +180,14 @@ export default memo( lastSub.endTime + timeDiff, next ? next.startTime : null ); + + const nextCardStartTime = endTime; + const previousCardEndTime = startTime; + const width = (endTime - startTime) * 10 * gridGap; + const nextCardWidth = (next.endTime - nextCardStartTime) * 10 * gridGap; + const previousCardWidth = + (previousCardEndTime - previou.startTime) * 10 * gridGap; if (lastType === "left") { if (startTime >= 0 && lastSub.endTime - startTime >= 0.2) { @@ -199,6 +197,12 @@ export default memo( updateSub(lastSub, { start_time }); } + if(index > 0 && startTime < DT.t2d(previou.end_time) && startTime !== DT.t2d(previou.end_time)) { + updateSub(lastSub, { start_time }); + updateSub(previou, { end_time: start_time }); + previousTarget.style.width = `${previousCardWidth}px`; + } + if (index === 0) { updateSub(lastSub, { start_time }); } @@ -209,11 +213,26 @@ export default memo( if (endTime >= 0 && endTime - lastSub.startTime >= 0.2) { const end_time = DT.d2t(endTime); - if (index >= 0 && index !== subtitles.length - 1 && endTime <= DT.t2d(next.start_time)) { + if ( + index >= 0 && + index !== subtitles.length - 1 && + endTime <= DT.t2d(next.start_time) + ) { + updateSub(lastSub, { end_time }); + } + + if ( + index >= 0 && + index !== subtitles.length - 1 && + endTime > DT.t2d(next.start_time) && + endTime !== DT.t2d(next.start_time) + ) { updateSub(lastSub, { end_time }); + updateSub(next, { start_time: end_time }); + nextTarget.style.width = `${nextCardWidth}px`; } - if(index === subtitles.length - 1 && endTime < lastSub.endTime) { + if (index === subtitles.length - 1 && endTime < lastSub.endTime) { updateSub(lastSub, { end_time }); } } else { @@ -372,13 +391,13 @@ export default memo( left: 0, width: 10, }} - onMouseDown={(event) => onMouseDown(sub, event, "left")} + onMouseDown={(event) => onMouseDown(key, event, "left")} >
onMouseDown(sub, event)} + onMouseDown={(event) => onMouseDown(key, event)} >

{taskDetails.task_type.includes("TRANSCRIPTION") || @@ -394,7 +413,7 @@ export default memo( right: 0, width: 10, }} - onMouseDown={(event) => onMouseDown(sub, event, "right")} + onMouseDown={(event) => onMouseDown(key, event, "right")} >

{sub.duration}
From 0f54956863af1aaffd4052209b3155989afa64f2 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Wed, 11 Oct 2023 17:04:58 +0530 Subject: [PATCH 02/18] fix for snackbar closing immediately for transcription task --- src/containers/Organization/Video/RightPanel.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/containers/Organization/Video/RightPanel.jsx b/src/containers/Organization/Video/RightPanel.jsx index 52e5571d..1267bca4 100644 --- a/src/containers/Organization/Video/RightPanel.jsx +++ b/src/containers/Organization/Video/RightPanel.jsx @@ -115,7 +115,9 @@ const RightPanel = ({ currentIndex, setCurrentIndex }) => { if (!progress && success && apiType === "SAVE_TRANSCRIPT") { if (!autoSave) { - dispatch(setSnackBar({ open: false })); + setTimeout(() => { + dispatch(setSnackBar({ open: false })); + }, 1000); } if (complete) { From f8c17ca6ebdb13580d1eadf57fec8560effb48e4 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Thu, 12 Oct 2023 13:45:03 +0530 Subject: [PATCH 03/18] fixed issue while dragging first subtitle card in bottom timeline --- src/containers/Organization/Video/components/SubtitleBoxes.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Organization/Video/components/SubtitleBoxes.jsx b/src/containers/Organization/Video/components/SubtitleBoxes.jsx index 933a413b..2ed94d0a 100644 --- a/src/containers/Organization/Video/components/SubtitleBoxes.jsx +++ b/src/containers/Organization/Video/components/SubtitleBoxes.jsx @@ -187,7 +187,7 @@ export default memo( const width = (endTime - startTime) * 10 * gridGap; const nextCardWidth = (next.endTime - nextCardStartTime) * 10 * gridGap; const previousCardWidth = - (previousCardEndTime - previou.startTime) * 10 * gridGap; + (previousCardEndTime - previou?.startTime?previou.startTime:0) * 10 * gridGap; if (lastType === "left") { if (startTime >= 0 && lastSub.endTime - startTime >= 0.2) { From 1a9da496a5f373f461b690d9ffb5bf3834309778 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Tue, 17 Oct 2023 11:41:29 +0530 Subject: [PATCH 04/18] fixed the issue of first subtitle drag which holds on to mouse keypress event --- src/containers/Organization/Video/components/SubtitleBoxes.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Organization/Video/components/SubtitleBoxes.jsx b/src/containers/Organization/Video/components/SubtitleBoxes.jsx index 2ed94d0a..111afbc6 100644 --- a/src/containers/Organization/Video/components/SubtitleBoxes.jsx +++ b/src/containers/Organization/Video/components/SubtitleBoxes.jsx @@ -127,7 +127,7 @@ export default memo( const index = hasSub(sub); const copySub = [...subtitles]; - if (index < 0) return; + if (index <= 0) return; Object.assign(sub, obj); From 474604aadf3698f272fbc57321011faf098c666c Mon Sep 17 00:00:00 2001 From: AlpanaMajhi Date: Mon, 23 Oct 2023 10:13:29 +0530 Subject: [PATCH 05/18] Newsletter changes --- src/config/apiendpoint.js | 1 + src/containers/Admin/Dashboard.jsx | 5 +- src/containers/Admin/NewsLetter.jsx | 64 +++++++++++++++++++ .../UserManagement/Notifications.jsx | 63 +++++++++++++++--- .../actions/api/Admin/NewsletterSubscribe.js | 41 ++++++++++++ src/redux/actions/index.js | 3 +- src/utils/utils.js | 6 ++ 7 files changed, 172 insertions(+), 11 deletions(-) create mode 100644 src/containers/Admin/NewsLetter.jsx create mode 100644 src/redux/actions/api/Admin/NewsletterSubscribe.js diff --git a/src/config/apiendpoint.js b/src/config/apiendpoint.js index 92b7977c..4f650120 100644 --- a/src/config/apiendpoint.js +++ b/src/config/apiendpoint.js @@ -14,6 +14,7 @@ const endpoints = { confirmResetPassword: "/users/auth/users/reset_password_confirm/", languages: "/users/languages/fetch/", userRoles: "/users/roles/", + newsletterSubscribe: "/newsletter/subscribe/", //Video video: "/video/", diff --git a/src/containers/Admin/Dashboard.jsx b/src/containers/Admin/Dashboard.jsx index 8f3e7e36..6692d57d 100644 --- a/src/containers/Admin/Dashboard.jsx +++ b/src/containers/Admin/Dashboard.jsx @@ -67,7 +67,10 @@ const DashBoard = () => { /> - + diff --git a/src/containers/Admin/NewsLetter.jsx b/src/containers/Admin/NewsLetter.jsx new file mode 100644 index 00000000..d95ee081 --- /dev/null +++ b/src/containers/Admin/NewsLetter.jsx @@ -0,0 +1,64 @@ +import { useState } from "react"; +import { useDispatch } from "react-redux"; +import { APITransport, NewsletterSubscribe } from "redux/actions"; +import { validateEmail } from "utils/utils"; + +const { Grid, Typography, TextField, Button } = require("@mui/material"); + +const NewsLetter = (props) => { + const [email, setEmail] = useState(""); + const dispatch = useDispatch(); + + const handleSubscribe = () => { + const apiObj = new NewsletterSubscribe(email); + dispatch(APITransport(apiObj)); + }; + + const handleEmailChange = (e) => { + if (validateEmail(e.target.value)) setEmail(e.target.value); + }; + return ( + + {/* + Enter Email + */} + + + + + + + + ); +}; + +export default NewsLetter; diff --git a/src/containers/UserManagement/Notifications.jsx b/src/containers/UserManagement/Notifications.jsx index b332d05c..6ee0b377 100644 --- a/src/containers/UserManagement/Notifications.jsx +++ b/src/containers/UserManagement/Notifications.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useParams } from "react-router-dom"; @@ -7,16 +7,19 @@ import { LoginStyle } from "styles"; //Components import { + Button, Card, FormControlLabel, Grid, Switch, + TextField, Tooltip, Typography, } from "@mui/material"; //APIs import { APITransport, ToggleMailsAPI } from "redux/actions"; +import NewsLetter from "./NewsLetter"; const Notifications = () => { const classes = LoginStyle(); @@ -29,32 +32,71 @@ const Notifications = () => { const [formFields, setFormFields] = useState({ dailyEmail: false, + newsLetterSubscribe: false }); - const handleEmailToggle = async () => { + const handleSwitchToggle = (prop) => { setFormFields((prev) => ({ ...prev, - dailyEmail: !formFields.dailyEmail, + [prop]: !formFields[prop], })); - - const mailObj = new ToggleMailsAPI(loggedInUser.id, !formFields.dailyEmail); - dispatch(APITransport(mailObj)); }; + useEffect(() => { + if (formFields.dailyEmail) { + const mailObj = new ToggleMailsAPI( + loggedInUser.id, + !formFields.dailyEmail + ); + dispatch(APITransport(mailObj)); + } + }, [formFields.dailyEmail]); + const notificationOptions = [ { title: "Daily Emails", name: "dailyEmail", label: "Enable daily emails for all the activities", tooltipTitle: `${ - formFields.dailyEmails ? "Disable" : "Enable" + formFields.dailyEmail ? "Disable" : "Enable" } daily mails`, - onClick: () => handleEmailToggle(), + onClick: () => handleSwitchToggle("dailyEmail"), disabled: !( loggedInUser.id === +id || loggedInUser.role === "ADMIN" || loggedInUser.role === "ORG_OWNER" ), + component: <>, + }, + { + title: "Newsletter", + name: "newsLetterSubscribe", + label: "Subscribe to Newsletter", + tooltipTitle: `${ + formFields.newsLetterSubscribe ? "Disable" : "Enable" + } newsletter`, + onClick: () => handleSwitchToggle("newsLetterSubscribe"), + disabled: !( + loggedInUser.id === +id || + loggedInUser.role === "ADMIN" || + loggedInUser.role === "ORG_OWNER" + ), + component: formFields.newsLetterSubscribe ? ( + + + + ) : ( + <> + ), }, ]; @@ -63,7 +105,7 @@ const Notifications = () => { {notificationOptions.map((element) => { return ( - + <> {element.title} { + + {element.component} + ); })} diff --git a/src/redux/actions/api/Admin/NewsletterSubscribe.js b/src/redux/actions/api/Admin/NewsletterSubscribe.js new file mode 100644 index 00000000..1c7e7947 --- /dev/null +++ b/src/redux/actions/api/Admin/NewsletterSubscribe.js @@ -0,0 +1,41 @@ +import API from "../../../api"; +import ENDPOINTS from "../../../../config/apiendpoint"; + +export default class NewsletterSubscribe extends API { + constructor(email, timeout = 2000) { + super("POST", timeout, false); + this.email = email; + this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.newsletterSubscribe}`; + } + + processResponse(res) { + super.processResponse(res); + if (res) { + this.report = res; + } + } + + apiEndPoint() { + return this.endpoint; + } + + getBody() { + return { + email: this.email + }; + } + + getHeaders() { + this.headers = { + headers: { + "Content-Type": "application/json", + "Authorization": `JWT ${localStorage.getItem('token')}`, + }, + }; + return this.headers; + } + + getPayload() { + return this.status; + } +} diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js index 1e181cb5..331b327b 100644 --- a/src/redux/actions/index.js +++ b/src/redux/actions/index.js @@ -99,7 +99,7 @@ import UpdateMyPasswordAPI from "./api/User/UpdateMyPassword"; import UpdateProfileAPI from "./api/User/UpdateProfile"; import VerifyUpdateEmailAPI from "./api/User/VerifyUpdateEmail"; import UpdateUserRoleAPI from "./api/User/UpdateUserRole"; - +import NewsletterSubscribe from "./api/User/NewsletterSubscribe"; //Commom Actions import { FullScreen, @@ -232,4 +232,5 @@ export { ReopenTaskAPI, UpdateUserRoleAPI, setTotalSentences, + NewsletterSubscribe }; diff --git a/src/utils/utils.js b/src/utils/utils.js index ee0ae9d6..e904aa9b 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -568,3 +568,9 @@ export const filterTaskList = (taskList, selectedFilters) => { return filterResult; }; + +export const validateEmail=(email)=>{ + const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; + + return emailRegex.test(email); +}; \ No newline at end of file From 592eec84c9ad788bf13df4ddf915ed88a463fd65 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Mon, 6 Nov 2023 14:37:05 +0530 Subject: [PATCH 06/18] added delete voiceover and reopen task feature --- .../Organization/Project/TaskList.jsx | 49 ++++++++++++++++++- src/redux/actions/api/Project/ReopenTask.js | 5 +- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/containers/Organization/Project/TaskList.jsx b/src/containers/Organization/Project/TaskList.jsx index 496f073b..6e4ef288 100644 --- a/src/containers/Organization/Project/TaskList.jsx +++ b/src/containers/Organization/Project/TaskList.jsx @@ -165,6 +165,7 @@ const TaskList = () => { const [searchedCol, setSearchedCol] = useState({}); const [searchedColumn, setSearchedColumn] = useState({}); const [columnDisplay, setColumnDisplay] = useState(false); + const [reOpenTaskId, setReOpenTaskId]= useState(null); //Data from Redux const { total_count: totalCount, tasks_list: taskList } = useSelector( @@ -176,6 +177,51 @@ const TaskList = () => { (state) => state.getPreviewData?.data ); + const reopenActionColumn = { + name: "Action", + label: "Actions", + options: { + filter: false, + sort: false, + align: "center", + setCellHeaderProps: () => ({ + className: tableClasses.cellHeaderProps, + }), + customBodyRender: (_value, tableMeta) => { + const { tableData: data, rowIndex } = tableMeta; + const selectedTask = data[rowIndex]; + + return ( + + + + ); + }, + }, + }; + useEffect(() => { const { progress, success, apiType, data } = apiStatus; if (!progress) { @@ -250,7 +296,7 @@ const TaskList = () => { if (apiType === "REOPEN_TASK" && data.response) { dispatch(setSnackBar({ open: false })); handleDialogOpen("tableDialog"); - setTableDialogColumn(reopenTableColumns); + setTableDialogColumn([...reopenTableColumns,reopenActionColumn]); setTableDialogMessage(data.message); setTableDialogResponse(data.response); } @@ -669,6 +715,7 @@ const TaskList = () => { case "Reopen": const reopenObj = new ReopenTaskAPI(id); dispatch(APITransport(reopenObj)); + setReOpenTaskId(id) break; default: diff --git a/src/redux/actions/api/Project/ReopenTask.js b/src/redux/actions/api/Project/ReopenTask.js index 19401440..a82f353e 100644 --- a/src/redux/actions/api/Project/ReopenTask.js +++ b/src/redux/actions/api/Project/ReopenTask.js @@ -3,14 +3,15 @@ import ENDPOINTS from "../../../../config/apiendpoint"; import C from "../../../constants"; export default class ReopenTaskAPI extends API { - constructor(id, timeout = 2000) { + constructor(id, delete_voiceover_and_reopen=false, timeout = 2000) { super("POST", timeout, false); this.type = C.REOPEN_TASK; + this.delete_and_reopen=delete_voiceover_and_reopen; this.id = id; this.endpoint = `${super.apiEndPointAuto()}${ ENDPOINTS.task - }${id}/reopen_translation_task/`; + }${id}/reopen_translation_task/?delete_voiceover_and_reopen=${delete_voiceover_and_reopen}`; } processResponse(res) { From 16dbc56435133f8d9d50b2411a0396ee21162212 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Mon, 6 Nov 2023 18:00:42 +0530 Subject: [PATCH 07/18] updated button name in previous commit --- src/containers/Organization/Project/TaskList.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Organization/Project/TaskList.jsx b/src/containers/Organization/Project/TaskList.jsx index 6e4ef288..a2afadd5 100644 --- a/src/containers/Organization/Project/TaskList.jsx +++ b/src/containers/Organization/Project/TaskList.jsx @@ -214,7 +214,7 @@ const TaskList = () => { } } }> - Delete & Reopen + Reopen ); From f2c59e45bf94b8cb0b5cf4af0b49481790f8aee5 Mon Sep 17 00:00:00 2001 From: Chetan-Gudagamanal Date: Wed, 8 Nov 2023 12:32:44 +0530 Subject: [PATCH 08/18] added feature to not allow voiceover time change and new subtitle box --- src/containers/Organization/Video/components/Metronome.jsx | 4 ++++ .../Organization/Video/components/SubtitleBoxes.jsx | 1 + 2 files changed, 5 insertions(+) diff --git a/src/containers/Organization/Video/components/Metronome.jsx b/src/containers/Organization/Video/components/Metronome.jsx index f9c192c6..8e1cb2c4 100644 --- a/src/containers/Organization/Video/components/Metronome.jsx +++ b/src/containers/Organization/Video/components/Metronome.jsx @@ -28,6 +28,7 @@ const findIndex = (subs, startTime) => { export default React.memo( function Component({ render, playing }) { + const taskDetails = useSelector((state) => state.getTaskDetails.data); const classes = VideoLandingStyle(); const dispatch = useDispatch(); @@ -52,6 +53,7 @@ export default React.memo( const onMouseDown = useCallback( (event) => { if (event.button !== 0) return; + if (taskDetails.task_type.includes("VOICEOVER")){return} const clickTime = getEventTime(event); setIsDroging(true); setDrogStartTime(clickTime); @@ -61,6 +63,7 @@ export default React.memo( const onMouseMove = useCallback( (event) => { + if (taskDetails.task_type.includes("VOICEOVER")){return} if (isDroging) { if (playing) player.pause(); setDrogEndTime(getEventTime(event)); @@ -70,6 +73,7 @@ export default React.memo( ); const onDocumentMouseUp = useCallback(() => { + if (taskDetails.task_type.includes("VOICEOVER")){return} if (isDroging) { if ( drogStartTime > 0 && diff --git a/src/containers/Organization/Video/components/SubtitleBoxes.jsx b/src/containers/Organization/Video/components/SubtitleBoxes.jsx index 111afbc6..1050cd71 100644 --- a/src/containers/Organization/Video/components/SubtitleBoxes.jsx +++ b/src/containers/Organization/Video/components/SubtitleBoxes.jsx @@ -128,6 +128,7 @@ export default memo( const copySub = [...subtitles]; if (index <= 0) return; + if (taskDetails.task_type.includes("VOICEOVER")){return} Object.assign(sub, obj); From 90124e714c538ea61b4382ec0f1b2ecf0bc340b2 Mon Sep 17 00:00:00 2001 From: AlpanaMajhi Date: Wed, 15 Nov 2023 00:47:05 +0530 Subject: [PATCH 09/18] newsletter changes --- src/config/apiendpoint.js | 1 + src/containers/Admin/Dashboard.jsx | 14 +- src/containers/Admin/NewsLetter.jsx | 64 ------- src/containers/Admin/NewsLetterTemplate.jsx | 178 ++++++++++++++++++ .../UserManagement/NewsLetterSubscribe.jsx | 24 +++ .../UserManagement/Notifications.jsx | 11 +- .../actions/api/Admin/NewsLetterTemplate.js | 42 +++++ .../actions/api/User/NewsletterSubscribe.js | 47 +++++ src/redux/actions/index.js | 5 +- src/redux/constants.js | 1 + 10 files changed, 318 insertions(+), 69 deletions(-) delete mode 100644 src/containers/Admin/NewsLetter.jsx create mode 100644 src/containers/Admin/NewsLetterTemplate.jsx create mode 100644 src/containers/UserManagement/NewsLetterSubscribe.jsx create mode 100644 src/redux/actions/api/Admin/NewsLetterTemplate.js create mode 100644 src/redux/actions/api/User/NewsletterSubscribe.js diff --git a/src/config/apiendpoint.js b/src/config/apiendpoint.js index 4f650120..79636c8c 100644 --- a/src/config/apiendpoint.js +++ b/src/config/apiendpoint.js @@ -15,6 +15,7 @@ const endpoints = { languages: "/users/languages/fetch/", userRoles: "/users/roles/", newsletterSubscribe: "/newsletter/subscribe/", + newsletter: "/newsletter/", //Video video: "/video/", diff --git a/src/containers/Admin/Dashboard.jsx b/src/containers/Admin/Dashboard.jsx index 6692d57d..ae5e44df 100644 --- a/src/containers/Admin/Dashboard.jsx +++ b/src/containers/Admin/Dashboard.jsx @@ -14,6 +14,7 @@ import AdminLevelReport from "./AdminLevelReport"; //Apis import { APITransport, AddOrganizationMemberAPI } from "redux/actions"; +import NewsLetter from "./NewsLetterTemplate"; const TabPanel = (props) => { const { children, value, index, ...other } = props; @@ -145,7 +146,18 @@ const DashBoard = () => { value={value} index={3} style={{ textAlign: "center", maxWidth: "100%" }} - > + > + +
+ +
+
+ {addUserDialog && ( diff --git a/src/containers/Admin/NewsLetter.jsx b/src/containers/Admin/NewsLetter.jsx deleted file mode 100644 index d95ee081..00000000 --- a/src/containers/Admin/NewsLetter.jsx +++ /dev/null @@ -1,64 +0,0 @@ -import { useState } from "react"; -import { useDispatch } from "react-redux"; -import { APITransport, NewsletterSubscribe } from "redux/actions"; -import { validateEmail } from "utils/utils"; - -const { Grid, Typography, TextField, Button } = require("@mui/material"); - -const NewsLetter = (props) => { - const [email, setEmail] = useState(""); - const dispatch = useDispatch(); - - const handleSubscribe = () => { - const apiObj = new NewsletterSubscribe(email); - dispatch(APITransport(apiObj)); - }; - - const handleEmailChange = (e) => { - if (validateEmail(e.target.value)) setEmail(e.target.value); - }; - return ( - - {/* - Enter Email - */} - - - - - - - - ); -}; - -export default NewsLetter; diff --git a/src/containers/Admin/NewsLetterTemplate.jsx b/src/containers/Admin/NewsLetterTemplate.jsx new file mode 100644 index 00000000..8f7d7c87 --- /dev/null +++ b/src/containers/Admin/NewsLetterTemplate.jsx @@ -0,0 +1,178 @@ +import { Grid, Select, MenuItem, FormControl, InputLabel, Box, TextField, Button } from "@mui/material"; +import { useCallback, useState } from "react"; +import { useDispatch } from "react-redux"; +import { APITransport, NewsletterTemplate } from "redux/actions"; +import CloudUploadIcon from '@mui/icons-material/CloudUpload'; +import { styled } from '@mui/material/styles'; + +const VisuallyHiddenInput = styled('input')({ + clip: 'rect(0 0 0 0)', + clipPath: 'inset(50%)', + height: 1, + overflow: 'hidden', + position: 'absolute', + bottom: 0, + left: 0, + whiteSpace: 'nowrap', + width: 1, +}); + + +const NewsLetter = () => { + const [selectedTemplate, setSelectedTemplate] = useState(null); + const [templateInfo, setTemplateInfo] = useState({ + 1: null, + 2: null, + 3: null + }) + const dispatch = useDispatch(); + + const handleTemplateChange = (e) => { + setTemplateInfo((prev) => ({ + ...prev, + 1: null, + 2: null, + 3: null + })) + setSelectedTemplate(e.target.value) + }; + + const handleTemplateSubmit = () => { + const payload = { + submitter_id: 1, + content: selectedTemplate !== 3 ? [templateInfo?.[selectedTemplate]] : templateInfo?.[selectedTemplate], + category: "NEW_FEATURE", + template_id: selectedTemplate + } + const templateOneObj = new NewsletterTemplate(payload, selectedTemplate); + dispatch(APITransport(templateOneObj)); + + }; + + const handleChange = (prop, value) => { + setTemplateInfo((prev) => ({ + ...prev, + [selectedTemplate]: { + ...prev[selectedTemplate], + [prop]: value, + }, + })); + }; + + function getBase64(file) { + return new Promise((resolve, reject) => { + var reader = new FileReader(); + reader.readAsDataURL(file); + + reader.onload = function () { + resolve(reader.result); + }; + + reader.onerror = function (error) { + reject(error); + }; + }); + } + + const templateOne = () => { + return + + handleChange("header", e.target.value)} /> + + +