Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last errors #107

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions front/src/components/TwoFaActivationInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ export const TwoFACode: React.FC<TwoFACodeProps> = ({ setShowInvalidate }) => {
});

const handleCodeChange = (e: any) => {
console.log('[TwoFAActivationInput] - On change');
setCode(e.target.value);
};

const handleSubmit = (event: any) => {
console.log('[TwoFAActivationInput] - Submitting');
event.preventDefault();
};

return (
<form onSubmit={handleSubmit} className="flex flex-col items-center">
<form onSubmit={() => mutation.mutate(code)} className="flex flex-col items-center">
<input
className="rounded-md border border-dark-3 bg-white-3 p-1 invalid:border-red focus:border-blue focus:outline-none"
type="test"
name="2FAcode"
onChange={handleCodeChange}
/>
Expand Down
26 changes: 15 additions & 11 deletions front/src/components/chat/DmCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,40 @@ interface DmChannelProps {

const DmCreate = ({ setShowModal, socket, users, setCurrentChannel }: DmChannelProps) => {
const [searchUser, setSearchUser] = useState<string>('');
const [userSelected, setUserSelected] = useState<HTMLButtonElement | null>(null);
const [userName, setUserName] = useState<string>('');
const [userButtonSelected, setUserButtonSelected] = useState<HTMLButtonElement | null>(null);
const [selectedLogin, setSelectedLogin] = useState<string>('');

useEffect(() => {
socket.on('dm', (data) => {
setCurrentChannel(data.channel);
});
}, []);

const useSetLogin = (displayName: string): void => {
const selectedUser = users?.find((user) => user.displayName == displayName);
setSelectedLogin(selectedUser?.login || '');
return;
};

const selectUser = (e: React.MouseEvent<HTMLButtonElement>) => {
setUserName(e.currentTarget.firstChild?.textContent || '');
if (e.currentTarget !== userSelected) {
if (userSelected) {
userSelected.style.backgroundColor = '#FFFFFF';
userSelected.style.color = '#000000';
useSetLogin(e.currentTarget.firstChild?.textContent || '');
if (e.currentTarget !== userButtonSelected) {
if (userButtonSelected) {
userButtonSelected.style.backgroundColor = '#FFFFFF';
userButtonSelected.style.color = '#000000';
}
e.currentTarget.style.backgroundColor = '#37626D';
e.currentTarget.style.color = '#FFFFFF';
setUserSelected(e.currentTarget);
setUserButtonSelected(e.currentTarget);
}
};

const handleDirectMessage = () => {
//Need to be replace by socker.emit('createDM', {login: username})
const message = document.querySelector<HTMLButtonElement>('#firstMessage')?.value;
socket.emit('dm', { login: userName, content: message });
socket.emit('dm', { login: selectedLogin, content: message });
socket.on('dm', (data) => {
setCurrentChannel(data.channel);
});
// TODO send notification if error
setShowModal(false);
};

Expand Down
Loading