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!

some update

kruzhambus63a706ac260d
diff --git a/src/api/index.js b/src/api/index.js
index 5c2790b60..9b34af3c3 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -259,3 +259,13 @@ export const getGeneralStats = () =>
? error.response.data
: error.response.data.message
})
+
+export const shareProject = (pid, data) => api
+ .post(`project/${pid}/share`, data)
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message)
+ ? error.response.data
+ : error.response.data.message
+ })
diff --git a/src/pages/Project/Settings/People/AddUser.jsx b/src/pages/Project/Settings/People/AddUser.jsx
deleted file mode 100644
index fa0d820c7..000000000
--- a/src/pages/Project/Settings/People/AddUser.jsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import React, { useState, useEffect } from 'react'
-import { useTranslation } from 'react-i18next'
-import Input from 'ui/Input'
-import { isValidEmail } from 'utils/validator'
-import _keys from 'lodash/keys'
-import _isEmpty from 'lodash/isEmpty'
-
-const AddUser = ({ projectName }) => {
- const { t } = useTranslation('common')
- const [form, setForm] = useState({})
- const [beenSubmitted, setBeenSubmitted] = useState(false)
- const [errors, setErrors] = useState({})
- const [validated, setValidated] = useState(false)
-
- const validate = () => {
- const allErrors = {}
-
- if (!isValidEmail(form.email)) {
- allErrors.email = t('auth.common.badEmailError')
- }
-
- const valid = _isEmpty(_keys(allErrors))
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
- useEffect(() => {
- validate()
- }, [form]) // eslint-disable-line
-
- const handleInput = ({ target }) => {
- const value = target.type === 'checkbox' ? target.checked : target.value
-
- setForm(oldForm => ({
- ...oldForm,
- [target.name]: value,
- }))
- }
- const onSubmit = () => {
- console.log('work')
- }
- const handleSubmit = e => {
- e.preventDefault()
- e.stopPropagation()
- setBeenSubmitted(true)
-
- if (validated) {
- onSubmit(form)
- }
- }
-
- return (
- <form onSubmit={handleSubmit}>
- <h2 className='text-xl font-bold text-gray-700 dark:text-gray-200'>
- Invite member to
- {' '}
- {projectName}
- </h2>
- <p className='mt-2 text-base text-gray-700 dark:text-gray-200'>
- Enter the email address and role of the person you want to invite. We
- will contact them over email to offer them access to ads analytics.
- </p>
- <p className='mt-2 text-base text-gray-700 dark:text-gray-200'>
- The invitation will expire in 48 hours
- </p>
- <Input
- name='email'
- id='email'
- type='email'
- label={t('auth.common.email')}
- value={form.email}
- placeholder='[email protected]'
- className='mt-4'
- onChange={handleInput}
- error={beenSubmitted && errors.email}
- />
- </form>
- )
-}
-
-export default AddUser
diff --git a/src/pages/Project/Settings/People/People.jsx b/src/pages/Project/Settings/People/People.jsx
index 01ee5b09b..798b8bf79 100644
--- a/src/pages/Project/Settings/People/People.jsx
+++ b/src/pages/Project/Settings/People/People.jsx
@@ -12,6 +12,8 @@ import cx from 'clsx'
import _map from 'lodash/map'
import _filter from 'lodash/filter'
+import { shareProject } from 'api'
+
const roles = [
{
name: 'Admin',
@@ -100,7 +102,7 @@ const UsersList = ({ data, onRemove }) => {
)
}
-const People = ({ projectName }) => {
+const People = ({ projectName, pid }) => {
const [showModal, setShowModal] = useState(false)
const { t } = useTranslation('common')
const [form, setForm] = useState({
@@ -110,7 +112,6 @@ const People = ({ projectName }) => {
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [errors, setErrors] = useState({})
const [validated, setValidated] = useState(false)
-
const [users, setUsers] = useState([
{
@@ -191,6 +192,7 @@ const People = ({ projectName }) => {
setForm({ email: '', role: '' })
setErrors({})
setValidated(false)
+ shareProject(pid, { email: form.email, role: form.role })
}
const handleSubmit = e => {
@@ -211,7 +213,6 @@ const People = ({ projectName }) => {
}
const onRemove = gmail => {
- console.log(gmail)
setUsers(oldUsers => _filter(oldUsers, user => user.gmail !== gmail))
}
return (
diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsx
index 63bac82cd..3d0445840 100644
--- a/src/pages/Project/Settings/ProjectSettings.jsx
+++ b/src/pages/Project/Settings/ProjectSettings.jsx
@@ -234,6 +234,12 @@ const ProjectSettings = ({
label={t('project.settings.public')}
hint={t('project.settings.publicHint')}
/>
+
+ <hr className='mt-5' />
+
+ <People projectName={form.name} pid={id} />
+
+ <hr className='mt-5' />
</>
) : (
<p className='text-gray-500 dark:text-gray-300 italic mt-2 text-sm'>
@@ -241,12 +247,6 @@ const ProjectSettings = ({
</p>
)}
- <hr className='mt-5' />
-
- <People projectName={form.name} />
-
- <hr className='mt-5' />
-
<div className='flex justify-between mt-4'>
<div>
<Button className='mr-2 border-indigo-100 dark:text-gray-50 dark:border-gray-800 dark:border-gray-700 dark:bg-gray-700 dark:hover:bg-gray-600' onClick={onCancel} secondary regular>