Skip to content

Commit

Permalink
fix: profile update and onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Aug 6, 2024
1 parent 6332bdb commit 0884b89
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 62 deletions.
57 changes: 34 additions & 23 deletions app/(app)/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/native';
import {Stack} from 'expo-router';
import {Icon, Typography} from 'dooboo-ui';
import {Icon, Typography, useDooboo} from 'dooboo-ui';
import {t} from '../../../src/STRINGS';
import {useRecoilValue} from 'recoil';
import {authRecoilState} from '../../../src/recoil/atoms';
Expand Down Expand Up @@ -95,6 +95,7 @@ const TagText = styled.Text`

export default function Profile(): JSX.Element {
const {user, tags} = useRecoilValue(authRecoilState);
const {theme} = useDooboo();

return (
<Container>
Expand All @@ -109,7 +110,7 @@ export default function Profile(): JSX.Element {
source={user?.avatar_url ? {uri: user?.avatar_url} : IC_ICON}
/>
<UserName>{user?.display_name || ''}</UserName>
<UserBio>{user?.introduction || ''}</UserBio>
{user?.introduction ? <UserBio>{user?.introduction}</UserBio> : null}
</ProfileHeader>
<Content>
<InfoCard>
Expand All @@ -122,7 +123,7 @@ export default function Profile(): JSX.Element {
gap: 4px;
`}
>
<Icon name="GithubLogo" size={16} color="#333" />
<Icon name="GithubLogo" size={16} color={theme.role.secondary} />
<InfoValue>{user?.github_id || ''}</InfoValue>
</View>
</InfoItem>
Expand All @@ -131,26 +132,36 @@ export default function Profile(): JSX.Element {
<InfoValue>{user?.affiliation || ''}</InfoValue>
</InfoItem>
</InfoCard>
<InfoCard>
<InfoItem>
<InfoLabel>{t('onboarding.desiredConnection')}</InfoLabel>
<InfoValue>{user?.desired_connection || ''}</InfoValue>
</InfoItem>
<InfoItem>
<InfoLabel>{t('onboarding.futureExpectations')}</InfoLabel>
<InfoValue>{user?.future_expectations || ''}</InfoValue>
</InfoItem>
</InfoCard>
<InfoCard>
<InfoLabel>{t('onboarding.userTags')}:</InfoLabel>
<TagContainer>
{tags?.map((tag, index) => (
<Tag key={index}>
<TagText>{tag}</TagText>
</Tag>
))}
</TagContainer>
</InfoCard>

{user?.desired_connection || user?.future_expectations ? (
<InfoCard>
{user?.desired_connection ? (
<InfoItem>
<InfoLabel>{t('onboarding.desiredConnection')}</InfoLabel>
<InfoValue>{user?.desired_connection || ''}</InfoValue>
</InfoItem>
) : null}
{user?.future_expectations ? (
<InfoItem>
<InfoLabel>{t('onboarding.futureExpectations')}</InfoLabel>
<InfoValue>{user?.future_expectations || ''}</InfoValue>
</InfoItem>
) : null}
</InfoCard>
) : null}

{tags?.length ? (
<InfoCard>
<InfoLabel>{t('onboarding.userTags')}</InfoLabel>
<TagContainer>
{tags.map((tag, index) => (
<Tag key={index}>
<TagText>{tag}</TagText>
</Tag>
))}
</TagContainer>
</InfoCard>
) : null}
</Content>
</CustomScrollView>
</Container>
Expand Down
38 changes: 20 additions & 18 deletions app/(app)/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {useRecoilState} from 'recoil';
import {authRecoilState} from '../../src/recoil/atoms';
import {ImageInsertArgs} from '../../src/types';
import FallbackComponent from '../../src/components/uis/FallbackComponent';
import { showAlert } from '../../src/utils/alert';
import {showAlert} from '../../src/utils/alert';

const Container = styled.SafeAreaView`
flex: 1;
Expand All @@ -55,11 +55,11 @@ const Content = styled.View`
`;

const schema = yup.object().shape({
display_name: yup.string().required(t('common.requiredField')),
display_name: yup.string().required(t('common.requiredField')).min(2).max(20),
github_id: yup.string().required(t('common.requiredField')),
affiliation: yup.string().required(t('common.requiredField')),
avatar_url: yup.string(),
meetup_id: yup.string(),
affiliation: yup.string(),
github_id: yup.string(),
other_sns_urls: yup.array().of(yup.string()),
tags: yup.array().of(yup.string()),
desired_connection: yup.string(),
Expand Down Expand Up @@ -115,7 +115,7 @@ export default function Onboarding(): JSX.Element {

let image: ImageInsertArgs | undefined = {};

if (profileImg) {
if (profileImg && !profileImg.startsWith('http')) {
const destPath = `users/${authId}`;

image = await uploadFileToSupabase({
Expand Down Expand Up @@ -295,7 +295,7 @@ export default function Onboarding(): JSX.Element {
displayNameError
? displayNameError
: errors.display_name
? errors.display_name.message
? t('error.displayNameInvalid')
: ''
}
/>
Expand All @@ -304,9 +304,10 @@ export default function Onboarding(): JSX.Element {
/>
<Controller
control={control}
name="meetup_id"
name="github_id"
render={({field: {onChange, value}}) => (
<EditText
required
styles={{
label: css`
font-size: 14px;
Expand All @@ -316,21 +317,22 @@ export default function Onboarding(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.meetupId')}
label={t('onboarding.githubId')}
onChangeText={onChange}
placeholder={t('onboarding.meetupIdPlaceholder')}
placeholder={t('onboarding.githubIdPlaceholder')}
value={value}
decoration="boxed"
error={errors.meetup_id ? errors.meetup_id.message : ''}
error={errors.github_id ? errors.github_id.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
/>
<Controller
control={control}
name="github_id"
name="affiliation"
render={({field: {onChange, value}}) => (
<EditText
required
styles={{
label: css`
font-size: 14px;
Expand All @@ -340,19 +342,19 @@ export default function Onboarding(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.githubId')}
label={t('onboarding.affiliation')}
onChangeText={onChange}
placeholder={t('onboarding.githubIdPlaceholder')}
placeholder={t('onboarding.affiliationPlaceholder')}
value={value}
decoration="boxed"
error={errors.github_id ? errors.github_id.message : ''}
error={errors.affiliation ? errors.affiliation.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
/>
<Controller
control={control}
name="affiliation"
name="meetup_id"
render={({field: {onChange, value}}) => (
<EditText
styles={{
Expand All @@ -364,12 +366,12 @@ export default function Onboarding(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.affiliation')}
label={t('onboarding.meetupId')}
onChangeText={onChange}
placeholder={t('onboarding.affiliationPlaceholder')}
placeholder={t('onboarding.meetupIdPlaceholder')}
value={value}
decoration="boxed"
error={errors.affiliation ? errors.affiliation.message : ''}
error={errors.meetup_id ? errors.meetup_id.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
Expand Down
38 changes: 20 additions & 18 deletions app/(app)/settings/profile-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '../../../src/apis/profileQueries';
import FallbackComponent from '../../../src/components/uis/FallbackComponent';
import CustomLoadingIndicator from '../../../src/components/uis/CustomLoadingIndicator';
import { showAlert } from '../../../src/utils/alert';
import {showAlert} from '../../../src/utils/alert';

const Container = styled.SafeAreaView`
flex: 1;
Expand All @@ -49,11 +49,11 @@ const Content = styled.View`
`;

const schema = yup.object().shape({
display_name: yup.string().required(t('common.requiredField')),
avatar_url: yup.string(),
display_name: yup.string().required(t('common.requiredField')).min(2).max(20),
github_id: yup.string().required(t('common.requiredField')),
affiliation: yup.string().required(t('common.requiredField')),
meetup_id: yup.string(),
affiliation: yup.string(),
github_id: yup.string(),
avatar_url: yup.string(),
other_sns_urls: yup.array().of(yup.string()),
tags: yup.array().of(yup.string()),
desired_connection: yup.string(),
Expand Down Expand Up @@ -245,7 +245,7 @@ export default function ProfileUpdate(): JSX.Element {
displayNameError
? displayNameError
: errors.display_name
? errors.display_name.message
? t('error.displayNameInvalid')
: ''
}
/>
Expand All @@ -254,9 +254,10 @@ export default function ProfileUpdate(): JSX.Element {
/>
<Controller
control={control}
name="meetup_id"
name="github_id"
render={({field: {onChange, value}}) => (
<EditText
required
styles={{
label: css`
font-size: 14px;
Expand All @@ -266,21 +267,22 @@ export default function ProfileUpdate(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.meetupId')}
label={t('onboarding.githubId')}
onChangeText={onChange}
placeholder={t('onboarding.meetupIdPlaceholder')}
placeholder={t('onboarding.githubIdPlaceholder')}
value={value}
decoration="boxed"
error={errors.meetup_id ? errors.meetup_id.message : ''}
error={errors.github_id ? errors.github_id.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
/>
<Controller
control={control}
name="github_id"
name="affiliation"
render={({field: {onChange, value}}) => (
<EditText
required
styles={{
label: css`
font-size: 14px;
Expand All @@ -290,19 +292,19 @@ export default function ProfileUpdate(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.githubId')}
label={t('onboarding.affiliation')}
onChangeText={onChange}
placeholder={t('onboarding.githubIdPlaceholder')}
placeholder={t('onboarding.affiliationPlaceholder')}
value={value}
decoration="boxed"
error={errors.github_id ? errors.github_id.message : ''}
error={errors.affiliation ? errors.affiliation.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
/>
<Controller
control={control}
name="affiliation"
name="meetup_id"
render={({field: {onChange, value}}) => (
<EditText
styles={{
Expand All @@ -314,12 +316,12 @@ export default function ProfileUpdate(): JSX.Element {
`,
}}
colors={{focused: theme.role.primary}}
label={t('onboarding.affiliation')}
label={t('onboarding.meetupId')}
onChangeText={onChange}
placeholder={t('onboarding.affiliationPlaceholder')}
placeholder={t('onboarding.meetupIdPlaceholder')}
value={value}
decoration="boxed"
error={errors.affiliation ? errors.affiliation.message : ''}
error={errors.meetup_id ? errors.meetup_id.message : ''}
/>
)}
rules={{validate: (value) => !!value}}
Expand Down
6 changes: 3 additions & 3 deletions assets/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
},
"error": {
"default": "Error occurred!",
"displayNameExists": "The nickname already exists",
"displayNameInvalid": "Nickname must be between 2 and 20 characters",
"displayNameIsEmpty": "Please enter a nickname",
"displayNameExists": "The display name already exists",
"displayNameInvalid": "Display name must be between 2 and 20 characters",
"displayNameIsEmpty": "Please enter a display name",
"unableToOpenEmailClient": "Unable to open email client",
"projectIdNotFound": "Project ID not found",
"mustUsePhysicalDeviceForSubject": "Must use physical device for {{subject}}"
Expand Down
Binary file modified bun.lockb
Binary file not shown.

0 comments on commit 0884b89

Please sign in to comment.