Add initial JSON data files and implement core page components for game functionality

This commit is contained in:
bobbert committed 2026-03-17 21:49:44 +00:00
1 parent 81847a9188
commit ca27f8d6ed
54 files changed
+2424 -250

No files matched your search

+21 -48
View File
@@ -1,59 +1,32 @@
// If a user's subgroupID is 0, Treat them as ADMIN
// If a user's subgroupID is 1, Treat them as USER [For Public instances only subgroups avail are 0 and 1]
// If a user's subgroupID is 2, Treat them as USER [For Private instances, subgroups could range from 0-999 where 0 = admin, non 0 = member group]
// Use GroupID to link Subgroup to a group in the groups table, where subgroup --> defines permissions and whether the person is allowed to play or not.
// within subgroups have TeamGroups --> TeamGroups can come and go, they are not a fixed table [Team groups are enabled per admin request.]
// Team group ==> IF Teams are enabled a user can create a team group, if they're admin in team group they can kick people.
// All team groups have a unique JOIN CODE.
// User's table should have their [NULLABLE] unique Gid, SGid and TGid.
// Gid == GroupID || SGid == SubgroupID || TGid == TeamGroupID
// When a user logs in, we check their Gid, SGid and TGid to determine their permissions and what they can see on the front end.
// If a user is in a team group, they can only see other members of that team group and the games that team group is playing.
// If a user is in a subgroup, they can see all members of that subgroup and the games that subgroup is playing.
// If a user is in the admin subgroup, they can see all members and all games.
import { useState } from 'react';
import { useNavigation } from '@react-navigation/native';
const useLoginLogic = () => {
const [username, setUsername] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const navigation = useNavigation();
const dispatch = useDispatch();
const handleLogin = async () => {
try {
// Replace with your actual API endpoint
const response = await fetch('https://yourapi.com/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
});
if (!response.ok) {
alert("API error");
}
const data = await response.json();
// Assuming the API returns user data including Gid, SGid, and TGid
const { Gid, SGid, TGid } = data;
// Dispatch user data to Redux store
dispatch(setUser({ Gid, SGid, TGid }));
// Navigate to the appropriate screen based on user role
if (SGid === 0) {
navigation.navigate('AdminDashboard');
} else if (SGid === 1) {
navigation.navigate('UserDashboard');
} else {
navigation.navigate('PrivateDashboard');
}
} catch (error) {
Alert.alert('Login Error', error.message);
if (!email || !password) {
return false;
}
if (email.trim().toLowerCase().includes('admin')) {
navigation.navigate('admin-hub');
return true;
}
navigation.navigate('game-type');
return true;
};
export default LoginLogic;
return {
email,
password,
setEmail,
setPassword,
handleLogin,
};
};
export default useLoginLogic;