Skip to content

Commit 25f3c87

Browse files
committed
[APP-1405]: Adding metadata to profile
1 parent ac71ea2 commit 25f3c87

File tree

1 file changed

+111
-1
lines changed

1 file changed

+111
-1
lines changed

src/screens/Profile/Header/EditProfileDialog.tsx

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {Text} from '#/components/Typography'
2626
import {useSimpleVerificationState} from '#/components/verification'
2727

2828
const DISPLAY_NAME_MAX_GRAPHEMES = 64
29+
const PRONOUNS_MAX_GRAPHEMES = 50
30+
const WEBSITE_MAX_GRAPHEMES = 300
2931
const DESCRIPTION_MAX_GRAPHEMES = 256
3032

3133
const SCREEN_HEIGHT = Dimensions.get('window').height
@@ -115,6 +117,12 @@ function DialogInner({
115117
const [displayName, setDisplayName] = useState(initialDisplayName)
116118
const initialDescription = profile.description || ''
117119
const [description, setDescription] = useState(initialDescription)
120+
const initialPronouns = ''
121+
const [pronouns, setPronouns] = useState(initialPronouns)
122+
const initialWebsite = ''
123+
const [website, setWebsite] = useState(initialWebsite)
124+
const initialLocation = ''
125+
const [location, setLocation] = useState(initialLocation)
118126
const [userBanner, setUserBanner] = useState<string | undefined | null>(
119127
profile.banner,
120128
)
@@ -131,6 +139,9 @@ function DialogInner({
131139
const dirty =
132140
displayName !== initialDisplayName ||
133141
description !== initialDescription ||
142+
pronouns !== initialPronouns ||
143+
website !== initialWebsite ||
144+
location !== initialLocation ||
134145
userAvatar !== profile.avatar ||
135146
userBanner !== profile.banner
136147

@@ -209,6 +220,15 @@ function DialogInner({
209220
text: displayName,
210221
maxCount: DISPLAY_NAME_MAX_GRAPHEMES,
211222
})
223+
const pronounsTooLong = useWarnMaxGraphemeCount({
224+
text: pronouns,
225+
maxCount: PRONOUNS_MAX_GRAPHEMES,
226+
})
227+
const websiteTooLong = useWarnMaxGraphemeCount({
228+
text: website,
229+
maxCount: WEBSITE_MAX_GRAPHEMES,
230+
})
231+
const websiteInvalidFormat = !!(website && !website.match(/^https?:\/\/.+/))
212232
const descriptionTooLong = useWarnMaxGraphemeCount({
213233
text: description,
214234
maxCount: DESCRIPTION_MAX_GRAPHEMES,
@@ -241,7 +261,10 @@ function DialogInner({
241261
!dirty ||
242262
isUpdatingProfile ||
243263
displayNameTooLong ||
244-
descriptionTooLong
264+
descriptionTooLong ||
265+
pronounsTooLong ||
266+
websiteTooLong ||
267+
websiteInvalidFormat
245268
}
246269
size="small"
247270
color="primary"
@@ -262,6 +285,9 @@ function DialogInner({
262285
isUpdatingProfile,
263286
displayNameTooLong,
264287
descriptionTooLong,
288+
pronounsTooLong,
289+
websiteTooLong,
290+
websiteInvalidFormat,
265291
],
266292
)
267293

@@ -389,6 +415,90 @@ function DialogInner({
389415
</Text>
390416
)}
391417
</View>
418+
419+
<View>
420+
<TextField.LabelText>
421+
<Trans>Pronouns</Trans>
422+
</TextField.LabelText>
423+
<TextField.Root isInvalid={pronounsTooLong}>
424+
<Dialog.Input
425+
defaultValue={pronouns}
426+
onChangeText={setPronouns}
427+
label={_(msg`Pronouns`)}
428+
placeholder={_(msg`Pronouns`)}
429+
testID="editProfilePronounsInput"
430+
/>
431+
</TextField.Root>
432+
{pronounsTooLong && (
433+
<Text
434+
style={[
435+
a.text_sm,
436+
a.mt_xs,
437+
a.font_bold,
438+
{color: t.palette.negative_400},
439+
]}>
440+
<Plural
441+
value={PRONOUNS_MAX_GRAPHEMES}
442+
other="The maximum number of characters is #."
443+
/>
444+
</Text>
445+
)}
446+
</View>
447+
448+
<View>
449+
<TextField.LabelText>
450+
<Trans>Website</Trans>
451+
</TextField.LabelText>
452+
<TextField.Root isInvalid={websiteTooLong || websiteInvalidFormat}>
453+
<Dialog.Input
454+
defaultValue={website}
455+
onChangeText={setWebsite}
456+
label={_(msg`Website`)}
457+
placeholder={_(msg`URL`)}
458+
testID="editProfileWebsiteInput"
459+
/>
460+
</TextField.Root>
461+
{websiteTooLong && (
462+
<Text
463+
style={[
464+
a.text_sm,
465+
a.mt_xs,
466+
a.font_bold,
467+
{color: t.palette.negative_400},
468+
]}>
469+
<Plural
470+
value={WEBSITE_MAX_GRAPHEMES}
471+
other="Website is too long. The maximum number of characters is #."
472+
/>
473+
</Text>
474+
)}
475+
{websiteInvalidFormat && (
476+
<Text
477+
style={[
478+
a.text_sm,
479+
a.mt_xs,
480+
a.font_bold,
481+
{color: t.palette.negative_400},
482+
]}>
483+
<Trans>Website must start with http:// or https://</Trans>
484+
</Text>
485+
)}
486+
</View>
487+
488+
<View>
489+
<TextField.LabelText>
490+
<Trans>Location</Trans>
491+
</TextField.LabelText>
492+
<TextField.Root>
493+
<Dialog.Input
494+
defaultValue={location}
495+
onChangeText={setLocation}
496+
label={_(msg`Location`)}
497+
placeholder={_(msg`Location`)}
498+
testID="editProfileLocationInput"
499+
/>
500+
</TextField.Root>
501+
</View>
392502
</View>
393503
</Dialog.ScrollableInner>
394504
)

0 commit comments

Comments
 (0)