Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | import { Favorite, Language, Star } from "@mui/icons-material"; import { Box, Skeleton, Typography, useMediaQuery } from "@mui/material"; import Divider from "components/Divider"; import { useTranslation } from "i18n"; import { GLOBAL, LANDING } from "i18n/namespaces"; import { useEffect, useState } from "react"; import { theme } from "theme"; import { timeAgoI18n } from "utils/timeAgo"; export interface SignupInfo { userCount: string; lastSignup: string | Date; lastLocation: string; } const SocialProof = () => { const { t } = useTranslation([GLOBAL, LANDING]); const isMobile = useMediaQuery(theme.breakpoints.down("md")); const [signupInfo, setSignupInfo] = useState<SignupInfo | null>(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { const fetchSignupInfo = async () => { try { const response = await fetch( "https://couchers.org/api/public/signup-page-info", ); Iif (!response.ok) { throw new Error("Failed to fetch signup info"); } const data = await response.json(); setSignupInfo(data); } catch (error) { console.error("Error fetching signup info:", error); } finally { setIsLoading(false); } }; fetchSignupInfo(); }, []); return ( <Box sx={{ padding: theme.spacing(8, 4), textAlign: "center", }} maxWidth="lg" > <Typography sx={{ fontSize: "3rem", fontWeight: "bold", [theme.breakpoints.down("md")]: { fontSize: "1.8rem", }, }} > {t("landing:what_couchsurfing_title")} </Typography> <Typography paragraph sx={{ marginTop: 2, fontSize: "1.2rem", padding: isMobile ? undefined : theme.spacing(0, 20), }} > {t("landing:what_couchsurfing_description")} </Typography> <Divider sx={{ backgroundColor: theme.palette.common.black, marginTop: 4 }} /> <Box display="flex" flexDirection={isMobile ? "column" : "row"} alignItems="center" justifyContent="center" sx={{ marginTop: 4, width: "100%" }} gap={2} > <Box display="flex" alignItems="center"> <Favorite sx={{ marginRight: 1, fontSize: "30px", color: theme.palette.primary.main, }} /> {isLoading ? ( <Box sx={{ width: 120 }}> <Typography sx={{ fontSize: "1.5rem", fontWeight: 500 }}> <Box component="span" sx={{ display: "inline-block", width: "100%" }} > <Skeleton variant="text" width="100%" height={36} /> </Box> </Typography> </Box> ) : ( <Typography sx={{ fontSize: "1.5rem", fontWeight: 500 }}> {t("landing:num_users", { numUsers: signupInfo?.userCount || "56k+", })} </Typography> )} </Box> <Box display="flex" alignItems="center"> <Language sx={{ marginRight: 1, fontSize: "30px", color: theme.palette.primary.main, }} /> <Typography sx={{ fontSize: "1.5rem", fontWeight: 500 }}> {t("landing:num_countries", { numCountries: 180 })} </Typography> </Box> <Box display="flex" alignItems={isMobile ? "flex-start" : "center"}> <Star sx={{ marginRight: 1, fontSize: "30px", color: theme.palette.primary.main, }} /> {isLoading ? ( <Box sx={{ width: 220 }}> <Typography sx={{ fontSize: "1.5rem", fontWeight: 500 }}> <Box component="span" sx={{ display: "inline-block", width: "100%" }} > <Skeleton variant="text" width="100%" height={36} /> </Box> </Typography> </Box> ) : ( signupInfo && signupInfo.lastSignup && ( <Typography sx={{ fontSize: "1.5rem", fontWeight: 500, }} > {t("landing:last_signup", { timeAgo: timeAgoI18n({ input: signupInfo.lastSignup, t: t, }), })} </Typography> ) )} </Box> </Box> </Box> ); }; export default SocialProof; |