diff --git a/src/features/Onboarding/OnboardingPage.tsx b/src/features/Onboarding/OnboardingPage.tsx index a3c1fdd..75ff966 100644 --- a/src/features/Onboarding/OnboardingPage.tsx +++ b/src/features/Onboarding/OnboardingPage.tsx @@ -21,6 +21,8 @@ import { languageOptions, proficiencyOptions, } from '@/constants'; +import { availabilityPresetToPattern } from '@/constants/availability'; +import { type DiscoveryProfile, ProfileCard } from '@/features/Discovery'; import { Navbar } from '@/features/Navbar'; import { useRouteProgressRouter } from '@/features/Navigation/RouteProgress'; import { @@ -119,32 +121,46 @@ export const OnboardingPage = ({ const completion = useMemo(() => getOnboardingCompletion(values), [values]); - const preview = useMemo(() => { - const getLabel = ( - options: { label: string; value: string }[], - value?: string, - ) => options.find((option) => option.value === value)?.label ?? ''; + const previewProfile = useMemo(() => { + const countryLabel = + localizedCountryOptions.find((option) => option.value === values.country) + ?.label ?? ''; return { - primaryLanguage: getLabel( - localizedLanguageOptions, - values.primaryLanguage, - ), - targetLanguage: getLabel(localizedLanguageOptions, values.targetLanguage), - proficiencyLevel: getLabel( - localizedProficiencyOptions, - values.proficiencyLevel, - ), - country: getLabel(localizedCountryOptions, values.country), + id: 'onboarding-preview', + displayName: userDisplayName, + discordUsername: userDisplayName, + avatarUrl: userAvatarUrl, + primaryLanguage: values.primaryLanguage || t('previewPrimaryFallback'), + targetLanguages: values.targetLanguage + ? [ + { + language: values.targetLanguage, + level: values.proficiencyLevel || undefined, + }, + ] + : [], + about: values.bio, + interests: tags, + country: countryLabel, + timezone: values.timezone, + availability: values.availability + ? availabilityPresetToPattern(values.availability) + : undefined, }; }, [ localizedCountryOptions, - localizedLanguageOptions, - localizedProficiencyOptions, + t, + tags, + userAvatarUrl, + userDisplayName, + values.availability, + values.bio, values.country, values.primaryLanguage, values.proficiencyLevel, values.targetLanguage, + values.timezone, ]); const addTag = () => { @@ -499,61 +515,12 @@ export const OnboardingPage = ({

{t('previewTitle')}

-
-
- -
-

- {userDisplayName} -

-

{t('previewPublic')}

-
-
- -
- {preview.primaryLanguage ? ( - - {preview.primaryLanguage} - - ) : null} - {preview.targetLanguage ? ( - - {preview.targetLanguage} - {preview.proficiencyLevel - ? ` / ${preview.proficiencyLevel}` - : ''} - - ) : null} -
- -

- {values.bio || t('previewBioFallback')} -

- -

- {values.availability - ? t(availabilityLabelKeys[values.availability]) - : t('previewAvailabilityFallback')} - {values.timezone ? ` / ${values.timezone}` : ''} -

- - {tags.length > 0 ? ( -
- {tags.slice(0, 6).map((tag) => ( - - {tag} - - ))} -
- ) : null} - - {preview.country ? ( -

{preview.country}

- ) : null} -
+ diff --git a/src/locales/en.json b/src/locales/en.json index 23ad9de..6878630 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -449,9 +449,9 @@ "publishButton": "Publish profile", "publishing": "Publishing...", "previewTitle": "Public card preview", - "previewPublic": "Public", "previewBioFallback": "Your bio will appear here.", - "previewAvailabilityFallback": "Availability" + "previewPrimaryFallback": "Primary", + "previewNoTags": "No tags yet" }, "DiscoveryStories": { "gridTitle": "Find your next language partner", diff --git a/src/locales/ja.json b/src/locales/ja.json index a62c3fc..898c3ca 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -449,9 +449,9 @@ "publishButton": "プロフィールを公開", "publishing": "公開中...", "previewTitle": "公開カードプレビュー", - "previewPublic": "公開", "previewBioFallback": "自己紹介がここに表示されます。", - "previewAvailabilityFallback": "利用可能な時間" + "previewPrimaryFallback": "主要言語", + "previewNoTags": "タグはまだありません" }, "DiscoveryStories": { "gridTitle": "次の言語パートナーを見つけよう",