Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add redux actions

kruzhambus22add4ed5893
diff --git a/src/redux/sagas/actions/index.ts b/src/redux/sagas/actions/index.ts
new file mode 100644
index 000000000..b51d31047
--- /dev/null
+++ b/src/redux/sagas/actions/index.ts
@@ -0,0 +1,86 @@
+/* eslint-disable no-unused-vars */
+import types from 'redux/sagas/actions/types'
+import { getRefreshToken } from 'utils/refreshToken'
+import { logoutApi } from 'api'
+import { IUser } from '../../models/IUser'
+
+const loadProjects = (take: string, skip: string) => ({
+ type: types.LOAD_PROJECTS,
+ payload: { take, skip },
+})
+
+const loadSharedProjects = (take: string, skip: string) => ({
+ type: types.LOAD_SHARED_PROJECTS,
+ payload: { take, skip },
+})
+
+const loadProjectsCaptcha = (take: string, skip: string) => ({
+ type: types.LOAD_PROJECTS,
+ payload: { take, skip, isCaptcha: true },
+})
+const loadExtensions = () => ({
+ type: types.LOAD_EXTENSIONS,
+})
+const loadProjectAlerts = (take: string, skip: string) => ({
+ type: types.LOAD_PROJECT_ALERTS,
+ payload: { take, skip },
+})
+const loginAsync = (credentials: {
+ email: string,
+ password: string,
+}, callback = () => { }) => ({
+ type: types.LOGIN_ASYNC,
+ payload: {
+ credentials, callback,
+ },
+})
+
+const signupAsync = (data: {
+ email: string,
+ password: string,
+}, t: (string: string) => {}, callback = () => { }) => ({
+ type: types.SIGNUP_ASYNC,
+ payload: {
+ data, callback, t,
+ },
+})
+
+const emailVerifyAsync = (data: {
+ email: string,
+ code: string,
+}, successfulCallback: () => {}, errorCallback: () => {}) => ({
+ type: types.EMAIL_VERIFY_ASYNC,
+ payload: { data, successfulCallback, errorCallback },
+})
+
+const updateUserProfileAsync = (data: IUser, callback = () => { }) => ({
+ type: types.UPDATE_USER_PROFILE_ASYNC,
+ payload: { data, callback },
+})
+
+const deleteAccountAsync = (errorCallback: (e: string) => {}, successCallback: (str: string) => {}, t: (str: string) => {}) => {
+ const refreshToken = getRefreshToken()
+ logoutApi(refreshToken)
+
+ return {
+ type: types.DELETE_ACCOUNT_ASYNC,
+ payload: {
+ errorCallback, successCallback, t,
+ },
+ }
+}
+
+const sagaActions = {
+ loadProjects,
+ loadSharedProjects,
+ loadProjectsCaptcha,
+ loadExtensions,
+ loadProjectAlerts,
+ loginAsync,
+ signupAsync,
+ emailVerifyAsync,
+ updateUserProfileAsync,
+ deleteAccountAsync,
+}
+
+export default sagaActions
diff --git a/src/redux/sagas/actions/types.ts b/src/redux/sagas/actions/types.ts
new file mode 100644
index 000000000..9d9424088
--- /dev/null
+++ b/src/redux/sagas/actions/types.ts
@@ -0,0 +1,13 @@
+const sagaTypes = {
+ LOAD_EXTENSIONS: 'UI_LOAD_EXTENSIONS',
+ LOAD_PROJECTS: 'UI_LOAD_PROJECTS',
+ LOAD_SHARED_PROJECTS: 'UI_LOAD_SHARED_PROJECTS',
+ LOAD_PROJECT_ALERTS: 'UI_LOAD_PROJECT_ALERTS',
+ LOGIN_ASYNC: 'LOGIN_ASYNC',
+ SIGNUP_ASYNC: 'SIGNUP_ASYNC',
+ EMAIL_VERIFY_ASYNC: 'EMAIL_VERIFY_ASYNC',
+ UPDATE_USER_PROFILE_ASYNC: 'UPDATE_USER_PROFILE_ASYNC',
+ DELETE_ACCOUNT_ASYNC: 'DELETE_ACCOUNT_ASYNC',
+}
+
+export default sagaTypes