Skip to content

Commit ffee6c8

Browse files
committed
fixed invalid target in created refs
1 parent 36967d9 commit ffee6c8

File tree

4 files changed

+34
-33
lines changed

4 files changed

+34
-33
lines changed

react-app/src/components/CreatedRefs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const CreatedRefs = (props: { refs: { ref: string; title: string }[] }) => {
2727
<CopyToClipboard text={ref.ref}>
2828
<div>
2929
<MdContentCopy
30-
id={ref.ref.replace(/@|[/]/g, '')}
30+
id={ref.ref.replace(/\W/g, '')}
3131
className="ml-2"
3232
onClick={() => alertSuccess('copied')}
3333
/>
3434
<UncontrolledTooltip
3535
placement="bottom"
36-
target={ref.ref.replace(/@|[/]/g, '')}
36+
target={ref.ref.replace(/\W/g, '')}
3737
>
3838
copy to clipboard
3939
</UncontrolledTooltip>

react-app/src/components/LemmaForm/LemmaForm.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
Button
1414
} from 'reactstrap';
1515
import { IoMdTrash } from 'react-icons/io';
16-
// import './LemmaForm.css';
16+
import './LemmaForm.css';
1717
import { isNotOwner, isUrl, isEmail } from '../../helpers/input-validation';
1818
import {
1919
RECAPTCHA_CLIENT_KEY,
@@ -74,6 +74,7 @@ const LemmaForm = (props: any) => {
7474
list: [{ ref: '', required: true, id: 0, invalid: false }],
7575
currentId: 0
7676
});
77+
7778
const [search, setSearch] = useState({
7879
searchable: false,
7980
synopsis: ''
@@ -85,7 +86,7 @@ const LemmaForm = (props: any) => {
8586
useEffect(() => {
8687
recaptchaRef.current!.execute();
8788
}, [recaptchaRef]);
88-
89+
8990
// Submit form
9091
const createRef = () => {
9192
const nOwner = !!owner.password && !!owner.name ? '@' + owner.name : '';
@@ -141,19 +142,19 @@ const LemmaForm = (props: any) => {
141142
'X-AUTH-PASSWORD': owner.password
142143
}
143144
: {};
144-
console.log(withSearch, headers);
145-
// Axios.post(`${BASE_URL}/ref`, withSearch, { headers })
146-
// .then(res => {
147-
// props.addRef(res.data.link, title);
148-
// alertSuccess('Ref Successflly Created');
149-
// })
150-
// .catch(err => {
151-
// if (err.response) {
152-
// alertError(err.response.data.error);
153-
// } else {
154-
// alertError(err.message);
155-
// }
156-
// });
145+
// console.log(withSearch, headers);
146+
Axios.post(`${BASE_URL}/ref`, withSearch, { headers })
147+
.then(res => {
148+
props.addRef(res.data.link, title);
149+
alertSuccess('Ref Successflly Created');
150+
})
151+
.catch(err => {
152+
if (err.response) {
153+
alertError(err.response.data.error);
154+
} else {
155+
alertError(err.message);
156+
}
157+
});
157158
}
158159
};
159160

react-app/src/components/NotFound.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const NotFound = () => {
55
return (
66
<div style={{ textAlign: 'center' }}>
77
<h1>This Page doesn't exist!</h1>
8-
<Link to="/create-ref">Go to main page</Link>
8+
<Link to="/">Go to main page</Link>
99
</div>
1010
);
1111
};

react-app/src/components/Register.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Register = (props: any) => {
4242
useEffect(() => {
4343
recaptchaRef.current!.execute();
4444
}, [recaptchaRef]);
45-
// const handleRecaptcha = (val: string | null) => setRecaptcha(val);
45+
4646
const inputChange = (input: EventTarget & HTMLInputElement) => {
4747
const inValidUser = {
4848
...user,
@@ -92,20 +92,20 @@ const Register = (props: any) => {
9292
} else if (!recaptcha_code) {
9393
alertWarning('Captcha not authenticated. Reload Page');
9494
} else {
95-
console.log(req);
96-
// Axios.post(`${BASE_URL}/accounts`, req)
97-
// .then(res => {
98-
// AUTH_SYNC(name, email, password_1);
99-
// alertSuccess('Account Created');
100-
// props.history.push('/create-ref');
101-
// })
102-
// .catch(err => {
103-
// if (err.response) {
104-
// alertError(err.response.data.error);
105-
// } else {
106-
// alertError(err.message);
107-
// }
108-
// });
95+
Axios.post(`${BASE_URL}/accounts`, req)
96+
.then(res => {
97+
alertSuccess('Account Created');
98+
setTimeout(() => {
99+
props.history.push('/');
100+
}, 1500);
101+
})
102+
.catch(err => {
103+
if (err.response) {
104+
alertError(err.response.data.error);
105+
} else {
106+
alertError(err.message);
107+
}
108+
});
109109
}
110110
};
111111

0 commit comments

Comments
 (0)