From 5ddf842def59e3718efa287fe54a1bc3ac2ec8f3 Mon Sep 17 00:00:00 2001 From: Aditya-Sakpal Date: Sat, 20 Jan 2024 20:05:44 +0530 Subject: [PATCH 1/5] Confirmation --- functions/package.json | 2 +- src/store/actions/authActions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/package.json b/functions/package.json index f20d6f03..837d0b0f 100644 --- a/functions/package.json +++ b/functions/package.json @@ -15,7 +15,7 @@ "dependencies": { "dotenv": "^16.0.1", "firebase-admin": "^9.0.0", - "firebase-functions": "^3.9.0", + "firebase-functions": "^3.24.1", "lodash": "^4.17.19" }, "devDependencies": { diff --git a/src/store/actions/authActions.js b/src/store/actions/authActions.js index 5b748dee..9520eb78 100644 --- a/src/store/actions/authActions.js +++ b/src/store/actions/authActions.js @@ -290,4 +290,4 @@ export const setUpInitialData = console.log(e); dispatch({ type: actions.INITIAL_SETUP_FAIL, payload: e }); } - }; + }; \ No newline at end of file From e72c3625da1582e9002b69b1a8290f17098a9f67 Mon Sep 17 00:00:00 2001 From: Aditya-Sakpal Date: Wed, 31 Jan 2024 11:13:41 +0530 Subject: [PATCH 2/5] Confirmation --- src/store/actions/authActions.js | 2 +- src/store/actions/tutorialsActions.js | 294 +++++++++++++------------- 2 files changed, 148 insertions(+), 148 deletions(-) diff --git a/src/store/actions/authActions.js b/src/store/actions/authActions.js index 9520eb78..5b748dee 100644 --- a/src/store/actions/authActions.js +++ b/src/store/actions/authActions.js @@ -290,4 +290,4 @@ export const setUpInitialData = console.log(e); dispatch({ type: actions.INITIAL_SETUP_FAIL, payload: e }); } - }; \ No newline at end of file + }; diff --git a/src/store/actions/tutorialsActions.js b/src/store/actions/tutorialsActions.js index 7d273c1d..f6adedc4 100644 --- a/src/store/actions/tutorialsActions.js +++ b/src/store/actions/tutorialsActions.js @@ -230,36 +230,36 @@ export const getCurrentTutorialData = export const addNewTutorialStep = ({ owner, tutorial_id, title, time, id }) => - async (firebase, firestore, dispatch) => { - try { - dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); + async (firebase, firestore, dispatch) => { + try { + dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(id) - .set({ - content: `Switch to editor mode to begin ${title} step`, - id, - time, - title, - visibility: true, - deleted: false - }); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(id) + .set({ + content: `Switch to editor mode to begin ${title} step`, + id, + time, + title, + visibility: true, + deleted: false + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); - } catch (e) { - console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); - } - }; + dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); + } catch (e) { + console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); + dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); + } + }; export const clearCreateTutorials = () => dispatch => dispatch({ type: actions.CLEAR_CREATE_TUTORIALS_STATE }); @@ -305,78 +305,78 @@ export const setCurrentStepContent = export const hideUnHideStep = (owner, tutorial_id, step_id, visibility) => - async (firebase, firestore, dispatch) => { - try { - /* not being used */ - // const type = await checkUserOrOrgHandle(owner)(firebase); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .update({ - [`visibility`]: !visibility, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + /* not being used */ + // const type = await checkUserOrOrgHandle(owner)(firebase); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .update({ + [`visibility`]: !visibility, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const publishUnpublishTutorial = (owner, tutorial_id, isPublished) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .update({ - ["isPublished"]: !isPublished - }); + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .update({ + ["isPublished"]: !isPublished + }); - getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); - } catch (e) { - console.log(e.message); - } - }; + getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); + } catch (e) { + console.log(e.message); + } + }; export const removeStep = (owner, tutorial_id, step_id, current_step_no) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .delete() - - // const data = await firestore - // .collection("tutorials") - // .doc(tutorial_id) - // .collection("steps") - // .doc(step_id) - // .get(); - - await setCurrentStepNo( - current_step_no > 0 ? current_step_no - 1 : current_step_no - )(dispatch); - - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .delete(); + + // const data = await firestore + // .collection("tutorials") + // .doc(tutorial_id) + // .collection("steps") + // .doc(step_id) + // .get(); + + await setCurrentStepNo( + current_step_no > 0 ? current_step_no - 1 : current_step_no + )(dispatch); + + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setCurrentStep = data => async dispatch => dispatch({ type: actions.SET_EDITOR_DATA, payload: data }); @@ -465,69 +465,69 @@ export const remoteTutorialImages = export const updateStepTitle = (owner, tutorial_id, step_id, step_title) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`title`]: step_title, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`title`]: step_title, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e); + } + }; export const updateStepTime = (owner, tutorial_id, step_id, step_time) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`time`]: step_time, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`time`]: step_time, + updatedAt: firestore.FieldValue.serverTimestamp() + }); + + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setTutorialTheme = ({ tutorial_id, owner, bgColor, textColor }) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials`; + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials`; - await firestore.collection(dbPath).doc(tutorial_id).update({ - text_color: textColor, - background_color: bgColor, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + await firestore.collection(dbPath).doc(tutorial_id).update({ + text_color: textColor, + background_color: bgColor, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; From 2ad0cc176246c79b18fbedbe2b4a3dead66a4162 Mon Sep 17 00:00:00 2001 From: Aditya-Sakpal Date: Mon, 19 Feb 2024 21:30:40 +0530 Subject: [PATCH 3/5] Confirmation --- functions/package.json | 2 +- src/store/actions/tutorialsActions.js | 294 +++++++++++++------------- 2 files changed, 148 insertions(+), 148 deletions(-) diff --git a/functions/package.json b/functions/package.json index 837d0b0f..f20d6f03 100644 --- a/functions/package.json +++ b/functions/package.json @@ -15,7 +15,7 @@ "dependencies": { "dotenv": "^16.0.1", "firebase-admin": "^9.0.0", - "firebase-functions": "^3.24.1", + "firebase-functions": "^3.9.0", "lodash": "^4.17.19" }, "devDependencies": { diff --git a/src/store/actions/tutorialsActions.js b/src/store/actions/tutorialsActions.js index f6adedc4..6ba163ac 100644 --- a/src/store/actions/tutorialsActions.js +++ b/src/store/actions/tutorialsActions.js @@ -230,36 +230,36 @@ export const getCurrentTutorialData = export const addNewTutorialStep = ({ owner, tutorial_id, title, time, id }) => - async (firebase, firestore, dispatch) => { - try { - dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); + async (firebase, firestore, dispatch) => { + try { + dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(id) - .set({ - content: `Switch to editor mode to begin ${title} step`, - id, - time, - title, - visibility: true, - deleted: false - }); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(id) + .set({ + content: `Switch to editor mode to begin ${title} step`, + id, + time, + title, + visibility: true, + deleted: false + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); - } catch (e) { - console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); - } - }; + dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); + } catch (e) { + console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); + dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); + } + }; export const clearCreateTutorials = () => dispatch => dispatch({ type: actions.CLEAR_CREATE_TUTORIALS_STATE }); @@ -305,78 +305,78 @@ export const setCurrentStepContent = export const hideUnHideStep = (owner, tutorial_id, step_id, visibility) => - async (firebase, firestore, dispatch) => { - try { - /* not being used */ - // const type = await checkUserOrOrgHandle(owner)(firebase); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .update({ - [`visibility`]: !visibility, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + /* not being used */ + // const type = await checkUserOrOrgHandle(owner)(firebase); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .update({ + [`visibility`]: !visibility, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const publishUnpublishTutorial = (owner, tutorial_id, isPublished) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .update({ - ["isPublished"]: !isPublished - }); + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .update({ + ["isPublished"]: !isPublished + }); - getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); - } catch (e) { - console.log(e.message); - } - }; + getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); + } catch (e) { + console.log(e.message); + } + }; export const removeStep = (owner, tutorial_id, step_id, current_step_no) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .delete(); - - // const data = await firestore - // .collection("tutorials") - // .doc(tutorial_id) - // .collection("steps") - // .doc(step_id) - // .get(); - - await setCurrentStepNo( - current_step_no > 0 ? current_step_no - 1 : current_step_no - )(dispatch); - - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .delete() + + // const data = await firestore + // .collection("tutorials") + // .doc(tutorial_id) + // .collection("steps") + // .doc(step_id) + // .get(); + + await setCurrentStepNo( + current_step_no > 0 ? current_step_no - 1 : current_step_no + )(dispatch); + + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setCurrentStep = data => async dispatch => dispatch({ type: actions.SET_EDITOR_DATA, payload: data }); @@ -465,69 +465,69 @@ export const remoteTutorialImages = export const updateStepTitle = (owner, tutorial_id, step_id, step_title) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`title`]: step_title, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`title`]: step_title, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e); + } + }; export const updateStepTime = (owner, tutorial_id, step_id, step_time) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`time`]: step_time, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; + + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`time`]: step_time, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setTutorialTheme = ({ tutorial_id, owner, bgColor, textColor }) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials`; + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials`; - await firestore.collection(dbPath).doc(tutorial_id).update({ - text_color: textColor, - background_color: bgColor, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + await firestore.collection(dbPath).doc(tutorial_id).update({ + text_color: textColor, + background_color: bgColor, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; \ No newline at end of file From e9cf19d6fbf44940a5df0ccfd2850d5795f2b6fd Mon Sep 17 00:00:00 2001 From: Aditya-Sakpal Date: Mon, 19 Feb 2024 21:31:26 +0530 Subject: [PATCH 4/5] Confirmation --- src/store/actions/tutorialsActions.js | 294 +++++++++++++------------- 1 file changed, 147 insertions(+), 147 deletions(-) diff --git a/src/store/actions/tutorialsActions.js b/src/store/actions/tutorialsActions.js index 6ba163ac..f6adedc4 100644 --- a/src/store/actions/tutorialsActions.js +++ b/src/store/actions/tutorialsActions.js @@ -230,36 +230,36 @@ export const getCurrentTutorialData = export const addNewTutorialStep = ({ owner, tutorial_id, title, time, id }) => - async (firebase, firestore, dispatch) => { - try { - dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); + async (firebase, firestore, dispatch) => { + try { + dispatch({ type: actions.CREATE_TUTORIAL_STEP_START }); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(id) - .set({ - content: `Switch to editor mode to begin ${title} step`, - id, - time, - title, - visibility: true, - deleted: false - }); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(id) + .set({ + content: `Switch to editor mode to begin ${title} step`, + id, + time, + title, + visibility: true, + deleted: false + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); - } catch (e) { - console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); - dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); - } - }; + dispatch({ type: actions.CREATE_TUTORIAL_STEP_SUCCESS }); + } catch (e) { + console.log("CREATE_TUTORIAL_STEP_FAIL", e.message); + dispatch({ type: actions.CREATE_TUTORIAL_STEP_FAIL, payload: e.message }); + } + }; export const clearCreateTutorials = () => dispatch => dispatch({ type: actions.CLEAR_CREATE_TUTORIALS_STATE }); @@ -305,78 +305,78 @@ export const setCurrentStepContent = export const hideUnHideStep = (owner, tutorial_id, step_id, visibility) => - async (firebase, firestore, dispatch) => { - try { - /* not being used */ - // const type = await checkUserOrOrgHandle(owner)(firebase); - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .update({ - [`visibility`]: !visibility, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + /* not being used */ + // const type = await checkUserOrOrgHandle(owner)(firebase); + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .update({ + [`visibility`]: !visibility, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const publishUnpublishTutorial = (owner, tutorial_id, isPublished) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .update({ - ["isPublished"]: !isPublished - }); + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .update({ + ["isPublished"]: !isPublished + }); - getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); - } catch (e) { - console.log(e.message); - } - }; + getCurrentTutorialData(owner, tutorial_id)(firebase, firestore, dispatch); + } catch (e) { + console.log(e.message); + } + }; export const removeStep = (owner, tutorial_id, step_id, current_step_no) => - async (firebase, firestore, dispatch) => { - try { - await firestore - .collection("tutorials") - .doc(tutorial_id) - .collection("steps") - .doc(step_id) - .delete() - - // const data = await firestore - // .collection("tutorials") - // .doc(tutorial_id) - // .collection("steps") - // .doc(step_id) - // .get(); - - await setCurrentStepNo( - current_step_no > 0 ? current_step_no - 1 : current_step_no - )(dispatch); - - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + async (firebase, firestore, dispatch) => { + try { + await firestore + .collection("tutorials") + .doc(tutorial_id) + .collection("steps") + .doc(step_id) + .delete(); + + // const data = await firestore + // .collection("tutorials") + // .doc(tutorial_id) + // .collection("steps") + // .doc(step_id) + // .get(); + + await setCurrentStepNo( + current_step_no > 0 ? current_step_no - 1 : current_step_no + )(dispatch); + + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setCurrentStep = data => async dispatch => dispatch({ type: actions.SET_EDITOR_DATA, payload: data }); @@ -465,69 +465,69 @@ export const remoteTutorialImages = export const updateStepTitle = (owner, tutorial_id, step_id, step_title) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`title`]: step_title, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`title`]: step_title, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e); - } - }; + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e); + } + }; export const updateStepTime = (owner, tutorial_id, step_id, step_time) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials/${tutorial_id}/steps`; - - await firestore - .collection(dbPath) - .doc(step_id) - .update({ - [`time`]: step_time, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials/${tutorial_id}/steps`; - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; + await firestore + .collection(dbPath) + .doc(step_id) + .update({ + [`time`]: step_time, + updatedAt: firestore.FieldValue.serverTimestamp() + }); + + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; export const setTutorialTheme = ({ tutorial_id, owner, bgColor, textColor }) => - async (firebase, firestore, dispatch) => { - try { - const dbPath = `tutorials`; + async (firebase, firestore, dispatch) => { + try { + const dbPath = `tutorials`; - await firestore.collection(dbPath).doc(tutorial_id).update({ - text_color: textColor, - background_color: bgColor, - updatedAt: firestore.FieldValue.serverTimestamp() - }); + await firestore.collection(dbPath).doc(tutorial_id).update({ + text_color: textColor, + background_color: bgColor, + updatedAt: firestore.FieldValue.serverTimestamp() + }); - await getCurrentTutorialData(owner, tutorial_id)( - firebase, - firestore, - dispatch - ); - } catch (e) { - console.log(e.message); - } - }; \ No newline at end of file + await getCurrentTutorialData(owner, tutorial_id)( + firebase, + firestore, + dispatch + ); + } catch (e) { + console.log(e.message); + } + }; From 6509b7c9503cafb3862cc900e60c1ceb0f113a33 Mon Sep 17 00:00:00 2001 From: Aditya-Sakpal Date: Mon, 26 Feb 2024 13:42:24 +0530 Subject: [PATCH 5/5] Confirmation --- src/components/Card/CardWithoutPicture.jsx | 11 +- src/components/HomePage/index.jsx | 1 + .../Tutorials/NewTutorial/index.jsx | 110 ++++++++++++++++-- src/store/actions/tutorialPageActions.js | 1 + src/store/actions/tutorialsActions.js | 5 +- 5 files changed, 114 insertions(+), 14 deletions(-) diff --git a/src/components/Card/CardWithoutPicture.jsx b/src/components/Card/CardWithoutPicture.jsx index abc4ecb0..f70f5706 100644 --- a/src/components/Card/CardWithoutPicture.jsx +++ b/src/components/Card/CardWithoutPicture.jsx @@ -55,6 +55,7 @@ const useStyles = makeStyles(theme => ({ padding: "5px" }, time: { + marginLeft:"2%", lineHeight: "1" }, small: { @@ -100,6 +101,8 @@ export default function CardWithoutPicture({ tutorial }) { return timestamp.toDate().toDateString(); }; + + return ( + {tutorial?.tags.map((tag, index) => ( + ))} homepageFeedArray ); + // console.log(tutorials, "tutorials") const notification = () => {}; const handleChange = (event, newValue) => { diff --git a/src/components/Tutorials/NewTutorial/index.jsx b/src/components/Tutorials/NewTutorial/index.jsx index ac826889..072dc784 100644 --- a/src/components/Tutorials/NewTutorial/index.jsx +++ b/src/components/Tutorials/NewTutorial/index.jsx @@ -5,7 +5,7 @@ import { createTutorial } from "../../../store/actions"; import { useFirebase, useFirestore } from "react-redux-firebase"; import { useHistory } from "react-router-dom"; import Button from "@mui/material/Button"; -import { Alert, Box } from "@mui/material"; +import { Alert, Box,Chip } from "@mui/material"; import TextField from "@mui/material/TextField"; import Divider from "@mui/material/Divider"; import { IconButton } from "@mui/material"; @@ -32,6 +32,48 @@ const useStyles = makeStyles(theme => ({ purple: { color: deepPurple[700], backgroundColor: deepPurple[500] + }, + tagsInput: { + display: 'flex', + flexWrap: 'wrap', + minHeight: 48, + width: 480, + border: '1px solid rgb(214, 216, 218)', + borderRadius: 6, + // outline: '1px solid #673ab7', + '& input': { + flex: 1, + border: 'none', + height: 46, + fontSize: 14, + padding: '4px 0 0 0', + '&:focus': { + outline: 'none', + }, + }, + }, + tagsContainer: { + display: 'flex', + flexWrap: 'wrap', + padding: 0, + margin: '8px 0 0 0', + }, + tag: { + margin: '0 8px 8px 0', + }, + tagInput:{ + border: 'none', + width: "100%", + height:"100%", + textAlign:"center", + // height: 46, + // border:"1px solid white" , + fontSize: 14, + outline:"none", + '&:focus': { + outline: 'none', + }, + } })); @@ -43,6 +85,9 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(false); + const [tags, setTags] = useState([]); + const [tagsInput, setTagsInput] = useState(''); + const [tagsInputClicked, setTagsInputClicked] = useState(false); const [formValue, setformValue] = useState({ title: "", summary: "", @@ -103,14 +148,14 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { const orgList = allowOrgs > 0 ? organizations - .map((org, i) => { - if (org.permissions.includes(3) || org.permissions.includes(2)) { - return org; - } else { - return null; - } - }) - .filter(Boolean) + .map((org, i) => { + if (org.permissions.includes(3) || org.permissions.includes(2)) { + return org; + } else { + return null; + } + }) + .filter(Boolean) : null; useEffect(() => { @@ -122,6 +167,7 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { const tutorialData = { ...formValue, created_by: userHandle, + tags: tags, is_org: userHandle !== formValue.owner, completed: false }; @@ -146,6 +192,22 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { }; const classes = useStyles(); + + + const removeTags = (indexToRemove) => { + setTags(tags.filter((_, index) => index !== indexToRemove)); + }; + + const addTags = (event) => { + if (event.target.value !== '') { + setTags([...tags, event.target.value]); + event.target.value = ''; + setTagsInput(''); + console.log(tagsInput) + } + + }; + return ( { aria-describedby="simple-modal-description" style={{ display: "flex", + maxWidth: "50%", + marginLeft: "25%", alignItems: "center", justifyContent: "center" }} @@ -200,6 +264,7 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { prefix={ } + onClick={()=>setTagsInputClicked(false)} placeholder="Title of the Tutorial" autoComplete="title" name="title" @@ -215,6 +280,7 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { prefix={ } + onClick={()=>setTagsInputClicked(false)} fullWidth variant="outlined" name="summary" @@ -226,6 +292,32 @@ const NewTutorial = ({ viewModal, onSidebarClick, viewCallback, active }) => { style={{ marginBottom: "2rem" }} /> +
setTagsInputClicked(true)} > +
+ {tags.map((tag, index) => ( + removeTags(index)} + className={classes.tag} + /> + ))} +
+ setTagsInput(event.target.value)} + InputProps={{ + disableUnderline: true, + inputProps: { style: { marginLeft: '14px',border:"none !important",outline:"none !important" } }, + }} + onKeyUp={(event) => (event.key === 'ArrowUp' ? addTags(event) : null)} + placeholder="Press ArrowUp key to add tags" + /> +
+ diff --git a/src/store/actions/tutorialPageActions.js b/src/store/actions/tutorialPageActions.js index c716765a..36cf344a 100644 --- a/src/store/actions/tutorialPageActions.js +++ b/src/store/actions/tutorialPageActions.js @@ -98,6 +98,7 @@ export const getTutorialFeedData = title: tutorial?.title, summary: tutorial?.summary, owner: tutorial?.owner, + tags: tutorial?.tags, created_by: tutorial?.created_by, createdAt: tutorial?.createdAt, featured_image: tutorial?.featured_image diff --git a/src/store/actions/tutorialsActions.js b/src/store/actions/tutorialsActions.js index f6adedc4..c69ff6bd 100644 --- a/src/store/actions/tutorialsActions.js +++ b/src/store/actions/tutorialsActions.js @@ -122,11 +122,11 @@ export const createTutorial = tutorialData => async (firebase, firestore, dispatch, history) => { try { dispatch({ type: actions.CREATE_TUTORIAL_START }); - const { title, summary, owner, created_by, is_org } = tutorialData; + const { title, summary, owner, created_by,tags ,is_org } = tutorialData; const setData = async () => { const document = firestore.collection("tutorials").doc(); - + console.log(tags); const documentID = document.id; const step_id = `${documentID}_${new Date().getTime()}`; @@ -141,6 +141,7 @@ export const createTutorial = featured_image: "", icon: "", url: "", + tags:tags, background_color: "#ffffff", text_color: "#000000", createdAt: firestore.FieldValue.serverTimestamp(),