{"id":21877531,"url":"https://github.com/erabossid/firestore-signup-code","last_synced_at":"2025-03-10T14:23:21.993Z","repository":{"id":166676954,"uuid":"373379138","full_name":"erabosscode/firestore-signup-code","owner":"erabosscode","description":"Signup code with firestore and react native","archived":false,"fork":false,"pushed_at":"2021-06-18T08:40:16.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T02:22:54.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erabosscode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-03T04:21:05.000Z","updated_at":"2021-06-18T08:40:18.000Z","dependencies_parsed_at":"2023-06-01T15:15:29.121Z","dependency_job_id":null,"html_url":"https://github.com/erabosscode/firestore-signup-code","commit_stats":null,"previous_names":["tradecoder/firestore-signup-code","logixmaster/firestore-signup-code","mydigita/firestore-signup-code","erabossid/firestore-signup-code","erabosstt/firestore-signup-code","erabosscode/firestore-signup-code"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erabosscode%2Ffirestore-signup-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erabosscode%2Ffirestore-signup-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erabosscode%2Ffirestore-signup-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erabosscode%2Ffirestore-signup-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erabosscode","download_url":"https://codeload.github.com/erabosscode/firestore-signup-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242865159,"owners_count":20197845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T08:09:31.977Z","updated_at":"2025-03-10T14:23:21.973Z","avatar_url":"https://github.com/erabosscode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# firestore-signup-code\nSignup code with firestore and react native \n* Using react-native-elements for UI \n* React Navigation for navigation\n\n```javascript\nimport React, { useState } from 'react';\nimport { ThemeProvider, Text, Input, Button, Card } from 'react-native-elements';\nimport { TouchableOpacity } from 'react-native';\nimport { firebase } from '../firebase/config';\nimport { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scrollview';\n\nexport default function SignupScreen({ navigation }) {\n  const [firstName, setFirstName] = useState(\"\");\n  const [lastName, setLastName] = useState(\"\");\n  const [email, setEmail] = useState(\"\");\n  const [mobile, setMobile] = useState(\"\");\n  const [password, setPassword] = useState(\"\");\n  const [errorList, setErrorList] = useState([]);\n  const validFirstName = /../.test(firstName);\n  const validLastName = /../.test(lastName);\n  const validEmail = /.....@gmail.com/.test(email);\n  const validMobile = /01[3-9]......../.test(mobile);\n  const validPassword = () =\u003e {\n    if ((/......../).test(password)\n      \u0026\u0026 (/[A-Z]/).test(password)\n      \u0026\u0026 (/[a-z]/).test(password)\n      \u0026\u0026 (/[0-9]/).test(password)) {\n      return true;\n    } else {\n      return false;\n    }\n  }\n\n  // Check if all data is valid\n  const isDataValid = () =\u003e {\n    if (validFirstName \u0026\u0026 validLastName \u0026\u0026 validEmail \u0026\u0026 validMobile \u0026\u0026 validPassword()) {\n      return true;\n    } else {\n      return false\n    }\n  }\n\n  // On change input event handlers \n  function onChangeFirstName(e) {\n    setFirstName(e.replace(/[^A-Za-z]/g, ''));\n  }\n  function onChangeLastName(e) {\n    setLastName(e.replace(/[^A-Za-z]/g, ''));\n  }\n  function onChangeEmail(e) {\n    setEmail(e)\n  }\n  function onChangeMobile(e) {\n    setMobile(e.replace(/[^0-9]/g, ''));\n  }\n  function onChangePassword(e) {\n    setPassword(e);\n  }\n\n  // check invalid input data and make a list of them\n  function inputDataCheckPoint() {\n\n    let invalidData = [];\n    if (!validFirstName) {\n      invalidData.push(\"Invalid first name\")\n    }\n    if (!validLastName) {\n      invalidData.push(\"Invalid last name\")\n    }\n    if (!validEmail) {\n      invalidData.push(\"Invalid gmail address\")\n    }\n\n    if (!validMobile) {\n      invalidData.push(\"Invalid mobile number\")\n    }\n    if (!validPassword()) {\n      invalidData.push(\"Use password longer than 8, combining capital and small letters and numbers\")\n    }\n    setErrorList(invalidData);\n  }\n\n  // Show list of invaid input data if any\n  function showInvalidDataList() {\n    return (errorList.map((e, i) =\u003e {\n      return (\u003cText key={i} style={{ color: \"red\" }}\u003e{i + 1}. {e}.{\"\\n\"}\u003c/Text\u003e)\n    }))\n  }\n\n  // Send data to firebase if all information is given\n  // if not, send error alert and a list of invalid input\n\n  function onPressSignup() {\n\n    //check and send input error if any\n    inputDataCheckPoint();\n\n    // send data to firebase if everything is ok\n    if (isDataValid()) {\n      firebase.auth()\n        .createUserWithEmailAndPassword(email, password)\n        .then(response =\u003e {\n          const uid = response.user.uid;\n          const data = { _id: uid, firstName, lastName, email, mobile };\n\n          const usersRef = firebase.firestore().collection('users');\n          usersRef.doc(uid)\n            .set(data)\n            .then(() =\u003e {\n              alert(\"success\");\n              navigation.navigate(\"Home\", { user: data })\n            })\n            .catch(() =\u003e alert(\"System Error! Please try again later.\"))\n        })\n        .catch(() =\u003e alert(\"Could not connect to server! Please try again later\"))\n    } else {\n      alert(\"Please provide correct information!\")\n    }\n  }\n\n  return (\n    \u003cThemeProvider theme={theme}\u003e\n      \u003cKeyboardAwareScrollView\u003e\n        \u003cCard\u003e\n        \u003cText\u003e{errorList.length ? showInvalidDataList() : \u003cText h4\u003eSignup to continue\u003c/Text\u003e}\u003c/Text\u003e\n        \u003c/Card\u003e\n        \u003cCard\u003e\n          \u003cInput placeholder='First name' value={firstName} onChangeText={onChangeFirstName} /\u003e\n          \u003cInput placeholder='Last name' value={lastName} onChangeText={onChangeLastName} /\u003e\n          \u003cInput placeholder='Gmail address' onChangeText={onChangeEmail} maxLength={35} /\u003e\n          \u003cInput placeholder='Mobile number' value={mobile} keyboardType=\"number-pad\" maxLength={11} onChangeText={onChangeMobile} /\u003e\n          \u003cInput placeholder='Password' onChangeText={onChangePassword} secureTextEntry={true} /\u003e\n          \u003cButton title=\"Signup\" onPress={onPressSignup} /\u003e\n        \u003c/Card\u003e\n          \u003cText\u003e\n            \u003cTouchableOpacity onPress={() =\u003e navigation.navigate(\"Login\")}\u003e\n              \u003cText style={{ color: \"blue\" }}\u003eHave an account? Login here\u003c/Text\u003e\n            \u003c/TouchableOpacity\u003e\n          \u003c/Text\u003e\n      \u003c/KeyboardAwareScrollView\u003e\n    \u003c/ThemeProvider\u003e\n  )\n}\nconst theme = {\n\n  Button: {\n    raised: true,\n    buttonStyle: {\n      height: 60\n    },\n    titleStyle: {\n      fontSize: 20\n    }\n  },\n  Text: {\n    style: {\n      fontSize: 20,\n      padding: 10\n    }\n\n  }\n}\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferabossid%2Ffirestore-signup-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferabossid%2Ffirestore-signup-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferabossid%2Ffirestore-signup-code/lists"}