Loading...
;\n }\n\n const handleChangeName = (e) => {\n console.log(\"targetvalue\", e.target.value);\n setVenuedata({ venuedata, Name: e.target.value });\n let Data = JSON.parse(JSON.stringify(Venuelist));\n Data[SelectedIndex].Name = e.target.value;\n // setVenueName(e.target.value);\n\n setVenuelist(Data);\n handlegetVenuedata(Data);\n };\n\n return (\n <>\n \n {Nameflag !== undefined ? (\n
\n handleChangeName(e)}\n value={venuedata?.Name}\n placeholder=\"Enter name for the Venue\"\n style={{\n width: \"97%\",\n height: \"34px\",\n border: \"1px solid\",\n borderColor: \"rgb(85, 85, 85)\",\n color: colors.white,\n paddingLeft: \"10px\",\n borderRadius: \"5px\",\n fontSize: \"15px\",\n fontFamily: \"PlusJakartaSansRegular\",\n background: colors.royalBlue,\n }}\n />\n
\n ) : null}\n
\n
{\n console.log(\"Doremon\", text);\n setVenuedata({ venuedata, Address: text });\n setAddress(text);\n }}\n onSelect={handleSelect}\n >\n {({\n getInputProps,\n suggestions,\n getSuggestionItemProps,\n loading,\n }) => (\n \n
{\n // const value = e.target.value;\n // console.log(\"venuedata\", value);\n // // setVenuedata({ venuedata, Address: e.target.value });\n // }}\n />\n {suggestions && suggestions.length > 0 && (\n
\n {loading ?
Loading...
: null}\n {suggestions.map((suggestion) => {\n const style = {\n backgroundColor: suggestion.active\n ? colors.aqua\n : colors.royalBlue,\n fontFamily: \"PlusJakartaSansExtraLight\",\n color: suggestion.active\n ? colors.bgColor\n : colors.white,\n paddingbottom: \"3px\",\n };\n return (\n
\n {suggestion.description}\n
\n );\n })}\n
\n )}\n
\n )}\n \n
\n
\n >\n );\n}\n\nexport default Venue;\n","import React, { useContext, useEffect, useState } from \"react\";\nimport {\n View,\n Text,\n StyleSheet,\n Pressable,\n Dimensions,\n Platform,\n TextInput,\n} from \"react-native\";\nimport { H3, Label } from \"../../../../components/reusable/TextComponent\";\nimport { colors } from \"../../../../components/reusable/colour\";\nimport { RadioButton } from \"react-native-paper\";\nimport UploadImage from \"../../../../components/reusable/UploadImage\";\nimport UploadFile from \"../../../../components/reusable/UploadFile\";\nimport {\n RoundMaster,\n Tournament,\n UserMaster,\n UserMasterTournament,\n} from \"../../../../models\";\nimport { DataStore } from \"aws-amplify/datastore\";\nimport { uploadData } from \"aws-amplify/storage\";\nimport AsyncStorage from \"@react-native-async-storage/async-storage\";\nimport { RoundFormat } from \"../../../../models\";\nimport TrashIcon from \"react-native-vector-icons/Feather\";\nimport Venue from \"../../../view/Home/Venue\";\nimport Icon from \"react-native-vector-icons/FontAwesome\";\nimport AddIcon2 from \"react-native-vector-icons/Ionicons\";\nimport CustomDatePicker from \"../../../../components/reusable/CustomeDatePicker\";\nimport moment from \"moment\";\nimport { useNavigation } from \"@react-navigation/native\";\nimport awsmobile from \"../../../../aws-exports\";\nimport { AuthenticationContext } from \"../../../../authentication/Authentication.js\";\nimport {\n AreYouSureOrange,\n ErrorModal,\n ModalTrophy,\n} from \"../../../../components/reusable/AreYouSure\";\nimport { Substitution } from \"../../../../models\";\nimport { color } from \"react-native-elements/dist/helpers\";\nimport { Picker } from \"@react-native-picker/picker\";\nconst screenWidth = Dimensions.get(\"window\").width;\n\nconst Settings = () => {\n const [checkedSubstitute, setCheckedSubstitute] = useState(\"\");\n const [checkedPublish, setCheckedPublish] = useState(\"no\");\n const [selectedDate, setSelectedDate] = useState(\"\");\n const [SuccessModalVisible, setSuccessModalVisible] = useState(false);\n const [SunccessModalMesg, setSunccessModalMesg] = useState(\"\");\n const [CurrentTournament, setCurrentTournament] = useState(\"\");\n const [Logo, setLogo] = useState(\"\");\n\n const [Banner, setBanner] = useState(\"\");\n const navigation: any = useNavigation();\n const [roundFormat, setroundFormant] = useState([]);\n const [deleteModalVisible, setDeleteModalVisible] = useState(false);\n const [deleteModalMesg, setDeleteModalMesg] = useState(\"\");\n const [errorModalVisible, setErrorModalVisible] = useState(false);\n const [errorModalMesg, setErrorModalMesg] = useState(\"\");\n const [prizeModalVisible, setPrizeModalVisible] = useState(false);\n const { createAdminUser, getAdminUser } = useContext(AuthenticationContext);\n const [prizeModalMesg, setPrizeModalMesg] = useState(\"\");\n const [UserDetails, setUserDetails]: any = useState({});\n const [userData, setUserData] = useState(\"\");\n const [PDFfile, setPDFfile]: any = useState({});\n const [venueIdToDelete, setVenueIdToDelete] = useState(\"\");\n const [prizeIdToDelete, setPrizeIdToDelete] = useState(\"\");\n const [tournamentObj, setTournamentObj]: any = useState({});\n const [adminobj, setAdminobj]: any = useState({});\n const [DeleteAdminArr, setDeleteAdminArr] = useState([]);\n const [selectedLogo, setSelectedLogo]: any = useState({});\n const Defaultlogo =\n \"https://trackmytournament-dev125444-dev.s3.ap-south-1.amazonaws.com/public/tournament/football-club.png\";\n const Defaultbanner =\n \"https://trackmytournament-dev125444-dev.s3.ap-south-1.amazonaws.com/public/tournament/tournamentBanner.png\";\n\n const DefaultRulesDocument =\n \"https://trackmytournament-dev125444-QA.s3.ap-south-1.amazonaws.com/public/tournament/RulesDocument.png\";\n const [selectedBaneer, setSelectedBaneer]: any = useState({});\n const bucketName = awsmobile.aws_user_files_s3_bucket;\n let data = AsyncStorage.getItem(\"myTournamentEdit\");\n const [urlredirect, seturlredirect] = useState(data);\n const [venues, setVenues]: any = useState([\n {\n Name: \"\",\n Address: \"\",\n Coordinates: {},\n },\n ]);\n const [inputText, setinputText]: any = useState({\n TournamentName: \"\",\n OrganizerName: \"\",\n Sport: \"\",\n TournamentStartDate: \"\",\n TournamentEndDate: \"\",\n Category: \"\",\n CuttoffDate: \"\",\n Playing: \"\",\n Subsitute: \"\",\n Type: \"\",\n SubsitutionType: \"\",\n ContactNo: \"\",\n RegistrationFees: \"\",\n RegistrationEndDate: \"\",\n RegistrationStartDate: \"\",\n MaxNoofTeam: \"\",\n Format: \"\",\n logo: {},\n banner: {},\n PDfFile: {},\n Venue: \"\",\n CutOffDate: \"\",\n Substitution: false,\n RowlingSubstitution: false,\n Level: \"\",\n });\n const [Admininput, setAdmininput] = useState({\n Admin1Name: \"\",\n Admin1Contact: \"\",\n Admin1Email: \"\",\n Admin2Name: \"\",\n Admin2Contact: \"\",\n Admin2Email: \"\",\n Admin3Name: \"\",\n Admin3Contact: \"\",\n Admin3Email: \"\",\n Admin1UUID: \"\",\n Admin2UUID: \"\",\n Admin3UUID: \"\",\n });\n const [PrizesArr, setPrizesArr] = useState([\n {\n Name: \"\",\n Description: \"\",\n },\n ]);\n const [removeRoundList, setRemoveRoundList] = useState([]);\n const [roundSelecteindex, setRoundSelecteindex]: any = useState();\n const handleGroupYesNoSelect = (value) => {\n setCheckedSubstitute(value);\n };\n\n const handlePublishSelect = (value) => {\n console.log(\"First round\", value, roundFormat[0]);\n if (roundFormat[0].FixturesCreated == true && value == \"no\") {\n console.log(\"First round fixture created\");\n setErrorModalMesg(\n \"You can not change Tournament status once fixtures are already created!\"\n );\n setErrorModalVisible(true);\n } else {\n setCheckedPublish(value);\n }\n };\n const handleCancelcheck = () => {\n console.log(\"errorModalVisible\", errorModalVisible);\n };\n const handleinputText = (name, value) => {\n setAdmininput((lastValue) => {\n return {\n ...lastValue,\n [name]: value,\n };\n });\n };\n\n const handleDateChange = (newDate, field) => {\n console.log(\"handleDateChange\", newDate);\n const dateString = newDate;\n\n setSelectedDate(dateString);\n\n const yourMomentObject = moment(dateString);\n\n const formattedDate = yourMomentObject.format(\"YYYY-MM-DD\");\n console.log(\"formattedDate\", formattedDate);\n handleInput(field, formattedDate);\n };\n const handleInput = (name, value) => {\n console.log(\"handleInput\", name, value);\n setinputText((lastValue) => {\n return {\n ...lastValue,\n [name]: value,\n };\n });\n };\n\n const formatdata = [\n { label: \"Single Round Robin\", value: \"Single Round Robin\" },\n { label: \"Double Round Robin\", value: \"Double Round Robin\" },\n { label: \"KnockOut\", value: \"KnockOut\" },\n ];\n\n const handlegetUserData = async (uuid) => {\n let data = await DataStore.query(UserMaster, uuid);\n console.log(\"handlegetUserMaster\", data);\n return data.ContactNo;\n };\n\n const handlegetEmail = async (uuid) => {\n let data = await DataStore.query(UserMaster, uuid);\n console.log(\"handlegetUserMaster\", data);\n return data.EmailId;\n };\n const getTournamentdata = async () => {\n const TournamentData = await AsyncStorage.getItem(\"CurrentTournament\");\n setCurrentTournament(TournamentData);\n console.log(\"hello\");\n let dropdown = RoundFormat;\n\n console.log(\"TournamentData\", TournamentData);\n const subscription = DataStore.observeQuery(Tournament, (c) =>\n c.id.eq(TournamentData)\n ).subscribe(async (snapshot) => {\n console.log(\"snapshot\", snapshot);\n const getTournament: any = snapshot.items[0];\n\n console.log(\"getTournament\", getTournament);\n\n setAdmininput({\n Admin1Name:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? getTournament.Admin1.Name\n : \"\",\n Admin1Contact:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? await handlegetUserData(getTournament.Admin1.UUID)\n : \"\",\n Admin1Email:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? await handlegetEmail(getTournament.Admin1.UUID)\n : \"\",\n\n Admin2Name:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? getTournament.Admin2.Name\n : \"\",\n Admin1UUID:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? getTournament.Admin1.UUID\n : \"\",\n Admin2UUID:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? getTournament.Admin2.UUID\n : \"\",\n Admin3UUID:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? getTournament.Admin3.UUID\n : \"\",\n Admin2Contact:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? await handlegetUserData(getTournament.Admin2.UUID)\n : \"\",\n Admin2Email:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? await handlegetEmail(getTournament.Admin2.UUID)\n : \"\",\n Admin3Name:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? getTournament.Admin3.Name\n : \"\",\n Admin3Contact:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? await handlegetUserData(getTournament.Admin3.UUID)\n : \"\",\n Admin3Email:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? await handlegetEmail(getTournament.Admin3.UUID)\n : \"\",\n });\n let AdminObj = {\n Admin1Name:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? getTournament.Admin1.Name\n : \"\",\n Admin1Contact:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? await handlegetUserData(getTournament.Admin1.UUID)\n : \"\",\n Admin1Email:\n getTournament.Admin1 !== null &&\n Object.keys(getTournament.Admin1).length > 0\n ? await handlegetEmail(getTournament.Admin1.UUID)\n : \"\",\n Admin2Name:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? getTournament.Admin2.Name\n : \"\",\n Admin2Contact:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? await handlegetUserData(getTournament.Admin2.UUID)\n : \"\",\n Admin2Email:\n getTournament.Admin2 !== null &&\n Object.keys(getTournament.Admin2).length > 0\n ? await handlegetEmail(getTournament.Admin2.UUID)\n : \"\",\n Admin3Name:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? getTournament.Admin3.Name\n : \"\",\n Admin3Contact:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? await handlegetUserData(getTournament.Admin3.UUID)\n : \"\",\n Admin3Email:\n getTournament.Admin3 !== null &&\n Object.keys(getTournament.Admin3).length > 0\n ? await handlegetEmail(getTournament.Admin3.UUID)\n : \"\",\n };\n setTournamentObj(AdminObj);\n setAdminobj(AdminObj);\n setCheckedSubstitute(getTournament.SubstitutionType);\n let Roundsdata: any = await [getTournament.Rounds];\n let Rounds = await Roundsdata[0].values;\n console.log(\"RoundsArray\", Rounds);\n let arrlist = [];\n Rounds &&\n Rounds.length > 0 &&\n Rounds.map((ele) => {\n arrlist.push({\n Name: ele.Name,\n Format: ele.Format,\n id: ele.id,\n Comp: \"hii\",\n FixturesCreated: ele.FixturesCreated,\n });\n });\n setroundFormant(arrlist);\n setinputText({\n TournamentName: getTournament.Name,\n OrganizerName: getTournament.Organizer,\n Sport: getTournament.Sport !== null ? getTournament.Sport : \"\",\n TournamentStartDate: getTournament.StartDate,\n TournamentEndDate: getTournament.EndDate,\n Category: getTournament.AgeGroup,\n Playing: getTournament.Playing,\n Subsitute: getTournament.Substitute,\n Type: getTournament.Type,\n // SubsitutionType:getTournament,\n // ContactNo:getTournament,\n RegistrationFees: getTournament.Fees,\n CutOffDate: getTournament.CutOffDate,\n RegistrationEndDate: getTournament.RegistrationEndDate,\n MaxNoOfParticipants: getTournament.NoOfTeamsMax,\n logo: { URL: getTournament.Logo, FileName: \"\" },\n PDfFile: { URL: getTournament.RulesDocument, FileName: \"\" },\n banner: { URL: getTournament.Banner, FileName: \"\" },\n Venue: getTournament.Venues,\n Level: getTournament.Level,\n\n // Substitution:getTournament.,\n // RowlingSubstitution:false,\n\n MaxNoofTeam: getTournament.NoOfTeamsMax,\n });\n setCheckedPublish(\n getTournament.Status == \"SCHEDULED\" ||\n getTournament.Status == \"INPROGRESS\" ||\n getTournament.Status == \"COMPLETED\"\n ? \"yes\"\n : \"no\"\n );\n if (getTournament.Venues && getTournament.Venues.length > 0) {\n setVenues(getTournament.Venues);\n }\n\n if (getTournament.Prizes && getTournament.Prizes.length > 0) {\n setPrizesArr(getTournament.Prizes);\n }\n\n let fileName = getTournament.RulesDocument.substring(\n getTournament.RulesDocument.lastIndexOf(\"/\") + 1\n );\n console.log(\"PdfaURl\", fileName);\n\n if (fileName !== \"RulesDocument.png\") {\n setPDFfile({ URL: getTournament.RulesDocument, FileName: fileName });\n }\n });\n return () => {\n subscription.unsubscribe();\n };\n };\n const handleCallbackforImages = (uri, name, idx, filename) => {\n console.log(\"hellobanner\", uri, name, idx, filename);\n\n if (name == \"logo\") {\n console.log(\"hello1\");\n let obj = { URL: uri, FileName: filename };\n setSelectedLogo(obj);\n setinputText({\n ...inputText,\n logo: obj,\n });\n setLogo(uri);\n }\n if (name == \"profilePic\") {\n console.log(\"hello2\");\n let obj = { URL: uri, FileName: filename };\n setSelectedBaneer(obj);\n setinputText({\n ...inputText,\n banner: obj,\n });\n setBanner(uri);\n }\n };\n\n const handlePrizeDelete = (index) => {\n setPrizeModalVisible(true);\n setPrizeModalMesg(\"Are you sure do you want to Delete?\");\n setPrizeIdToDelete(index);\n };\n\n const handleAddNewPrize = () => {\n const newRow = { Name: \"\", Description: \"\" };\n setPrizesArr([...PrizesArr, newRow]);\n };\n\n const handleAddNewRound = () => {\n const newRow = { Name: \"\", Format: \"\", id: \"\", no: \"\" };\n setroundFormant([...roundFormat, newRow]);\n };\n\n const PrizesdeleteField = (index) => {\n const updatedData = PrizesArr.filter((row, idx) => idx !== index);\n setPrizesArr(updatedData);\n setPrizeModalVisible(false);\n };\n\n const handleConfirmRemoveRound = () => {\n let obj = roundFormat[roundSelecteindex];\n const updatedData = roundFormat.filter(\n (row, idx) => idx !== roundSelecteindex\n );\n\n setRemoveRoundList([...removeRoundList, obj]);\n setroundFormant(updatedData);\n setPrizeModalVisible(false);\n };\n\n const handleRoundDelete = (index) => {\n let obj = roundFormat[index];\n console.log(\"helloObj\", obj);\n if (obj.FixturesCreated == true) {\n setRoundSelecteindex(index);\n setPrizeModalVisible(true);\n setPrizeModalMesg(\n \"If you delete this round, all matches for this round will be deleted. Do you still want to go ahead?\"\n );\n } else {\n const updatedData = roundFormat.filter((row, idx) => idx !== index);\n\n setRemoveRoundList([...removeRoundList, obj]);\n setroundFormant(updatedData);\n }\n };\n\n const handleIputPrizesText = (field, value, index) => {\n console.log(\"PrizesArr\", PrizesArr, field, value, index);\n let updateddata = JSON.parse(JSON.stringify(PrizesArr));\n updateddata[index][field] = value;\n setPrizesArr(updateddata);\n };\n const uploadLogoFileToStorage = async (folderName, key) => {\n // const contentType = key.split(\";\")[0].split(\":\")[1];\n console.log(\"folder name\", folderName, \"FileName\", key.FileName);\n\n try {\n const response = await fetch(key.URL);\n const blob = await response.blob();\n let Response;\n await uploadData({\n key: `${folderName}/${key.FileName.replace(/ /g, \"_\")}`,\n data: blob,\n });\n Response = `https://${bucketName}.s3.ap-south-1.amazonaws.com/public/${folderName}/${key.FileName.replace(\n / /g,\n \"_\"\n )}`;\n return Response;\n } catch (err) {\n console.log(\"Error uploading file:\", err);\n }\n };\n\n const addUser = async (phoneNumber) => {\n let finalResponse;\n const userAttribute = [\n {\n Name: \"phone_number\" /* required */,\n Value: phoneNumber,\n },\n ];\n const response = await createAdminUser(phoneNumber, userAttribute).then(\n async (data) => {\n console.log(\"CreateUserResponse : \", data);\n finalResponse = data;\n }\n );\n console.log(\"response\", response);\n return finalResponse;\n };\n\n const cognitoUserDetails = async (phoneNumber) => {\n const response = await getAdminUser(phoneNumber);\n if (response) {\n console.log(\"response\", response);\n\n // console.log(\"UserDetails : \", response.statusCode);\n }\n\n return response;\n };\n\n const handleAdminSave = async () => {\n console.log(\"handleAdminSave\", Admininput, adminobj);\n let arrayOfObjects = [];\n let errorflag = false;\n let existingdataupdate = [];\n\n for (let i = 1; i <= 3; i++) {\n console.log(\"Admininput\", Admininput[`Admin${i}Name`]);\n if (\n (Admininput[`Admin${i}Name`] !== adminobj.Admin1Name &&\n Admininput[`Admin${i}Name`] !== adminobj.Admin2Name &&\n Admininput[`Admin${i}Name`] !== adminobj.Admin3Name) ||\n (Admininput[`Admin${i}Contact`] !== adminobj.Admin1Contact &&\n Admininput[`Admin${i}Contact`] !== adminobj.Admin2Contact &&\n Admininput[`Admin${i}Contact`] !== adminobj.Admin3Contact)\n ) {\n arrayOfObjects.push({\n Name: Admininput[`Admin${i}Name`],\n Contact: Number(Admininput[`Admin${i}Contact`]),\n UUID: \"\",\n Email: Admininput[`Admin${i}Email`],\n AdminType: i,\n });\n } else {\n if (\n Admininput[`Admin${i}Email`] !== adminobj.Admin1Email ||\n Admininput[`Admin${i}Email`] !== adminobj.Admin2Email ||\n Admininput[`Admin${i}Email`] !== adminobj.Admin3Email\n ) {\n existingdataupdate.push({\n Name: Admininput[`Admin${i}Name`],\n Contact: Number(Admininput[`Admin${i}Contact`]),\n UUID: Admininput[`Admin${i}UUID`],\n Email: Admininput[`Admin${i}Email`],\n AdminType: i,\n });\n }\n }\n }\n console.log(\"existingdataupdate\", existingdataupdate);\n console.log(\n \"arrayOfObjects\",\n adminobj,\n\n arrayOfObjects\n );\n\n existingdataupdate &&\n existingdataupdate.length > 0 &&\n existingdataupdate.map(async (ele) => {\n let getUserdata = await DataStore.query(UserMaster, ele.UUID);\n console.log(\"getUserdata\", getUserdata);\n\n const updateUserMaster = UserMaster.copyOf(getUserdata, (updated) => {\n updated.EmailId = ele.Email;\n return updated;\n });\n console.log(\"updatedTournament\", updateUserMaster);\n\n const ResponseUsermaster = await DataStore.save(updateUserMaster);\n });\n\n arrayOfObjects &&\n arrayOfObjects.length > 0 &&\n arrayOfObjects.map(async (ele) => {\n if (\n (ele.Contact !== 0 &&\n adminobj.Admin1Name == \"\" &&\n ele.AdminType == 1) ||\n (ele.Contact !== 0 &&\n adminobj.Admin2Name == \"\" &&\n ele.AdminType == 2) ||\n (ele.Contact !== 0 && adminobj.Admin3Name == \"\" && ele.AdminType == 3)\n ) {\n let res = await cognitoUserDetails(\"+91\" + ele.Contact);\n console.log(\"cognitoUserDetails\", res);\n if (res.statusCode === 400) {\n const resAddPlayer = await addUser(\"+91\" + ele.Contact);\n console.log(\"Resp : \", resAddPlayer);\n ele.UUID = resAddPlayer.User.Username;\n try {\n let playerUserMasterData = await DataStore.save(\n new UserMaster({\n UUID: ele.UUID,\n Name: ele.Name,\n ContactNo: Number(ele.Contact),\n EmailId: ele.Email,\n CreatedBy: UserDetails.Name,\n LastUpdatedBy: UserDetails.Name,\n RoleCoach: false,\n RolePlayer: false,\n })\n );\n await DataStore.save(\n new UserMasterTournament({\n userMasterUUID: ele.UUID,\n tournamentId: CurrentTournament,\n })\n );\n let getTOurnamentdata = await DataStore.query(\n Tournament,\n CurrentTournament\n );\n if (getTOurnamentdata) {\n const updatedTournament = Tournament.copyOf(\n getTOurnamentdata,\n (updated) => {\n updated.Admin1 =\n ele.AdminType == 1\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin1;\n updated.Admin2 =\n ele.AdminType == 2\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin2;\n updated.Admin3 =\n ele.AdminType == 3\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin3;\n\n return updated;\n }\n );\n console.log(\"updatedTournament\", updatedTournament);\n\n const ResponseUpdatedTournament = await DataStore.save(\n updatedTournament\n );\n }\n } catch (error) {}\n } else {\n ele.UUID = res.Username;\n await DataStore.save(\n new UserMasterTournament({\n userMasterUUID: ele.UUID,\n tournamentId: CurrentTournament,\n })\n );\n\n let getTOurnamentdata = await DataStore.query(\n Tournament,\n CurrentTournament\n );\n if (getTOurnamentdata) {\n const updatedTournament = Tournament.copyOf(\n getTOurnamentdata,\n (updated) => {\n updated.Admin1 =\n ele.AdminType == 1\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin1;\n updated.Admin2 =\n ele.AdminType == 2\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin2;\n updated.Admin3 =\n ele.AdminType == 3\n ? {\n Name: ele.Name,\n UUID: ele.UUID,\n PhotoURL: Defaultlogo,\n }\n : updated.Admin3;\n\n return updated;\n }\n );\n console.log(\"updatedTournament\", updatedTournament);\n const ResponseUpdatedTournament = await DataStore.save(\n updatedTournament\n );\n }\n }\n } else {\n errorflag = true;\n console.log(\"Mobile No Manadatory\");\n }\n });\n\n return errorflag;\n };\n\n const handleRemoveAdmins = async (arrlist) => {\n console.log(\"arrlist\", arrlist);\n for (let i = 0; i < arrlist.length; i++) {\n let res = await cognitoUserDetails(\"+91\" + arrlist[i].contact);\n let UUID = res.Username;\n\n console.log(\"handleRemoveAdmins\", res, UUID);\n try {\n const Response = await DataStore.delete(\n UserMasterTournament,\n (UserMasterTournament) =>\n UserMasterTournament?.userMasterUUID.eq(UUID)\n );\n console.log(\"DeleteResponse\", Response);\n // if (Response) {\n let getTOurnamentdata = await DataStore.query(\n Tournament,\n CurrentTournament\n );\n\n console.log(\"getTOurnamentdata\", getTOurnamentdata);\n if (getTOurnamentdata) {\n try {\n const updatedTournament = await Tournament.copyOf(\n getTOurnamentdata,\n (updated: any) => {\n updated.Admin1 =\n arrlist[i].Admin == \"Admin1Name\"\n ? {\n Name: \"\",\n PhotoURL: \"\",\n UUID: \"\",\n }\n : updated.Admin1;\n updated.Admin2 =\n arrlist[i].Admin == \"Admin2Name\"\n ? {\n Name: \"\",\n PhotoURL: \"\",\n UUID: \"\",\n }\n : updated.Admin2;\n updated.Admin3 =\n arrlist[i].Admin == \"Admin3Name\"\n ? {\n Name: \"\",\n PhotoURL: \"\",\n UUID: \"\",\n }\n : updated.Admin3;\n\n return updated;\n }\n );\n console.log(\"updatedTournament\", updatedTournament);\n const ResponseUpdatedTournament = await DataStore.save(\n updatedTournament\n );\n } catch (error) {\n console.log(\"error come after updatetournament\", error);\n }\n }\n // }\n } catch (error) {\n console.log(\"Error in deleting TournamentObj\", error);\n }\n }\n };\n\n const handleCreateRound = (data) => {\n console.log(\"handleCreateRound\", data);\n let RoundTable = [];\n data.map((ele, index) => {\n RoundTable.push({\n No: index + 1,\n Name: ele.Name.trim(),\n Format: ele.Format,\n Completed: false,\n TeamsSelected: false,\n FixturesCreated: false,\n CreatedBy: UserDetails.Name,\n LastUpdatedBy: UserDetails.Name,\n Tournament: CurrentTournament,\n });\n });\n console.log(\"RoundTable\", RoundTable);\n RoundTable.forEach(async (obj) => {\n try {\n const Response2 = await DataStore.save(new RoundMaster(obj));\n console.log(\"responseData\", Response2);\n } catch (error) {\n console.log(\"error\", error);\n }\n });\n };\n\n const handleRemoveRounds = async (Roundlist) => {\n console.log(\"helloRound\", Roundlist);\n Roundlist &&\n Roundlist.length > 0 &&\n Roundlist.map(async (ele) => {\n const modelToDelete = await DataStore.query(RoundMaster, ele.id);\n const Response = await DataStore.delete(modelToDelete);\n if (Response) {\n getTournamentdata();\n }\n });\n };\n const handleCreateUpdateRound = async () => {\n console.log(\"handleCreateUpdateRound\", roundFormat, removeRoundList);\n let createlist =\n roundFormat &&\n roundFormat.length > 0 &&\n roundFormat.filter((ele) => ele.id == \"\");\n console.log(\"hellouser\", createlist);\n if (createlist && createlist.length > 0) {\n await handleCreateRound(createlist);\n }\n if (removeRoundList && removeRoundList.length > 0) {\n await handleRemoveRounds(removeRoundList);\n }\n };\n\n // const handleSave = async () => {\n // await handleCreateUpdateRound();\n // };\n\n const handleSave = async () => {\n await handleCreateUpdateRound();\n console.log(\"inputText\", inputText, roundFormat, Banner, Logo);\n console.log(\"helloupdate\");\n console.log(\"adminobj\", adminobj);\n let errorFlag = false;\n if (\n adminobj.Admin1Name == \"\" ||\n adminobj.Admin2Name == \"\" ||\n adminobj.Admin3Name == \"\" ||\n Admininput.Admin1Email !== adminobj.Admin1Email ||\n Admininput.Admin2Email !== adminobj.Admin2Email ||\n Admininput.Admin3Email !== adminobj.Admin3Email\n ) {\n errorFlag = await handleAdminSave();\n console.log(\"errorFlag\", errorFlag);\n }\n\n if (errorFlag == false) {\n if (DeleteAdminArr && DeleteAdminArr.length > 0) {\n await handleRemoveAdmins(DeleteAdminArr);\n }\n let logo = \"\";\n let banner = \"\";\n let pdffile = \"\";\n let finalRules = \"\";\n console.log(\"finalRules\", inputText.PDfFile, finalRules);\n\n if (selectedLogo && Object.keys(selectedLogo).length > 0) {\n logo = await uploadLogoFileToStorage(\n `tournament/${inputText.TournamentName.replace(/ /g, \"_\")}`,\n selectedLogo\n );\n console.log(\"logo\", logo);\n // setLogoURl(logo);\n }\n if (selectedBaneer && Object.keys(selectedBaneer).length > 0) {\n banner = await uploadLogoFileToStorage(\n `tournament/${inputText.TournamentName.replace(/ /g, \"_\")}`,\n selectedBaneer\n );\n console.log(\"banner\", banner);\n // setBannerURL(banner);\n }\n\n if (PDFfile && Object.keys(PDFfile).length > 0) {\n pdffile = await uploadLogoFileToStorage(\n `tournament/${inputText.TournamentName.replace(/ /g, \"_\")}`,\n PDFfile\n );\n console.log(\"pdffile\", pdffile);\n // setBannerURL(banner);\n }\n\n const tournament = await DataStore.query(Tournament, CurrentTournament);\n const UpdateTournament = Tournament.copyOf(tournament, (updated) => {\n updated.Name = inputText.TournamentName;\n updated.Organizer = inputText.OrganizerName;\n updated.Sport = inputText.Sport;\n updated.RegistrationEndDate = inputText.RegistrationEndDate;\n updated.EndDate = inputText.TournamentEndDate;\n updated.AgeGroup = inputText.Category;\n updated.Type = inputText.Type;\n\n updated.RulesDocument =\n pdffile !== \"\"\n ? pdffile\n : inputText.PDfFile.URL !== \"\" || inputText.PDfFile.URL !== null\n ? inputText.PDfFile.URL\n : Defaultlogo;\n updated.Logo =\n logo !== \"\"\n ? logo\n : inputText.logo.URL !== \"\" || inputText.logo.URL !== null\n ? inputText.logo.URL\n : Defaultlogo;\n updated.Banner =\n banner !== \"\"\n ? banner\n : inputText.banner.URL !== \"\" || inputText.banner.URL !== null\n ? inputText.banner.URL\n : Defaultbanner;\n updated.StartDate = inputText.TournamentStartDate.toString();\n updated.Fees = inputText.RegistrationFees;\n updated.Playing = Number(inputText.Playing);\n updated.Substitute = Number(inputText.Subsitute);\n updated.NoOfTeamsMax = Number(inputText.MaxNoofTeam);\n updated.CutOffDate = inputText.CutOffDate;\n updated.Venues = venues;\n updated.Prizes = PrizesArr;\n updated.Level = inputText.Level;\n updated.Status =\n checkedPublish == \"yes\"\n ? \"SCHEDULED\"\n : checkedPublish == \"no\"\n ? \"CREATED\"\n : updated.Status;\n updated.SubstitutionType =\n checkedSubstitute == \"yes\"\n ? Substitution.REGULAR\n : Substitution.ROLLING;\n // Assuming FixturesCreated is the correct property name\n return updated;\n });\n console.log(\"UpdateTournament\", UpdateTournament);\n const FinalTournamentUpdate = await DataStore.save(UpdateTournament);\n if (FinalTournamentUpdate) {\n console.log(\"Tournament Updated Sucessfully\");\n getTournamentdata();\n setSuccessModalVisible(true);\n setSunccessModalMesg(\"Setting Updated Sucessfully\");\n\n // setSuccessModalVisible(true);\n }\n } else {\n setErrorModalMesg(\"Both Name and Mobile Number are mandatory!\");\n setErrorModalVisible(true);\n }\n\n // console.log(\"Updated RoundObj:\", FinalTournamentUpdate);\n // getUserdata();\n };\n\n function convertToAWSDate(inputDate) {\n // Assuming inputDate is in a format that can be parsed by Date\n // Example: '2024-03-05T12:34:56'\n console.log(\"Input date : \", inputDate);\n // const dateObject = new Date(inputDate);\n // console.log(\"Date Object : \", dateObject);\n // Extract components\n // const year = dateObject.getUTCFullYear();\n // const month = (dateObject.getUTCMonth() + 1).toString().padStart(2, \"0\"); // Months are zero-based\n // const day = dateObject.getUTCDate().toString().padStart(2, \"0\");\n\n // Combine components\n let awsDate = inputDate;\n console.log(\"AWSDATE : \", awsDate);\n return awsDate;\n }\n const handleDropdown = (value, Id, type) => {\n console.log(\"handleDropdown\", Id, value, type, roundFormat);\n let Arrayformat = roundFormat.map((ele) => ({ ...ele }));\n if (type == \"Name\") {\n Arrayformat[Id].Name = value;\n setroundFormant(Arrayformat);\n }\n\n if (type == \"Format\") {\n let dropdown = RoundFormat;\n console.log(\"Arrayformat\", Arrayformat);\n Arrayformat[Id].Format =\n value == \"League\"\n ? dropdown.SINGLE_ROUND_ROBIN\n : value == \"Double Round Robin\"\n ? dropdown.DOUBLE_ROUND_ROBIN\n : dropdown.KNOCKOUT;\n setroundFormant(Arrayformat);\n }\n };\n const getUserDetails = async () => {\n const userDetails = await AsyncStorage.getItem(\"UserDetail\");\n setUserData(userDetails);\n const userdata = await DataStore.query(UserMaster, userDetails);\n console.log(\"SettingUserdata\", userdata);\n setUserDetails(userdata);\n };\n const handleOk = () => {\n setSuccessModalVisible(false);\n setSunccessModalMesg(\"\");\n // navigation.navigate(urlredirect);\n };\n useEffect(() => {\n getTournamentdata();\n getUserDetails();\n }, [CurrentTournament, userData]);\n\n const handlegetVenuedata = (data) => {\n console.log(\"handlegetVenuedata\", data, venues);\n setVenues(data);\n };\n\n const venuesAddField = () => {\n const updatedVenues = [\n ...venues,\n {\n Name: \"\",\n Address: \"\",\n Coordinates: \"\",\n },\n ];\n setVenues(updatedVenues);\n };\n\n const handleVenuDelete = (index) => {\n console.log(\"index i get\", index);\n\n setDeleteModalVisible(true);\n setDeleteModalMesg(\"Are you sure do you want to Delete?\");\n setVenueIdToDelete(index);\n };\n\n const handleConfirm = () => {\n if (deleteModalMesg == \"Are you sure do you want to Delete?\") {\n venuesDeleteField(venueIdToDelete);\n }\n };\n\n const handleCancel = () => {\n setDeleteModalVisible(false);\n };\n\n const handleConfirm2 = () => {\n if (prizeModalMesg == \"Are you sure do you want to Delete?\") {\n PrizesdeleteField(prizeIdToDelete);\n }\n\n if (\n prizeModalMesg ==\n \"If you delete this round, all matches for this round will be deleted. Do you still want to go ahead?\"\n ) {\n console.log(\"hellodleete\");\n handleConfirmRemoveRound();\n }\n };\n const handleCancel2 = () => {\n setPrizeModalVisible(false);\n };\n\n const venuesDeleteField = (index) => {\n const updatedVenues = [...venues];\n updatedVenues.splice(index, 1);\n setVenues(updatedVenues);\n setDeleteModalVisible(false);\n };\n\n const handleRemoveRegulationFile = () => {\n setPDFfile({});\n };\n const onSubmit = () => {\n setErrorModalVisible(false);\n };\n\n const handlegetFiledata = (file, Uri) => {\n console.log(\"hellofile\", file, Uri);\n setPDFfile({ URL: Uri, FileName: file });\n };\n\n const handlechangeAdmindata = (ObjectAdmin, index) => {\n console.log(\"handleRemoveAdmin\", ObjectAdmin, index);\n let newArray = [];\n for (let key in ObjectAdmin) {\n console.log(\"helloprint\", key);\n if (key.includes(`Admin${index}Name`)) {\n let adminNameKey = `Admin${index}Name`;\n let adminContactKey = `Admin${index}Contact`;\n let adminUUIDKey = `Admin${index}UUID`;\n\n let adminName = ObjectAdmin[adminNameKey];\n let adminContact = ObjectAdmin[adminContactKey];\n let adminUUID = ObjectAdmin[adminUUIDKey];\n\n newArray.push({\n name: adminName,\n contact: adminContact,\n Admin: `Admin${index}Name`,\n UUID: adminUUID, // Not sure about the purpose of this line, it seems redundant\n });\n if (DeleteAdminArr && DeleteAdminArr.length > 0) {\n console.log(\n \"finals\",\n !DeleteAdminArr.some((obj) => obj.Admin == `Admin${index}Name`)\n );\n if (!DeleteAdminArr.some((obj) => obj.Admin == `Admin${index}Name`)) {\n setDeleteAdminArr([...DeleteAdminArr, newArray]);\n }\n } else {\n setDeleteAdminArr(newArray);\n }\n }\n\n setAdmininput({\n Admin1Name:\n `Admin${index}Name` == \"Admin1Name\" ? \"\" : Admininput.Admin1Name,\n Admin1Contact:\n `Admin${index}Name` == \"Admin1Name\" ? \"\" : Admininput.Admin1Contact,\n Admin1Email:\n `Admin${index}Name` == \"Admin1Name\" ? \"\" : Admininput.Admin1Email,\n Admin2Name:\n `Admin${index}Name` == \"Admin2Name\" ? \"\" : Admininput.Admin2Name,\n Admin2Contact:\n `Admin${index}Name` == \"Admin2Name\" ? \"\" : Admininput.Admin2Contact,\n Admin2Email:\n `Admin${index}Name` == \"Admin2Name\" ? \"\" : Admininput.Admin2Email,\n Admin3Name:\n `Admin${index}Name` == \"Admin3Name\" ? \"\" : Admininput.Admin3Name,\n Admin3Contact:\n `Admin${index}Name` == \"Admin3Name\" ? \"\" : Admininput.Admin3Contact,\n Admin3Email:\n `Admin${index}Name` == \"Admin3Name\" ? \"\" : Admininput.Admin3Email,\n });\n let AdminObj = {\n Admin1Name:\n `Admin${index}Name` == \"Admin1Name\" ? \"\" : tournamentObj.Admin1Name,\n Admin1Contact:\n `Admin${index}Name` == \"Admin1Name\" ? \"\" : Admininput.Admin1Contact,\n Admin2Name:\n `Admin${index}Name` == \"Admin2Name\" ? \"\" : tournamentObj.Admin2Name,\n Admin2Contact:\n `Admin${index}Name` == \"Admin2Name\" ? \"\" : Admininput.Admin2Contact,\n Admin3Name:\n `Admin${index}Name` == \"Admin3Name\" ? \"\" : tournamentObj.Admin3Name,\n Admin3Contact:\n `Admin${index}Name` == \"Admin3Name\" ? \"\" : Admininput.Admin3Contact,\n };\n\n setAdminobj(AdminObj);\n // console.log(\"newArray\", newArray);\n }\n };\n // const handleRoundType = () => {\n // console.log(\"Helloconsole\");\n\n // };\n const handleRoundType = (field, event, idx) => {\n console.log(\"hellovalue\", field, event, idx);\n const updatedPlayerList = roundFormat.map((player, index) => {\n if (index === idx) {\n if (field == \"Format\") {\n return {\n ...player,\n [field]:\n event == \"League\"\n ? \"SINGLE_ROUND_ROBIN\"\n : event == \"Double Round Robin\"\n ? \"DOUBLE_ROUND_ROBIN\"\n : \"KNOCKOUT\",\n };\n } else {\n return { ...player, [field]: event };\n }\n }\n return player;\n });\n setroundFormant(updatedPlayerList);\n };\n\n return (\n