diff --git a/front-end/package.json b/front-end/package.json index ec5f2b12..0d64b081 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -13,6 +13,7 @@ "@capacitor/ios": "4.2.0", "@capacitor/keyboard": "1.2.2", "@capacitor/push-notifications": "^4.1.0", + "@capacitor/app-launcher": "^4.0.1", "@capacitor/status-bar": "1.0.8", "@teamhive/capacitor-video-recorder": "^5.0.0", "@tensorflow/tfjs": "^3.20.0", diff --git a/front-end/src/components/AR/AR.tsx b/front-end/src/components/AR/AR.tsx index fe709019..e5a71023 100644 --- a/front-end/src/components/AR/AR.tsx +++ b/front-end/src/components/AR/AR.tsx @@ -5,8 +5,7 @@ import {IonButton, IonToast} from '@ionic/react'; import React, { useState } from "react"; import './AR.css'; -import { Device } from '@capacitor/device'; -import compList from './compatibleDevices' +import { AppLauncher } from '@capacitor/app-launcher'; /** * @brief input inteface for IonToast @@ -110,18 +109,20 @@ const AR: React.FC = ( inp ) => { * @returns boolean */ const IsAndroid = async () =>{ - return await isCompatible(); - } - - const isCompatible= async () =>{ - const info = await Device.getInfo(); - console.log(info.model); - if(compList.indexOf(info.model)>=0) + let app:string = 'com.google.ar.core' + + const { value } = await AppLauncher.canOpenUrl({ url: app }); + if(value===true) { + console.log(app + ' is available') return true - else + } + else { + console.log(app + ' is NOT available') return false - + } } + + //=========================================================================================================// /** @@ -158,7 +159,8 @@ const AR: React.FC = ( inp ) => { href+="end;"; // launch intent - window.location.replace(href) ; + + await AppLauncher.openUrl({ url: href}); console.log("isAndroid:" + href); } diff --git a/front-end/src/components/AR/compatibleDevices.tsx b/front-end/src/components/AR/compatibleDevices.tsx deleted file mode 100644 index 2aac6309..00000000 --- a/front-end/src/components/AR/compatibleDevices.tsx +++ /dev/null @@ -1,1084 +0,0 @@ - -export const compList = [ -"ASUS_A002", -"ASUS_A002_1", -"ASUS_A002_2", -"ASUS_AI2201", -"ASUS_AI2202", -"ASUS_I001_1", -"ASUS_I002D", -"ASUS_I003_1", -"ASUS_I004D", -"ASUS_I005_1", -"ASUS_I006D", -"ASUS_I007_1", -"ASUS_I01WD", -"ASUS_Z01QD_1", -"A101BM", -"X01A", -"apollo", -"A101FC", -"F51B", -"FCG01", -"F51A", -"F52A", -"GM9PLUS_s", -"barbet", -"bluejay", -"blueline", -"bonito", -"bramble", -"coral", -"crosshatch", -"flame", -"generic_x86_arm", -"marlin", -"oriole", -"raven", -"redfin", -"sailfish", -"sargo", -"sunfish", -"taimen", -"walleye", -"htc_thudugl", -"HNLGE", -"HW-01K", -"HW-02L", -"HWANE", -"HWCLT", -"HWCOL", -"HWELE", -"HWEML", -"HWEVR", -"HWHMA", -"HWINE", -"HWJKM-H", -"HWJSN-H", -"HWLYA", -"HWNEO", -"HWPAR", -"HWPCT", -"HWSNE", -"HWTNY", -"HWVCE", -"HWVOG", -"angler", -"Infinix-X610", -"Infinix-X663", -"Infinix-X663B", -"Infinix-X663C", -"Infinix-X672", -"Infinix-X676C", -"Infinix-X6810", -"Infinix-X6811", -"Infinix-X6811B", -"Infinix-X6815", -"Infinix-X6815B", -"Infinix-X6820", -"Infinix-X6821", -"Infinix-X687", -"Infinix-X687B", -"Infinix-X690", -"Infinix-X690B", -"Infinix-X690C", -"Infinix-X692", -"Infinix-X695", -"Infinix-X695C", -"Infinix-X695D", -"Infinix-X697", -"Infinix-X698", -"E7110", -"KC-S304", -"KY21L-RG100", -"KYG01", -"KYV46", -"S9-KC_sprout", -"L-01K", -"L-01L", -"L-02K", -"L-41A", -"L-51A", -"L-52A", -"acelm", -"acexlm", -"alphaamz", -"alphalm", -"alphaplus", -"betalm", -"blm", -"bullhead", -"caymanlm", -"caymanslm", -"cv7an", -"cv7as", -"cv7as-pr", -"falcon", -"fh50lm", -"flashlm", -"flashlmdd", -"joan", -"joan", -"judyln", -"judyp", -"judypn", -"lucye", -"mcaymanlm", -"mdh40lm", -"mdh50lm", -"mh", -"mh2lm", -"mh3", -"mh3-pl", -"mhn", -"phoenix_sprout", -"rainbowlm", -"tf10", -"tf10w", -"timelm", -"winglm", -"J607Z", -"J706F", -"J706L", -"Q706F", -"Q706Z", -"TB-J616F", -"TB-J616X", -"YT-J706F", -"YT-J706X", -"capri", -"caprip", -"guamp", -"LPD-10W", -"aliothin", -"E7446", -"ali", -"ali_n", -"astro", -"austin", -"beckham", -"berlin", -"berlna", -"blackjack", -"borneo", -"burton", -"capri", -"caprip", -"cebu", -"cebu", -"channel", -"chef_sprout", -"coful", -"corfur", -"cypfq", -"deen_sprout", -"def", -"denver", -"devon", -"doha", -"doha_n", -"dubai", -"eqs", -"evert", -"evert_n", -"evert_nt", -"foles", -"guamp", -"hanoip", -"hawao", -"hiphi", -"ibiza", -"java", -"java", -"kane_sprout", -"kiev", -"kievv", -"kyoto", -"lake", -"liber", -"lima", -"lisbon", -"messi", -"miami", -"milan", -"milanf", -"minsk", -"nairo", -"nash", -"nio", -"ocean", -"ocean_n", -"ocean_t", -"odessa", -"parker", -"payton", -"payton_sprout", -"pstar", -"racer", -"rav", -"rhode", -"rhodec", -"rhodep", -"river", -"river_n", -"saipan", -"sanders", -"sanders_n", -"sanders_nt", -"smith", -"sofia", -"sofiap", -"sofiap_sprout", -"sofiar", -"tesla", -"tonga", -"troika", -"troika_sprout", -"tundra", -"xpeng", -"LAVIETabT1212QHD1", -"A1N_sprout", -"B2N_sprout", -"BGT", -"BGT_sprout", -"CTL_sprout", -"DRD", -"DRDA_sprout", -"DRD_sprout", -"DRG_sprout", -"DRSA_sprout", -"DRS_sprout", -"NB1", -"PL2_sprout", -"PNX_sprout", -"RAV_VZW", -"Nord", -"OP5154L1", -"OP5155L1", -"OP5159L1", -"OP515BL1", -"OP516EL1", -"OP516FL1", -"OP535DL1", -"OP5552L1", -"OP555BL1", -"OP5566L1", -"OP5567L1", -"OP557AL1", -"OP7ProNRSpr", -"OnePlus3T", -"OnePlus5", -"OnePlus5T", -"OnePlus6", -"OnePlus6T", -"OnePlus6TSingle", -"OnePlus7", -"OnePlus7Pro", -"OnePlus7ProNR", -"OnePlus7ProTMO", -"OnePlus7T", -"OnePlus7TPro", -"OnePlus7TProNR", -"OnePlus7TTMO", -"OnePlus8", -"OnePlus8Pro", -"OnePlus8T", -"OnePlus8TMO", -"OnePlus8TTMO", -"OnePlus8VZW", -"OnePlus9", -"OnePlus9Pro", -"OnePlus9ProTMO", -"OnePlus9R", -"OnePlus9TMO", -"OnePlusN10METRO", -"OnePlusN10TMO", -"OnePlusN200", -"OnePlusN200TMO", -"OnePlusNordCE", -"OnePlusN10", -"CPH1877", -"OP4679", -"OP4699", -"OP46B1", -"OP46C3", -"OP47CFL1", -"OP47DD", -"OP47DDL1", -"OP4845", -"OP4845L1", -"OP4847", -"OP4847L1", -"OP4863", -"OP486B", -"OP48A1", -"OP48A1L1", -"OP4A43", -"OP4A47", -"OP4A57", -"OP4A77", -"OP4A7A", -"OP4A89", -"OP4A9D", -"OP4AA7", -"OP4AB5", -"OP4ABB", -"OP4AD9", -"OP4AE7", -"OP4AF7", -"OP4B65L1", -"OP4B83L1", -"OP4B9B", -"OP4B9EL1", -"OP4BA1L1", -"OP4BA2L1", -"OP4BA5L1", -"OP4BAFL1", -"OP4BDCL1", -"OP4C2DL1", -"OP4C41L1", -"OP4C45L1", -"OP4C4BL1", -"OP4C51L1", -"OP4C5FL1", -"OP4C72L1", -"OP4C77L1", -"OP4C7BL1", -"OP4C87L1", -"OP4E21", -"OP4E75L1", -"OP4EE8L1", -"OP4F0BL1", -"OP4F1BL1", -"OP4F1FL1", -"OP4F25L1", -"OP4F2BL1", -"OP4F39L1", -"OP4F43L1", -"OP4F4DL1", -"OP4F57L1", -"OP4F7FL1", -"OP4F81L1", -"OP4F83L1", -"OP4FA7L1", -"OP520DL1", -"OP5245", -"OP52D1L1", -"OP52D5L1", -"OP52E1L1", -"OP52EBL1", -"OP532BL1", -"OP532FL1", -"OPD4A1L1", -"RE54F3L1", -"RMX1851CN", -"RMX1853", -"RMX1901CN", -"RMX1911", -"alioth", -"aresin", -"bhima", -"camellia", -"camellian", -"fleur", -"gram", -"ingres", -"karna", -"lmi", -"miel", -"munch", -"peux", -"phoenixin", -"surya", -"vayu", -"veux", -"xaga", -"HydrogenONE", -"P780", -"RE50C1", -"RE54ABL1", -"RMX1851", -"RMX1911L1", -"RMX1919", -"RMX1921", -"RMX1921L1", -"RMX1927", -"RMX1931CN", -"RMX1931L1", -"RMX1971", -"RMX1971CN", -"RMX1971L1", -"RMX1973", -"RMX1991CN", -"RMX1992L1", -"RMX1993L1", -"RMX2001L1", -"RMX2002L1", -"RMX2003L1", -"RMX2081L1", -"RMX2085L1", -"RMX2144L1", -"RMX2170L1", -"RMX2202L1", -"XIG02", -"alioth", -"apollo", -"ares", -"begonia", -"begoniain", -"camellia", -"camellian", -"cannon", -"cannong", -"chopin", -"chopin", -"curtana", -"davinci", -"davinciin", -"excalibur", -"fleur", -"ginkgo", -"haydn", -"ingres", -"joyeuse", -"lavender", -"lmi", -"maltose", -"merlin", -"merlinnfc", -"miel", -"munch", -"opal", -"peux", -"phoenix", -"pissarropro", -"raphael", -"raphaelin", -"rosemary", -"secret", -"spes", -"spesn", -"sunny", -"sweet", -"sweetin", -"veux", -"willow", -"xaga", -"xagain", -"xagapro", -"SC-01K", -"SC-01L", -"SC-01M", -"SC-02H", -"SC-02J", -"SC-02K", -"SC-02L", -"SC-02M", -"SC-03J", -"SC-03K", -"SC-03L", -"SC-04L", -"SC-05L", -"SC-41A", -"SC-51A", -"SC-51B", -"SC-51C", -"SC-52A", -"SC-52B", -"SC-52C", -"SC-53A", -"SC-53B", -"SC-53C", -"SC-54A", -"SC-54B", -"SC-54C", -"SC-55B", -"SC-55C", -"SC-56B", -"SC51Aa", -"SCG01", -"SCG02", -"SCG03", -"SCG04", -"SCG06", -"SCG07", -"SCG08", -"SCG09", -"SCG10", -"SCG11", -"SCG12", -"SCG13", -"SCG14", -"SCG15", -"SCV33", -"SCV35", -"SCV36", -"SCV37", -"SCV38", -"SCV39", -"SCV40", -"SCV41", -"SCV42", -"SCV43", -"SCV43-j", -"SCV43-u", -"SCV44", -"SCV45", -"SCV46", -"SCV47", -"SCV48", -"a13x", -"a20", -"a20e", -"a20s", -"a22", -"a22x", -"a23", -"a23xq", -"a30", -"a30s", -"a31", -"a32", -"a32x", -"a33x", -"a3y17lte", -"a40", -"a41", -"a42xq", -"a42xuq", -"a50", -"a50s", -"a51", -"a51x", -"a51xq", -"a52q", -"a52sxq", -"a52xq", -"a53x", -"a5y17lte", -"a5y17ltecan", -"a5y17ltektt", -"a5y17ltelgt", -"a5y17lteskt", -"a60q", -"a6elteaio", -"a6elteatt", -"a6eltemtr", -"a6eltespr", -"a6eltetmo", -"a6elteue", -"a6lte", -"a6lteks", -"a70q", -"a70s", -"a71", -"a71x", -"a71xq", -"a72q", -"a73xq", -"a7y17lte", -"a7y17lteskt", -"a7y18lte", -"a7y18lteks", -"a7y18ve", -"a82xq", -"b0q", -"b0s", -"b2q", -"b4q", -"beyond0", -"beyond0q", -"beyond1", -"beyond1q", -"beyond2", -"beyond2q", -"beyondx", -"beyondxq", -"bloomq", -"bloomxq", -"c1q", -"c1s", -"c2q", -"c2s", -"crownlte", -"crownlteks", -"crownqltechn", -"crownqltecs", -"crownqltesq", -"crownqlteue", -"d1", -"d1q", -"d1x", -"d2q", -"d2s", -"d2x", -"d2xq", -"d2xq2", -"dream2lte", -"dream2lteks", -"dream2qltecan", -"dream2qltechn", -"dream2qltesq", -"dream2qlteue", -"dreamlte", -"dreamlteks", -"dreamqltecan", -"dreamqltechn", -"dreamqltesq", -"dreamqlteue", -"f22", -"f2q", -"f41", -"f42x", -"f62", -"g0q", -"g0s", -"graceqltechn", -"greatlte", -"greatlteks", -"greatqlte", -"greatqltechn", -"greatqltecs", -"greatqlteue", -"gta4l", -"gta4lwifi", -"gta4xl", -"gta4xlve", -"gta4xlvewifi", -"gta4xlwifi", -"gta8", -"gta8wifi", -"gtact4pro", -"gtactive3", -"gtactivexl", -"gtactivexlwifi", -"gts3llte", -"gts3lltechn", -"gts3lltekx", -"gts3llteusc", -"gts3lltevzw", -"gts3lwifi", -"gts3lwifichn", -"gts4llte", -"gts4llteatt", -"gts4lltechn", -"gts4lltekx", -"gts4lltespr", -"gts4lltetmo", -"gts4llteusc", -"gts4lltevzw", -"gts4lv", -"gts4lvwifi", -"gts4lvwifichn", -"gts4lwifi", -"gts4lwifichn", -"gts6l", -"gts6lwifi", -"gts6x", -"gts7fewifi", -"gts7l", -"gts7lwifi", -"gts7xl", -"gts7xllite", -"gts7xllitewifi", -"gts7xlwifi", -"gts8", -"gts8p", -"gts8pwifi", -"gts8u", -"gts8uwifi", -"gts8wifi", -"hero2lte", -"hero2ltebmc", -"hero2ltektt", -"hero2ltelgt", -"hero2lteskt", -"hero2qlteatt", -"hero2qltecctvzw", -"hero2qltechn", -"hero2qltespr", -"hero2qltetmo", -"hero2qlteue", -"hero2qlteusc", -"hero2qltevzw", -"herolte", -"heroltebmc", -"heroltektt", -"heroltelgt", -"herolteskt", -"heroqlteacg", -"heroqlteaio", -"heroqlteatt", -"heroqltecctvzw", -"heroqltelra", -"heroqltemtr", -"heroqltespr", -"heroqltetfnvzw", -"heroqltetmo", -"heroqlteue", -"heroqlteusc", -"heroqltevzw", -"j5y17lte", -"j5y17ltedx", -"j5y17ltektt", -"j5y17ltelgt", -"j5y17lteskt", -"j5y17ltextc", -"j7y17lte", -"j7y17ltektt", -"jackpot2lte", -"jackpotlte", -"jackpotltecan", -"jackpotlteks", -"m20", -"m20lte", -"m21", -"m22", -"m23xq", -"m30s", -"m31", -"m31s", -"m32", -"m33x", -"m51", -"m52xq", -"m53x", -"m62", -"o1q", -"o1s", -"p3q", -"p3s", -"q2q", -"q4q", -"r0q", -"r0s", -"r1q", -"r3q", -"r5q", -"r7", -"r8q", -"r8s", -"r9q", -"r9s", -"star2lte", -"star2lteks", -"star2qltechn", -"star2qltecs", -"star2qltesq", -"star2qlteue", -"starlte", -"starlteks", -"starqltechn", -"starqltecs", -"starqltesq", -"starqlteue", -"t2q", -"t2s", -"v2q", -"victory", -"winner", -"x1q", -"x1s", -"xcoverpro", -"xcoverpro2", -"y2q", -"y2s", -"z3q", -"z3s", -"zodiac", -"BOL", -"Banagher", -"Banagher", -"Chara", -"Chara", -"Jerid", -"JeridA", -"JeridB", -"JeridL", -"Judau", -"Judau", -"JudauL", -"Mineva", -"NAX", -"Nee", -"OBY", -"OJ6", -"PCZ", -"PCZ-u", -"QDA", -"Recoa", -"Recoa", -"Recoa", -"SG808SH", -"SG901SH", -"SG906SH", -"SG907SH", -"SG908SH", -"SGA002SH", -"SH-01M", -"SH-02M", -"SH-04L", -"SH-51A", -"SH-51B", -"SH-52C", -"SH-53A", -"SH-54B", -"SH-M11", -"SH-M12", -"SH-M12", -"SH-M13", -"SH-R10", -"SH-RM11", -"SH-Z20", -"Sarah", -"Sarah", -"SarahH", -"TGD", -"VG2", -"VG2", -"WJG", -"XKH", -"ZMJ", -"vespa_sprout", -"701SO", -"702SO", -"801SO", -"802SO", -"901SO", -"A002SO", -"A101SO", -"A102SO", -"A103SO", -"A201SO", -"A202SO", -"G8141", -"G8142", -"G8188", -"G8341", -"G8342", -"G8343", -"G8441", -"H8116", -"H8166", -"H8216", -"H8266", -"H8276", -"H8296", -"H8314", -"H8324", -"H8416", -"H9436", -"H9493", -"J8110", -"J8170", -"J8210", -"J8270", -"J9110", -"J9150", -"J9180", -"J9210", -"J9260", -"SO-01K", -"SO-01L", -"SO-01M", -"SO-02K", -"SO-03K", -"SO-03L", -"SO-04J", -"SO-04K", -"SO-05K", -"SO-51A", -"SO-51B", -"SO-51C", -"SO-52A", -"SO-52B", -"SO-52C", -"SO-53B", -"SO-53C", -"SOG01", -"SOG02", -"SOG03", -"SOG04", -"SOG05", -"SOG06", -"SOG07", -"SOG08", -"SOV36", -"SOV37", -"SOV38", -"SOV39", -"SOV40", -"SOV41", -"XQ-AQ52", -"XQ-AQ62", -"XQ-AS42", -"XQ-AS52", -"XQ-AS62", -"XQ-AS72", -"XQ-AT42", -"XQ-AT51", -"XQ-AT52", -"XQ-AT72", -"XQ-BC42", -"XQ-BC52", -"XQ-BC62", -"XQ-BC72", -"XQ-BE42", -"XQ-BE52", -"XQ-BE62", -"XQ-BE72", -"XQ-BQ42", -"XQ-BQ52", -"XQ-BQ62", -"XQ-BQ72", -"XQ-BT44", -"XQ-BT52", -"XQ-CC44", -"XQ-CC54", -"XQ-CC72", -"XQ-CT54", -"XQ-CT72", -"venus", -"H400", -"Seattle_5G", -"lake_n", -"TECNO-AB7", -"TECNO-AC8", -"TECNO-CC9", -"TECNO-CE8", -"TECNO-CE9", -"TECNO-CE9h", -"TECNO-CG8", -"TECNO-CG8h", -"TECNO-CH7", -"TECNO-CH7n", -"TECNO-CH9", -"TECNO-CH9n", -"TECNO-CI7n", -"TECNO-CI8", -"TECNO-CI8n", -"TECNO-LE7", -"TECNO-LE7n", -"TECNO-LE8", -"TECNO-LG7n", -"TECNO-LG8n", -"U3AR", -"1805", -"1813", -"1912", -"1913", -"1919", -"1930", -"2004", -"2005", -"2006", -"2009", -"2011", -"2012", -"2017", -"2018", -"2018", -"2019", -"2022", -"2025", -"2041", -"2045", -"2046", -"2047", -"2050", -"2105", -"2124", -"2126", -"2130", -"I1928", -"PD1805", -"PD1824", -"PD1930", -"PD1981", -"V2144", -"V2145", -"V2158", -"V2202", -"cassia", -"jacaranda", -"jacarandapro", -"W-P611", -"amber", -"apollo", -"beryllium", -"cas", -"cepheus", -"cmi", -"courbet", -"courbetin", -"cupid", -"dipper", -"diting", -"gauguin", -"gauguininpro", -"grus", -"haydn", -"haydnin", -"laurel_sprout", -"lisa", -"lmipro", -"mars", -"monet", -"nabu", -"perseus", -"pissarroinpro", -"polaris", -"psyche", -"pyxis", -"renoir", -"sirius", -"star", -"taoyao", -"toco", -"tucana", -"umi", -"vangogh", -"venus", -"vili", -"violet", -"zeus", -"NX709J", -"Z6571S", -"Z6650S", -"sweet", -"EC50", -"EC55", -"ET40L", -"ET40S", -"ET51L", -"ET51S", -"ET56L", -"ET56S", -"TC21", -"TC26", -"TC52", -"TC52X", -"TC53", -"TC57", -"TC57X", -"TC58", -"TC72", -"TC77", -"RE5081", -"RE513CL1", -"RE54CBL1", -"RE879EL1", -"RMX2061L1", -"RMX2063L1", -"RMX2075L1", -"RMX2076L1", -"RMX2083L1", -"RMX2086L1", -"RMX2111L1", -"RMX2151L1", -"RMX2161L1", -"RMX3031L1", -"RMX3081L1", -"RMX3092L1" -] -export default compList \ No newline at end of file diff --git a/front-end/src/components/AcceptRejectCard/AcceptRejectCard.tsx b/front-end/src/components/AcceptRejectCard/AcceptRejectCard.tsx index 0e3fc486..c4887c98 100644 --- a/front-end/src/components/AcceptRejectCard/AcceptRejectCard.tsx +++ b/front-end/src/components/AcceptRejectCard/AcceptRejectCard.tsx @@ -153,8 +153,8 @@ export const AcceptRejectCard: React.FC = (props) =>{ color="success" /> setLoading(false)} diff --git a/front-end/src/components/BurgerMenu/BurgerMenu.tsx b/front-end/src/components/BurgerMenu/BurgerMenu.tsx index 9e4d28e1..d75edba3 100644 --- a/front-end/src/components/BurgerMenu/BurgerMenu.tsx +++ b/front-end/src/components/BurgerMenu/BurgerMenu.tsx @@ -9,15 +9,16 @@ export const BurgerMenu=(props:{listItems:any[]})=>{ // used for routing let history=useHistory() return( - + + Menu - - - + + + {props.listItems.map((el:any)=> @@ -27,7 +28,7 @@ export const BurgerMenu=(props:{listItems:any[]})=>{ )}
- { + { localStorage.removeItem("email") localStorage.removeItem("password") localStorage.removeItem("usertype") @@ -44,7 +45,6 @@ export const BurgerMenu=(props:{listItems:any[]})=>{ - ) } diff --git a/front-end/src/components/FriendRequestsList/FriendRequestList.tsx b/front-end/src/components/FriendRequestsList/FriendRequestList.tsx index 8acc1186..87603896 100644 --- a/front-end/src/components/FriendRequestsList/FriendRequestList.tsx +++ b/front-end/src/components/FriendRequestsList/FriendRequestList.tsx @@ -32,9 +32,11 @@ const FriendRequestList: React.FC = () =>{ }) .then(response =>response.data) .then(response =>{ - console.log(response) - setRequests(response.results) - setLoading(false) + if(response.success){ + console.log(response) + setRequests(response.results) + setLoading(false) + } }) .catch(err => { console.log(err) @@ -52,8 +54,8 @@ const FriendRequestList: React.FC = () =>{ 'Content-Type': 'application/json', }, data: JSON.stringify({ - fromEmail: localStorage.getItem("email"), - toEmail: otherEmail + toEmail: otherEmail, + fromEmail: localStorage.getItem("email") }) }) @@ -61,6 +63,26 @@ const FriendRequestList: React.FC = () =>{ .then(response =>{ console.log(response) getFriendRequests() + + let message:string = localStorage.getItem("email") +" has accepted your friend reqeust" + // api call to notify accepted friend request + axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/SendGenericNotification`,{ + "method":"POST", + + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + data:{ + pushTarget: [otherEmail], + pushTitle: "Friend Request Accepted", + pushMessage: message, + isSilent: false + } + }) + .then(response =>response.data) + .catch(err => {console.log(err)}) + setShowConfirm(true) setLoading(false) }) @@ -148,8 +170,8 @@ const FriendRequestList: React.FC = () =>{ color="success" /> setLoading(false)} diff --git a/front-end/src/components/GymCard/GymCard.tsx b/front-end/src/components/GymCard/GymCard.tsx index 5685796c..7755d913 100644 --- a/front-end/src/components/GymCard/GymCard.tsx +++ b/front-end/src/components/GymCard/GymCard.tsx @@ -179,7 +179,6 @@ setLoading(false)} diff --git a/front-end/src/components/GymOwner-ViewBadgeGrid/GymOwnerViewBadgeGrid.tsx b/front-end/src/components/GymOwner-ViewBadgeGrid/GymOwnerViewBadgeGrid.tsx index 678744e4..d65eb6d6 100644 --- a/front-end/src/components/GymOwner-ViewBadgeGrid/GymOwnerViewBadgeGrid.tsx +++ b/front-end/src/components/GymOwner-ViewBadgeGrid/GymOwnerViewBadgeGrid.tsx @@ -1,5 +1,5 @@ -import { IonCol, IonGrid, IonLoading, IonRow} from '@ionic/react'; -import { useEffect, useState, } from 'react'; +import { IonCol, IonGrid, IonLoading, IonRow, useIonViewWillEnter} from '@ionic/react'; +import { useState, } from 'react'; import ViewBadgeCard from './ViewBadgeCard/ViewBadgeCard'; import axios from 'axios'; @@ -10,12 +10,13 @@ export const GymOwnerViewBadgeGrid=(props: {gymID:string})=>{ //GET REQUEST: - useEffect(()=> + useIonViewWillEnter(()=> { + console.log(props.gymID) axios.get(process.env["REACT_APP_GYM_KING_API"]+`/badges/gym/${props.gymID}`) .then(response =>response.data) .then(response =>{ - //console.log(response) + console.log(response) let arr=[]; for(let i=0; i{ setLoading(false)} diff --git a/front-end/src/components/GymsList/GymItem/GymItem.tsx b/front-end/src/components/GymsList/GymItem/GymItem.tsx index 5458f852..6b14e5dd 100644 --- a/front-end/src/components/GymsList/GymItem/GymItem.tsx +++ b/front-end/src/components/GymsList/GymItem/GymItem.tsx @@ -9,8 +9,6 @@ const GymsList: React.FC = (props) =>{ let history=useHistory() - - const [gymBrandName, setGymBrandName] = useState("") const [gymName, setGymName] = useState("") const [gymAddress, setGymAddress] = useState("") @@ -19,6 +17,8 @@ const GymsList: React.FC = (props) =>{ useEffect(()=>{ + console.log(props.gymId) + //get gym info axios.get(process.env["REACT_APP_GYM_KING_API"]+`/gyms/gym/${props.gymId}`) .then(response =>response.data) @@ -41,7 +41,9 @@ const GymsList: React.FC = (props) =>{ .catch(err => { console.log(err) }) - }) + + setLoading(false) + },[props,gymBrandName]) const viewGymProfile = (brandname:string, address:string) =>{ @@ -62,8 +64,8 @@ const GymsList: React.FC = (props) =>{ {gymName} setLoading(false)} diff --git a/front-end/src/components/GymsList/GymsList.tsx b/front-end/src/components/GymsList/GymsList.tsx index 79e0e4c8..fd183c1d 100644 --- a/front-end/src/components/GymsList/GymsList.tsx +++ b/front-end/src/components/GymsList/GymsList.tsx @@ -13,7 +13,7 @@ const GymsList: React.FC = (props) =>{ { props.gymsList?.map((el:any)=>{ - return () + return () }) } diff --git a/front-end/src/components/Register/Gym.tsx b/front-end/src/components/Register/Gym.tsx index 8447be73..34feaa29 100644 --- a/front-end/src/components/Register/Gym.tsx +++ b/front-end/src/components/Register/Gym.tsx @@ -14,7 +14,7 @@ export const Gym: React.FC = (props) =>{ useEffect(()=>{ getBrands() - }) + },[]) const getBrands = async() =>{ let gyms: any[]=[] @@ -72,7 +72,6 @@ export const Gym: React.FC = (props) =>{ setLoading(false)} diff --git a/front-end/src/components/SelectGym-Map/SelectGymMap.tsx b/front-end/src/components/SelectGym-Map/SelectGymMap.tsx index 61ecb0fe..dba415fb 100644 --- a/front-end/src/components/SelectGym-Map/SelectGymMap.tsx +++ b/front-end/src/components/SelectGym-Map/SelectGymMap.tsx @@ -101,7 +101,7 @@ export function SelectGymMap() { console.log(e) } console.log("using geocoding api"); - Geocoder.init("AIzaSyD9pQDwcGJFK6NRGNj5-YwdJBx2PtERCTg"); + Geocoder.init(""); Geocoder.from(gymCoord[0],gymCoord[1]) .then((json) => { if(json.status==="OK") @@ -120,7 +120,7 @@ const handleKeyDown = (event: { key: string }) => { if (event.key === "Enter") { console.log("enter was pressed") console.log("using geocoding api"); - Geocoder.init("AIzaSyD9pQDwcGJFK6NRGNj5-YwdJBx2PtERCTg"); + Geocoder.init(""); Geocoder.from(gymAddress) .then((json) => { if(json.status==="OK") diff --git a/front-end/src/components/map/MapView.css b/front-end/src/components/map/MapView.css index 2d3e1c89..bc67385b 100644 --- a/front-end/src/components/map/MapView.css +++ b/front-end/src/components/map/MapView.css @@ -41,6 +41,9 @@ main { background-image: linear-gradient(to bottom right, #321E93, #873CFF); } +.mainMap { + --overflow: hidden !important; +} ion-input{ diff --git a/front-end/src/components/map/MapView.tsx b/front-end/src/components/map/MapView.tsx index c37e43bd..67e8d9d6 100644 --- a/front-end/src/components/map/MapView.tsx +++ b/front-end/src/components/map/MapView.tsx @@ -406,7 +406,7 @@ const MapView: React.FC = () =>{ return ( <> - + { setLoading(false)} spinner={"circles"} cssClass="spinner" diff --git a/front-end/src/pages/AddEmployee/AddEmployee.tsx b/front-end/src/pages/AddEmployee/AddEmployee.tsx index b63bf283..97620f5b 100644 --- a/front-end/src/pages/AddEmployee/AddEmployee.tsx +++ b/front-end/src/pages/AddEmployee/AddEmployee.tsx @@ -1,4 +1,4 @@ -import {IonContent, IonText, IonPage, IonHeader, IonButton, IonInput, IonToast, useIonViewDidEnter, IonLoading} from '@ionic/react'; +import {IonContent, IonText, IonPage, IonHeader, IonButton, IonInput, IonToast, useIonViewDidEnter, IonLoading, IonLabel} from '@ionic/react'; import React, { useState} from 'react'; import { RadioGroup } from '../../components/radioGroup/radioGroup'; import ToolBar from '../../components/toolbar/Toolbar'; @@ -30,13 +30,13 @@ export const AddEmployee: React.FC = () =>{ }); const handleError = (error:string, input:string) => { + console.log(errors) setErrors(prevState => ({...prevState, [input]: error})); }; const validate = () => { let isValid = true - if(formData.email && !validEmail(formData.email)) { handleError('Please input a valid email', 'email'); isValid = false; @@ -44,15 +44,15 @@ export const AddEmployee: React.FC = () =>{ else handleError('', 'email'); - if(formData.name && !onlyLettersAndSpaces(formData.name)) { + if(formData.name && onlyLettersAndSpaces(formData.name)) { handleError('Please input a valid name', 'name'); isValid = false; } else handleError('', 'name'); - if(formData.number && !validPhone(formData.number)) { - handleError('Please input a valid phone', 'phone'); + if(formData.phone && !validPhone(formData.phone)) { + handleError('Please input a valid phone number', 'phone'); isValid = false; } else @@ -72,7 +72,7 @@ export const AddEmployee: React.FC = () =>{ else handleError('', 'password'); - if(formData.gid !=="") { + if(formData.gid ==="") { handleError('Please select a gym.', 'gid'); isValid = false; } @@ -123,7 +123,10 @@ export const AddEmployee: React.FC = () =>{ password: e.target.password.value, gid: gymId, }; - createEmployee(); + + let isValid = validate() + if(isValid) + createEmployee(); } const createEmployee=()=>{ @@ -175,22 +178,58 @@ export const AddEmployee: React.FC = () =>{

Email* -

+ + {errors.email!=="" && ( + <> + {errors.email}

+ + )} +

Full name* -

+ + {errors.name!=="" && ( + <> + {errors.name}

+ + )} +

Phone Number* -

+ + {errors.number!=="" && ( + <> + {errors.number}

+ + )} +

Username* -

+ + {errors.username!=="" && ( + <> + {errors.username}

+ + )} +

Password* -

+ + {errors.password!=="" && ( + <> + {errors.password}

+ + )} +

Gym* -



+ + {errors.gid!=="" && ( + <> + {errors.gid}

+ + )} +



Add Employee @@ -222,8 +261,8 @@ export const AddEmployee: React.FC = () =>{ color="danger" /> setLoading(false)} diff --git a/front-end/src/pages/AddGym/AddGym.tsx b/front-end/src/pages/AddGym/AddGym.tsx index 6557b25b..b8fc0ec7 100644 --- a/front-end/src/pages/AddGym/AddGym.tsx +++ b/front-end/src/pages/AddGym/AddGym.tsx @@ -317,8 +317,8 @@ const AddGym: React.FC = () => { color="danger" /> setLoading(false)} diff --git a/front-end/src/pages/CreateBadgePage/CreateBadge.tsx b/front-end/src/pages/CreateBadgePage/CreateBadge.tsx index a2afed56..e49b64f3 100644 --- a/front-end/src/pages/CreateBadgePage/CreateBadge.tsx +++ b/front-end/src/pages/CreateBadgePage/CreateBadge.tsx @@ -22,6 +22,8 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; const color = "#ffca22" const transparent = "#9d9fa669" const [gymId, setGymId] = useState('') + + const [activeGymName, setActiveGymName] = useState('') const [showToast, setShowToast] = useState(false); const [ownedGyms, setOwnedGyms] = useState([]); const [badgename, setBadgename] = useState(''); @@ -110,9 +112,12 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; localStorage.setItem('act', e); //setActivityType(e) } - const setChosenGymLocation = (e:any) =>{ + + const setChosenGymLocation= (e:any) =>{ console.log(e); + setActiveGymName(e.gym_name) setGymId(e) + localStorage.setItem("gymId", e) } @@ -127,7 +132,7 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; badgeName: e.target.badgeName.value, badgeDescription: e.target.badgeDescription.value, badgeChallenge:e.target.badgeChallenge.value, - gymId: gymId, + gymId: localStorage.getItem("gymId"), req1: e.target.req1.value, req2: e.target.req2.value, req3: e.target.req3.value @@ -183,6 +188,29 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; }) .then(response =>response.data) .then(response =>{ + let message:string = bn+" was created at " + activeGymName + + console.log(message) + console.log(gymId) + + // api call to notify subscribers + axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/SendSubscriberNotification`,{ + "method":"POST", + + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + data:{ + g_id: gymId, + pushTitle: "New Badge Available!", + pushMessage: message, + isSilent: true + } + }) + .then(response =>response.data) + .catch(err => {console.log(err)}) + console.log(response) setLoading(false) //show toast @@ -526,9 +554,9 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; selectTag(strengthTags[7], 7)} style={{"backgroundColor": chipColor7}} >{strengthTags[7]} selectTag(strengthTags[8], 8)} style={{"backgroundColor": chipColor8}} >{strengthTags[8]} selectTag(strengthTags[9], 9)} style={{"backgroundColor": chipColor9}} >{strengthTags[9]} - selectTag(strengthTags[10], 10)} style={{"backgroundColor": chipColor7}} >{strengthTags[10]} - selectTag(strengthTags[11], 11)} style={{"backgroundColor": chipColor8}} >{strengthTags[11]} - selectTag(strengthTags[12], 12)} style={{"backgroundColor": chipColor9}} >{strengthTags[12]} + selectTag(strengthTags[10], 10)} style={{"backgroundColor": chipColor10}} >{strengthTags[10]} + selectTag(strengthTags[11], 11)} style={{"backgroundColor": chipColor11}} >{strengthTags[11]} + selectTag(strengthTags[12], 12)} style={{"backgroundColor": chipColor12}} >{strengthTags[12]} @@ -581,8 +609,8 @@ import { onlyLettersAndSpaces } from '../../utils/validation'; color="success" /> setLoading(false)} diff --git a/front-end/src/pages/EditBadgePage/EditBadge.tsx b/front-end/src/pages/EditBadgePage/EditBadge.tsx index 6f319a44..5503b0d4 100644 --- a/front-end/src/pages/EditBadgePage/EditBadge.tsx +++ b/front-end/src/pages/EditBadgePage/EditBadge.tsx @@ -1,11 +1,11 @@ -import {IonContent, IonText, IonPage, IonHeader, IonButton, IonInput, IonTextarea, IonToast, IonLoading, useIonViewDidEnter, IonCol, IonGrid, IonRow} from '@ionic/react'; +import {IonContent, IonText, IonPage, IonHeader, IonButton, IonInput, IonTextarea, IonToast, IonLoading, useIonViewDidEnter, IonCol, IonGrid, IonRow, IonLabel} from '@ionic/react'; import ToolBar from '../../components/toolbar/Toolbar'; import React, {useState } from 'react'; -import { createBadgeSchema } from '../../validation/CreateBadgeValidation'; import SegmentButton from '../../components/segmentButton/segmentButton'; import { useHistory } from 'react-router-dom'; import BadgeSlider from '../../components/BadgeSlider/BadgeSlider'; import axios from "axios"; +import { onlyLettersAndSpaces } from '../../utils/validation'; const EditBadge: React.FC = () =>{ @@ -29,6 +29,54 @@ const EditBadge: React.FC = () =>{ let badgeId= localStorage.getItem("badgeid"); let tags ="" + //FORM VALIDATION + const [errors, setErrors] = useState({ + name: '', + activitytype:'', + description: '', + challenge:'', + req1:'', + req2:'', + req3:'', + gym:'', + + }); + + const handleError = (error:string, input:string) => { + setErrors(prevState => ({...prevState, [input]: error})); + }; + + const validate = () => { + let isValid = true + console.log(formData.gymId) + + if(formData.badgeName && onlyLettersAndSpaces(formData.badgeName)) { + handleError('Please input a valid name', 'name'); + isValid = false; + } + else + handleError('', 'name'); + + console.log(gymId) + if(gymId==="") { + handleError('Please select a gym', 'gym'); + isValid = false; + } + else + handleError('', 'gym'); + + if(localStorage.getItem('act') ==='') { + handleError('Please select an activty type', 'activitytype'); + isValid = false; + } + else + handleError('', 'activitytype'); + + + + return isValid; + } + //METHODS const setChosenActivityType = (e:any) =>{ localStorage.setItem('act', e); @@ -53,7 +101,7 @@ const EditBadge: React.FC = () =>{ }; - const isValid = await createBadgeSchema.isValid(formData); + const isValid = validate() if(isValid) { @@ -193,18 +241,30 @@ const EditBadge: React.FC = () =>{ Edit Badge
- Badge Name:



-



+ Badge Name:



+ + {errors.name!=="" && ( + <> + {errors.name}

+ + )} +



- Activity Type:



-



+ Activity Type:



+ + {errors.activitytype!=="" && ( + <> + {errors.activitytype}

+ + )} +



- Badge Challenge:



+ Badge Challenge:







- Badge Description:



+ Badge Description:







{ @@ -213,7 +273,7 @@ const EditBadge: React.FC = () =>{ - Weight: + Weight: @@ -221,7 +281,7 @@ const EditBadge: React.FC = () =>{ - Reps: + Reps: @@ -229,7 +289,7 @@ const EditBadge: React.FC = () =>{ - Sets: + Sets: @@ -243,7 +303,7 @@ const EditBadge: React.FC = () =>{ - Distance: + Distance: @@ -251,7 +311,7 @@ const EditBadge: React.FC = () =>{ - Duration: + Duration: @@ -259,7 +319,7 @@ const EditBadge: React.FC = () =>{ - Level of Difficulty: + Difficulty: @@ -267,6 +327,8 @@ const EditBadge: React.FC = () =>{ } + +

SAVE CHANGES @@ -293,7 +355,6 @@ const EditBadge: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/EditGymPage/EditGym.tsx b/front-end/src/pages/EditGymPage/EditGym.tsx index 0e88eac5..b0c6ab48 100644 --- a/front-end/src/pages/EditGymPage/EditGym.tsx +++ b/front-end/src/pages/EditGymPage/EditGym.tsx @@ -298,8 +298,8 @@ const EditGym: React.FC = () => { color="danger" /> setLoading(false)} diff --git a/front-end/src/pages/EmployeeHomePage/EmployeeHome.tsx b/front-end/src/pages/EmployeeHomePage/EmployeeHome.tsx index f36984a0..5240b1ab 100644 --- a/front-end/src/pages/EmployeeHomePage/EmployeeHome.tsx +++ b/front-end/src/pages/EmployeeHomePage/EmployeeHome.tsx @@ -13,7 +13,7 @@ const EmployeeHomePage: React.FC = () =>{

- + Employee Page Pending Approvals diff --git a/front-end/src/pages/EmployeeProfile/EmployeeProfile.tsx b/front-end/src/pages/EmployeeProfile/EmployeeProfile.tsx index bf60f5f2..50309700 100644 --- a/front-end/src/pages/EmployeeProfile/EmployeeProfile.tsx +++ b/front-end/src/pages/EmployeeProfile/EmployeeProfile.tsx @@ -3,6 +3,7 @@ import React, {useRef, useState} from 'react' import { ToolBar } from '../../components/toolbar/Toolbar'; import "./EmployeeProfile.css"; import axios from "axios"; +import { validEmail, onlyLettersAndSpaces, onlyAlphanumericAndUnderscore, validPhone } from '../../utils/validation'; interface InternalValues { file: any; @@ -26,14 +27,54 @@ const EmployeeProfilePage: React.FC = () =>{ const [showFail, setShowFail] = useState(false); const [loading, setLoading] = useState(false); - + const [presentingElement, setPresentingElement] = useState(null); + //FORM VALIDATION + const [errors, setErrors] = useState({ + username: '', + fullname: '', + email: '', + phone: '', + }); + const handleError = (error:string, input:string) => { + setErrors(prevState => ({...prevState, [input]: error})); + }; - const [presentingElement, setPresentingElement] = useState(null); + const validate = () => { + let isValid = true + + if(email && !validEmail(email)) { + handleError('Please input a valid email', 'email'); + isValid = false; + } + else + handleError('', 'email'); + + if(name && onlyLettersAndSpaces(name)) { + handleError('Please input a valid name', 'fullname'); + isValid = false; + } + else + handleError('', 'fullname'); + + if(username && !onlyAlphanumericAndUnderscore(username)) { + handleError('Please input a valid username', 'username'); + isValid = false; + } + else + handleError('', 'username'); + if(phone && !validPhone(phone)) { + handleError('Please input a valid phone number', 'phone'); + isValid = false; + } + else + handleError('', 'phone'); + return isValid; + } useIonViewDidEnter(()=>{ setPresentingElement(page.current); //for modal setLoading(true) @@ -104,12 +145,17 @@ const EmployeeProfilePage: React.FC = () =>{ } const updateDetails = (e:any) =>{ - //update - updateEmployeeDetails() - //dismiss - dismiss() + let isValid=validate() + if(isValid) + { + //update + updateEmployeeDetails() + //dismiss + dismiss() - setShowSuccess(true); + setShowSuccess(true); + } + } const updateEmail=(e:any)=>{ @@ -269,21 +315,36 @@ const EmployeeProfilePage: React.FC = () =>{ Username - + {errors.username!=="" && ( + <> + {errors.username}

+ + )} +

Full name - + {errors.fullname!=="" && ( + <> + {errors.fullname}

+ + )}

Email - + {errors.email!=="" && ( + <> + {errors.email}

+ + )}

Phone - + {errors.phone!=="" && ( + <> + {errors.phone}

+ + )}

- Password - Change Password
@@ -307,7 +368,6 @@ const EmployeeProfilePage: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/EmployeeProfileView/EmployeeProfileView.tsx b/front-end/src/pages/EmployeeProfileView/EmployeeProfileView.tsx index 74c8e847..6f8ac41e 100644 --- a/front-end/src/pages/EmployeeProfileView/EmployeeProfileView.tsx +++ b/front-end/src/pages/EmployeeProfileView/EmployeeProfileView.tsx @@ -180,7 +180,6 @@ const EmployeeProfileViewPage: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/Explore/Explore.tsx b/front-end/src/pages/Explore/Explore.tsx index 27f371e5..7871951f 100644 --- a/front-end/src/pages/Explore/Explore.tsx +++ b/front-end/src/pages/Explore/Explore.tsx @@ -28,7 +28,7 @@ const Explore: React.FC = () =>{ const [gymAddress, setGymAddress] =useState("") //suggested badges - const [badgeSuggestions, setBadgeSuggestions] =useState([]) + const [badgeSuggestions, setBadgeSuggestions] =useState() useIonViewWillEnter(async()=>{ @@ -49,7 +49,8 @@ const Explore: React.FC = () =>{ .then(response =>{ setLoading(false) console.log(response) - setBadgeSuggestions(response) + if(response.success) + setBadgeSuggestions(response) }) .catch(err => { @@ -126,6 +127,7 @@ const Explore: React.FC = () =>{ const findUser = (user:any) =>{ + console.log(user) axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/getUser`,{ method: 'POST', headers: { @@ -140,7 +142,8 @@ const Explore: React.FC = () =>{ }) .then(response =>response.data) .then(response =>{ - if(response.message) + console.log(response) + if(response.message==="User does not exist!") { setFoundUser(false) setEmail("") @@ -168,7 +171,8 @@ const Explore: React.FC = () =>{ .then(response =>response.data) .then(response =>{ - if(response ===null) + console.log(response) + if(response===null) { setFoundGym(false) setGid("") @@ -226,6 +230,7 @@ const Explore: React.FC = () =>{ { foundUser && + <> @@ -244,6 +249,7 @@ const Explore: React.FC = () =>{ + }

@@ -300,11 +306,12 @@ const Explore: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} + showBackdrop={true} + />
diff --git a/front-end/src/pages/ForgotPassword/ForgotPassword.tsx b/front-end/src/pages/ForgotPassword/ForgotPassword.tsx index 24ac3215..bc4a77b6 100644 --- a/front-end/src/pages/ForgotPassword/ForgotPassword.tsx +++ b/front-end/src/pages/ForgotPassword/ForgotPassword.tsx @@ -233,8 +233,8 @@ export const ForgotPassword: React.FC = () =>{ color="danger" /> setLoading(false)} diff --git a/front-end/src/pages/FriendProfile/FriendProfile.tsx b/front-end/src/pages/FriendProfile/FriendProfile.tsx index a1297621..8f3a8b5d 100644 --- a/front-end/src/pages/FriendProfile/FriendProfile.tsx +++ b/front-end/src/pages/FriendProfile/FriendProfile.tsx @@ -124,7 +124,7 @@ const FriendProfile: React.FC = () =>{ /> setLoading(false)} diff --git a/front-end/src/pages/FriendsPage/FriendsPage.tsx b/front-end/src/pages/FriendsPage/FriendsPage.tsx index d2b12d50..e855495b 100644 --- a/front-end/src/pages/FriendsPage/FriendsPage.tsx +++ b/front-end/src/pages/FriendsPage/FriendsPage.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react' +import React, { useState} from 'react' import {IonContent, IonText, IonPage, IonHeader, IonItem, IonLabel, useIonViewWillEnter, IonLoading} from '@ionic/react'; import { ToolBar } from '../../components/toolbar/Toolbar'; import FriendsList from '../../components/FriendsList/FriendsList'; @@ -20,6 +20,8 @@ const FriendsPage: React.FC = () =>{ useIonViewWillEnter(()=>{ setLoading(true) + + console.log("ion page entered") //remove session storage sessionStorage.removeItem("friendUsername") sessionStorage.removeItem("friendEmail") @@ -34,20 +36,24 @@ const FriendsPage: React.FC = () =>{ }, data: JSON.stringify({ userEmail: localStorage.getItem("email"), - }) }) .then(response =>response.data) .then(response =>{ - setLoading(false) + console.log(response) setFriends(response) + + setLoading(false) }) .catch(err => { setLoading(false) console.log(err) + setFriends([]) + }) + console.log(friends) },[]) //================================================================================================= @@ -75,7 +81,7 @@ const FriendsPage: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/GymOwner-ViewBadge/GymOwnerViewBadge.tsx b/front-end/src/pages/GymOwner-ViewBadge/GymOwnerViewBadge.tsx index e5ea284a..0e1550d0 100644 --- a/front-end/src/pages/GymOwner-ViewBadge/GymOwnerViewBadge.tsx +++ b/front-end/src/pages/GymOwner-ViewBadge/GymOwnerViewBadge.tsx @@ -77,7 +77,6 @@ const GymOwnerViewBadge: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/GymOwnerPage/GymOwnerPage.tsx b/front-end/src/pages/GymOwnerPage/GymOwnerPage.tsx index 46e481a2..ad6c2280 100644 --- a/front-end/src/pages/GymOwnerPage/GymOwnerPage.tsx +++ b/front-end/src/pages/GymOwnerPage/GymOwnerPage.tsx @@ -13,7 +13,7 @@ const GymOwnerPage: React.FC = () =>{

- + Owner Page Manage Gyms

diff --git a/front-end/src/pages/GymPage/GymPage.tsx b/front-end/src/pages/GymPage/GymPage.tsx index 31b95079..b1b67a84 100644 --- a/front-end/src/pages/GymPage/GymPage.tsx +++ b/front-end/src/pages/GymPage/GymPage.tsx @@ -41,14 +41,17 @@ const GymPage: React.FC = () =>{ }) .then(response =>response.data) .then(response =>{ - setLoading(false) - console.log(response) - setSubscribed(response) + + if(response===true){ + console.log(response) + setSubscribed(true) + } + setLoading(false) }) .catch(err => { setLoading(false) - console.log(err) + console.log(err) }) }) @@ -81,6 +84,7 @@ const GymPage: React.FC = () =>{ history.push("/ViewBadges") } const goToLeaderboard = () =>{ + sessionStorage.setItem("gid",gid!) history.push("/Leaderboard") } @@ -193,7 +197,7 @@ const GymPage: React.FC = () =>{ /> setLoading(false)} diff --git a/front-end/src/pages/Leaderboard/Leaderboard.tsx b/front-end/src/pages/Leaderboard/Leaderboard.tsx index b55ecd5f..d0ae6c20 100644 --- a/front-end/src/pages/Leaderboard/Leaderboard.tsx +++ b/front-end/src/pages/Leaderboard/Leaderboard.tsx @@ -32,6 +32,7 @@ const Leaderboard: React.FC = () =>{ useIonViewDidEnter(()=> { var gymid=sessionStorage.getItem("gid"); + console.log(sessionStorage.getItem("gid")) var index:number; var Overall:any=[]; var Cardio:any=[]; @@ -159,7 +160,6 @@ const Leaderboard: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/pages/LoginPage/Login.tsx b/front-end/src/pages/LoginPage/Login.tsx index 6eb63fd6..21b6b109 100644 --- a/front-end/src/pages/LoginPage/Login.tsx +++ b/front-end/src/pages/LoginPage/Login.tsx @@ -202,7 +202,6 @@ export const Login: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/ManageEmployees/ManageEmployees.tsx b/front-end/src/pages/ManageEmployees/ManageEmployees.tsx index 7d969525..21282fe5 100644 --- a/front-end/src/pages/ManageEmployees/ManageEmployees.tsx +++ b/front-end/src/pages/ManageEmployees/ManageEmployees.tsx @@ -113,7 +113,6 @@ const ManageEmployees: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/pages/ManageGyms/ManageGyms.tsx b/front-end/src/pages/ManageGyms/ManageGyms.tsx index 2f4d8764..a31833b5 100644 --- a/front-end/src/pages/ManageGyms/ManageGyms.tsx +++ b/front-end/src/pages/ManageGyms/ManageGyms.tsx @@ -115,7 +115,6 @@ const ManageGyms: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/MyBadge/MyBadge.tsx b/front-end/src/pages/MyBadge/MyBadge.tsx index 393be39e..5a23cfe3 100644 --- a/front-end/src/pages/MyBadge/MyBadge.tsx +++ b/front-end/src/pages/MyBadge/MyBadge.tsx @@ -136,7 +136,6 @@ const MyBadge: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/pages/MyGyms/MyGyms.tsx b/front-end/src/pages/MyGyms/MyGyms.tsx index f6e91a79..ba04d339 100644 --- a/front-end/src/pages/MyGyms/MyGyms.tsx +++ b/front-end/src/pages/MyGyms/MyGyms.tsx @@ -29,7 +29,7 @@ const MyGyms: React.FC = () =>{ .then(response =>response.data) .then(response =>{ setLoading(false) - console.log(response) + console.log(response.results) setGyms(response.results) }) .catch(err => { @@ -58,7 +58,7 @@ const MyGyms: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/NotFriendProfile/NotFriendProfile.tsx b/front-end/src/pages/NotFriendProfile/NotFriendProfile.tsx index ebcffe7b..91d32f07 100644 --- a/front-end/src/pages/NotFriendProfile/NotFriendProfile.tsx +++ b/front-end/src/pages/NotFriendProfile/NotFriendProfile.tsx @@ -2,6 +2,8 @@ import { IonContent, IonText, IonPage, IonHeader, IonGrid, IonRow, IonCol, IonCa import React, {useState} from 'react' import { ToolBar } from '../../components/toolbar/Toolbar'; import axios from "axios"; +import { useHistory } from 'react-router-dom'; + const NotFriendProfile: React.FC = () =>{ //localStorage.setItem("friendRequest","true") @@ -11,8 +13,9 @@ const NotFriendProfile: React.FC = () =>{ const [email, setEmail]= useState(sessionStorage.getItem("foundEmail")) const [fullname, setFullname]= useState("") const [profilePicture, setProfilePicture]= useState("") - const [requstPending, setRequestPending] = useState(false) + const [requstPending, setRequestPending] = useState("non") const [loading, setLoading] = useState(false); + let history=useHistory() useIonViewDidEnter(async()=>{ @@ -49,7 +52,51 @@ const NotFriendProfile: React.FC = () =>{ }) }) + const confirmRequest = ()=>{ + setLoading(true) + axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/CreateRequest`,{ + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + data: JSON.stringify({ + toEmail: email, + fromEmail: localStorage.getItem("email") + }) + }) + .then(response =>response.data) + .then(response =>{ + console.log(response) + + let message:string = localStorage.getItem("email") +" has accepted your friend reqeust" + // api call to notify accepted friend request + axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/SendGenericNotification`,{ + "method":"POST", + + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + data:{ + pushTarget: [email], + pushTitle: "Friend Request Accepted", + pushMessage: message, + isSilent: false + } + }) + .then(response =>response.data) + .catch(err => {console.log(err)}) + history.goBack() + setLoading(false) + }) + .catch(err => { + console.log(err) + setLoading(false) + }) + + } const sendFriendRequest = ()=>{ setLoading(true) @@ -69,7 +116,7 @@ const NotFriendProfile: React.FC = () =>{ .then(response =>{ setLoading(false) console.log(response) - setRequestPending(true) + setRequestPending("incoming") }) .catch(err => { setLoading(false) @@ -129,15 +176,20 @@ const NotFriendProfile: React.FC = () =>{



{ - !requstPending + (requstPending==="non") && Send Friend Request } { - requstPending + (requstPending==="incoming") && Request Sent } + { + (requstPending==="outgoing") + && + Accept Friend Request + } @@ -149,7 +201,7 @@ const NotFriendProfile: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/OwnerProfile/OwnerProfile.tsx b/front-end/src/pages/OwnerProfile/OwnerProfile.tsx index 02b8703d..7236b378 100644 --- a/front-end/src/pages/OwnerProfile/OwnerProfile.tsx +++ b/front-end/src/pages/OwnerProfile/OwnerProfile.tsx @@ -4,6 +4,7 @@ import { ToolBar } from '../../components/toolbar/Toolbar'; import "./OwnerProfile.css"; import { useHistory } from 'react-router-dom'; import axios from "axios"; +import { validEmail, onlyLettersAndSpaces, onlyAlphanumericAndUnderscore, validPhone } from '../../utils/validation'; interface InternalValues { file: any; @@ -28,6 +29,50 @@ const OwnerProfilePage: React.FC = () =>{ const [profilePicture, setProfilePicture] = useState(''); const [presentingElement, setPresentingElement] = useState(null); + const [errors, setErrors] = useState({ + username: '', + fullname: '', + email: '', + phone: '', + }); + + const handleError = (error:string, input:string) => { + setErrors(prevState => ({...prevState, [input]: error})); + }; + + const validate = () => { + let isValid = true + + if(email && !validEmail(email)) { + handleError('Please input a valid email', 'email'); + isValid = false; + } + else + handleError('', 'email'); + + if(name && onlyLettersAndSpaces(name)) { + handleError('Please input a valid name', 'fullname'); + isValid = false; + } + else + handleError('', 'fullname'); + + if(username && !onlyAlphanumericAndUnderscore(username)) { + handleError('Please input a valid username', 'username'); + isValid = false; + } + else + handleError('', 'username'); + + if(phone && !validPhone(phone)) { + handleError('Please input a valid phone number', 'phone'); + isValid = false; + } + else + handleError('', 'phone'); + + return isValid; + } useIonViewDidEnter(()=>{ setPresentingElement(page.current); //for modal @@ -154,12 +199,18 @@ const OwnerProfilePage: React.FC = () =>{ } const updateDetails = (e:any) =>{ - //update - updateEmployeeDetails() - //dismiss - dismiss() + let isValid = validate() - setShowSuccess(true); + if(isValid) + { + //update + updateEmployeeDetails() + //dismiss + dismiss() + + setShowSuccess(true); + } + } const updateEmail=(e:any)=>{ @@ -336,21 +387,36 @@ const OwnerProfilePage: React.FC = () =>{ Username - + {errors.username!=="" && ( + <> + {errors.username}

+ + )} +

Full name - + {errors.fullname!=="" && ( + <> + {errors.fullname}

+ + )}

Email - + {errors.email!=="" && ( + <> + {errors.email}

+ + )}

Phone - + {errors.phone!=="" && ( + <> + {errors.phone}

+ + )}

- Password - Change Password
@@ -374,7 +440,6 @@ const OwnerProfilePage: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/pages/PendingApprovalsPage/PendingApprovalsPage.tsx b/front-end/src/pages/PendingApprovalsPage/PendingApprovalsPage.tsx index abc76778..023d55db 100644 --- a/front-end/src/pages/PendingApprovalsPage/PendingApprovalsPage.tsx +++ b/front-end/src/pages/PendingApprovalsPage/PendingApprovalsPage.tsx @@ -92,7 +92,6 @@ const PendingApprovalsPage: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/ResetPassword/ResetPassword.tsx b/front-end/src/pages/ResetPassword/ResetPassword.tsx index c05ad7dc..94c62ba6 100644 --- a/front-end/src/pages/ResetPassword/ResetPassword.tsx +++ b/front-end/src/pages/ResetPassword/ResetPassword.tsx @@ -225,7 +225,7 @@ export const ResetPassword: React.FC = () =>{ /> setLoading(false)} diff --git a/front-end/src/pages/SplashPage/SplashPage.tsx b/front-end/src/pages/SplashPage/SplashPage.tsx index 2f48bac2..8a5b3408 100644 --- a/front-end/src/pages/SplashPage/SplashPage.tsx +++ b/front-end/src/pages/SplashPage/SplashPage.tsx @@ -3,7 +3,7 @@ import './splash-screen.css'; //import auth0Client from '../Auth'; import logo from './logo.png'; import { Geolocation } from '@capacitor/geolocation'; -import { PushNotifications, PushNotificationSchema, DeliveredNotifications } from '@capacitor/push-notifications'; +import { PushNotifications, PushNotificationSchema, DeliveredNotifications, ActionPerformed } from '@capacitor/push-notifications'; @@ -27,6 +27,22 @@ export const SplashPage: React.FC = () => } ); + + PushNotifications.addListener('pushNotificationActionPerformed', + (actionPerformed: ActionPerformed) => { + let n = { id: actionPerformed.notification.id, title: actionPerformed.notification.data.title, body: actionPerformed.notification.data.body, type: 'foreground' } + + let notificationStorage = localStorage.getItem("notificationStorage") + if(notificationStorage === null){ + localStorage.setItem("notificationStorage",JSON.stringify([n])) + } + else{ + let notifications = JSON.parse(notificationStorage) + notifications = [...notifications,n] + localStorage.setItem("notificationStorage",JSON.stringify(notifications)) + } + } +); PushNotifications.getDeliveredNotifications().then((Delivered:DeliveredNotifications)=>{ let notificationStorage = localStorage.getItem("notificationStorage") diff --git a/front-end/src/pages/UploadActivityPage/UploadActivityPage.tsx b/front-end/src/pages/UploadActivityPage/UploadActivityPage.tsx index 789441bd..fc05b646 100644 --- a/front-end/src/pages/UploadActivityPage/UploadActivityPage.tsx +++ b/front-end/src/pages/UploadActivityPage/UploadActivityPage.tsx @@ -24,7 +24,6 @@ const inputRefTakeVideo = useRef(null); const inputRefUploadVideo = useRef(null); //HOOKS AND VARAIBES const [award,setAward]=useState(false) -const [path,setPath]=useState("") const [isValid, setIsValid] = useState(false); const [submitted, setSubmitted] = useState(false); const [reps_required,setRepsRequired] =useState(0) @@ -180,7 +179,6 @@ const writeToFile=async()=>{ directory:Directory.Data }); console.log(result) - setPath(result) } const handleSubmit_AI = async () =>{ @@ -193,8 +191,6 @@ const handleSubmit_AI = async () =>{ setMessage("Calculating") setLoading(true) console.log("extracting frames") - console.log("********************************************************************************************************"); - console.log("********************************************************************************************************"); const url = URL.createObjectURL(values.current.file); console.log(url) await VideoToFrames.getFrames(url, VideoToFramesMethod.totalFrames).then(async function (frame:ImageData[]) { diff --git a/front-end/src/pages/UserMap/UserMap.css b/front-end/src/pages/UserMap/UserMap.css index 21b25964..422f96b3 100644 --- a/front-end/src/pages/UserMap/UserMap.css +++ b/front-end/src/pages/UserMap/UserMap.css @@ -1,4 +1,4 @@ -#main { +.main { --overflow: hidden !important; } diff --git a/front-end/src/pages/UserMap/UserMap.tsx b/front-end/src/pages/UserMap/UserMap.tsx index 4d0f556f..98dff140 100644 --- a/front-end/src/pages/UserMap/UserMap.tsx +++ b/front-end/src/pages/UserMap/UserMap.tsx @@ -20,8 +20,8 @@ const UserMap: React.FC = () => { - - + + diff --git a/front-end/src/pages/UserPendingBadges/PendingBadges.tsx b/front-end/src/pages/UserPendingBadges/PendingBadges.tsx index 33fe0f2c..94f21a89 100644 --- a/front-end/src/pages/UserPendingBadges/PendingBadges.tsx +++ b/front-end/src/pages/UserPendingBadges/PendingBadges.tsx @@ -60,7 +60,6 @@ const PendingBadgesPage: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/pages/UserProfile/UserProfile.tsx b/front-end/src/pages/UserProfile/UserProfile.tsx index f16c53d8..7b602671 100644 --- a/front-end/src/pages/UserProfile/UserProfile.tsx +++ b/front-end/src/pages/UserProfile/UserProfile.tsx @@ -25,6 +25,8 @@ const UserProfilePage: React.FC = () =>{ const [showFail, setShowFail] = useState(false); const [numClaims, setNumClaims] = useState(""); const [numBadges, setNumBadges] = useState(""); + const [numFriends, setNumFriends] = useState(""); + const [profilePicture, setProfilePicture] = useState(localStorage.getItem("profile_picture")); const [presentingElement, setPresentingElement] = useState(null); @@ -111,6 +113,31 @@ const UserProfilePage: React.FC = () =>{ }) } + const getNumberofFriends = ()=>{ + axios(process.env["REACT_APP_GYM_KING_API"]+`/users/user/getFriends`,{ + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + data: JSON.stringify({ + userEmail: localStorage.getItem("email"), + + }) + }) + .then(response =>response.data) + .then(response =>{ + setLoading(false) + console.log(response) + setNumFriends(response.length) + }) + .catch(err => { + setLoading(false) + console.log(err) + + }) + } + useIonViewDidEnter(()=>{ setPresentingElement(page.current); //for modal setLoading(true); @@ -143,6 +170,7 @@ const UserProfilePage: React.FC = () =>{ getNumberOfBadges() getNumberOfClaims() + getNumberofFriends() // eslint-disable-next-line react-hooks/exhaustive-deps },[profilePicture]) @@ -334,7 +362,7 @@ const UserProfilePage: React.FC = () =>{ My Friends - 3 + {numFriends} @@ -438,7 +466,6 @@ const UserProfilePage: React.FC = () =>{ setLoading(false)} diff --git a/front-end/src/pages/ViewBadgePage/ViewBadgePage.tsx b/front-end/src/pages/ViewBadgePage/ViewBadgePage.tsx index 9989bfa0..6f5d37e4 100644 --- a/front-end/src/pages/ViewBadgePage/ViewBadgePage.tsx +++ b/front-end/src/pages/ViewBadgePage/ViewBadgePage.tsx @@ -62,7 +62,6 @@ const ViewBadgePage: React.FC = () =>{ setLoading(false)} cssClass={"spinner"} diff --git a/front-end/src/theme/variables.css b/front-end/src/theme/variables.css index e2200cc9..98715849 100644 --- a/front-end/src/theme/variables.css +++ b/front-end/src/theme/variables.css @@ -296,12 +296,15 @@ ion-card{ } -.spinner{ - --background: #873CFF; +ion-loading.spinner{ + --background: transparent; --spinner-color: #ffc409; --height: 4em; + --width: 2em; } + + .userImage{ height: 7em; width: 7em; diff --git a/front-end/trapeze.yml b/front-end/trapeze.yml index 89943196..91813d9d 100644 --- a/front-end/trapeze.yml +++ b/front-end/trapeze.yml @@ -20,6 +20,13 @@ platforms: android:usesCleartextTraffic: "true" + + - file: AndroidManifest.xml + target: manifest + inject: | + + + gradle: - file: app/build.gradle target: diff --git a/package.json b/package.json index 3770fffd..1c0e49ef 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,16 @@ }, "dependencies": { "@agney/ir-toast": "^0.2.0", + "@angular/core": "^14.2.3", + "@awesome-cordova-plugins/app-availability": "^5.45.0", + "@awesome-cordova-plugins/core": "^5.45.0", "@babel/core": "^7.0.0-0", "@babel/plugin-syntax-flow": "^7.14.5", "@babel/plugin-transform-react-jsx": "^7.14.9", "@babel/preset-env": "^7.0.0", "@capacitor/android": "^4.3.0", "@capacitor/core": "^4.3.0", + "@capacitor/app-launcher": "^4.0.1", "@capacitor/device": "^4.0.1", "@capacitor/filesystem": "^4.1.1", "@capacitor/toast": "^4.0.1", @@ -104,7 +108,6 @@ "react-scripts": "^5.0.1", "react-toastify": "^9.0.1", "reflect-metadata": "^0.1.13", - "rxjs": "^6.5.0", "string-similarity-js": "^2.1.4", "swiper": "^8.2.6", "ts-config": "^20.10.0",