From 7f281d2b7a6b1f069081308b047ea25401c1b6f0 Mon Sep 17 00:00:00 2001 From: Kezia Date: Sun, 5 Dec 2021 09:29:36 +0700 Subject: [PATCH 1/3] 1st Function: Notify Discord when a new thread is created --- .gitlab-ci.yml | 2 +- src/components/thread/CreateThread.jsx | 10 ++++++++-- src/config/keys.js | 1 + src/helpers/services/auth.service.js | 5 +++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88a8557..52b5c89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ deploy-to-staging: stage: deploy-to-staging environment: name: staging - url: https://memepro-diskuy-frontend.netlify.app + url: https://faas-kezia.netlify.app only: - staging script: diff --git a/src/components/thread/CreateThread.jsx b/src/components/thread/CreateThread.jsx index 11870d5..dc4399b 100644 --- a/src/components/thread/CreateThread.jsx +++ b/src/components/thread/CreateThread.jsx @@ -1,8 +1,8 @@ import axios from 'axios'; import React, { useState, useEffect } from 'react'; import { useInput } from '../../helpers/hooks/input-hook'; -import { authHeader } from '../../helpers/services/auth.service'; -import { API_URL } from '../../config/keys'; +import { authHeader, userData } from '../../helpers/services/auth.service'; +import { API_URL, FAAS_URL } from '../../config/keys'; import '../../styles/thread/Form.css'; export default function ListThreads(props) { @@ -51,6 +51,12 @@ export default function ListThreads(props) { headers: authHeader(), } ); + + const discordMessage = userData(); + discordMessage.title = title; + axios + .post(`${FAAS_URL}/notifyDiscord`, discordMessage); + const { data } = thisThread?.data; redirect(`/topic/${data?.topic_name}/${data?.id}/page/1`); } catch (error) { diff --git a/src/config/keys.js b/src/config/keys.js index 4bb616f..5d90122 100644 --- a/src/config/keys.js +++ b/src/config/keys.js @@ -1,3 +1,4 @@ export const API_URL = process.env.REACT_APP_API_URL || 'https://diskuyapi-google.herokuapp.com/api'; +export const FAAS_URL = 'https://kezia-faas.herokuapp.com/api'; export const CLIENT_ID = process.env.REACT_APP_CLIENT_ID || '501878885013-126phco7bblqngas8kd1ubfa3r0hciq3.apps.googleusercontent.com'; diff --git a/src/helpers/services/auth.service.js b/src/helpers/services/auth.service.js index 246d025..5390766 100644 --- a/src/helpers/services/auth.service.js +++ b/src/helpers/services/auth.service.js @@ -28,6 +28,11 @@ export const authHeader = () => { } }; +export const userData = () => { + const user = JSON.parse(localStorage.getItem('user')); + return user.data; +} + export const loggedIn = JSON.parse(localStorage.getItem('user')) && 1; export const isAdmin = -- GitLab From 152fe1c9d25602c5a9a355b59edbae58803144e1 Mon Sep 17 00:00:00 2001 From: Kezia Date: Sun, 5 Dec 2021 09:48:39 +0700 Subject: [PATCH 2/3] google client --- src/config/keys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/keys.js b/src/config/keys.js index 5d90122..9785dbd 100644 --- a/src/config/keys.js +++ b/src/config/keys.js @@ -1,4 +1,4 @@ export const API_URL = process.env.REACT_APP_API_URL || 'https://diskuyapi-google.herokuapp.com/api'; export const FAAS_URL = 'https://kezia-faas.herokuapp.com/api'; export const CLIENT_ID = - process.env.REACT_APP_CLIENT_ID || '501878885013-126phco7bblqngas8kd1ubfa3r0hciq3.apps.googleusercontent.com'; + process.env.REACT_APP_CLIENT_ID || '272732138595-ep2nguvntea9lp8jvjok97a235efos69.apps.googleusercontent.com'; -- GitLab From 79df99d0bdbd34d4df5cb7f620ed274a965266b9 Mon Sep 17 00:00:00 2001 From: Kezia Date: Sun, 5 Dec 2021 11:20:41 +0700 Subject: [PATCH 3/3] Update FaaS URL --- src/config/keys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/keys.js b/src/config/keys.js index 9785dbd..7e77404 100644 --- a/src/config/keys.js +++ b/src/config/keys.js @@ -1,4 +1,4 @@ export const API_URL = process.env.REACT_APP_API_URL || 'https://diskuyapi-google.herokuapp.com/api'; -export const FAAS_URL = 'https://kezia-faas.herokuapp.com/api'; +export const FAAS_URL = 'https://faas-kezia-be.netlify.app/.netlify/functions'; export const CLIENT_ID = process.env.REACT_APP_CLIENT_ID || '272732138595-ep2nguvntea9lp8jvjok97a235efos69.apps.googleusercontent.com'; -- GitLab