feat(dashboard): minor fixes to profile (#7046)

This commit is contained in:
Kasper Fabricius Kristensen authored and GitHub committed 2024-04-11 09:52:28 +02:00
1 parent eac4d2d87a
commit 27387b7cf1
4 files changed
+28 -20

No files matched your search

@@ -802,11 +802,16 @@
"profile": { "profile": {
"domain": "Profile", "domain": "Profile",
"manageYourProfileDetails": "Manage your profile details", "manageYourProfileDetails": "Manage your profile details",
"editProfile": "Edit profile", "fields": {
"languageLabel": "Language",
"usageInsightsLabel": "Usage insights"
},
"edit": {
"header": "Edit Profile",
"languageHint": "The language you want to use in the admin dashboard. This will not change the language of your store.", "languageHint": "The language you want to use in the admin dashboard. This will not change the language of your store.",
"userInsightsHint": "Share usage insights and help us improve Medusa. You can read more about what we collect and how we use it in our <0>documentation</0>.", "languagePlaceholder": "Select language",
"language": "Language", "usageInsightsHint": "Share usage insights and help us improve Medusa. You can read more about what we collect and how we use it in our <0>documentation</0>."
"usageInsights": "Usage insights" }
}, },
"users": { "users": {
"domain": "Users", "domain": "Users",
@@ -10,6 +10,9 @@ type ProfileGeneralSectionProps = {
export const ProfileGeneralSection = ({ user }: ProfileGeneralSectionProps) => { export const ProfileGeneralSection = ({ user }: ProfileGeneralSectionProps) => {
const { i18n, t } = useTranslation() const { i18n, t } = useTranslation()
const name = [user.first_name, user.last_name].filter(Boolean).join(" ")
return ( return (
<Container className="divide-y p-0"> <Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4"> <div className="flex items-center justify-between px-6 py-4">
@@ -30,7 +33,7 @@ export const ProfileGeneralSection = ({ user }: ProfileGeneralSectionProps) => {
{t("fields.name")} {t("fields.name")}
</Text> </Text>
<Text size="small" leading="compact"> <Text size="small" leading="compact">
{user.first_name} {user.last_name} {name || "-"}
</Text> </Text>
</div> </div>
<div className="grid grid-cols-2 items-center px-6 py-4"> <div className="grid grid-cols-2 items-center px-6 py-4">
@@ -43,7 +46,7 @@ export const ProfileGeneralSection = ({ user }: ProfileGeneralSectionProps) => {
</div> </div>
<div className="grid grid-cols-2 items-center px-6 py-4"> <div className="grid grid-cols-2 items-center px-6 py-4">
<Text size="small" leading="compact" weight="plus"> <Text size="small" leading="compact" weight="plus">
{t("profile.language")} {t("profile.fields.languageLabel")}
</Text> </Text>
<Text size="small" leading="compact"> <Text size="small" leading="compact">
{languages.find((lang) => lang.code === i18n.language) {languages.find((lang) => lang.code === i18n.language)
@@ -52,7 +55,7 @@ export const ProfileGeneralSection = ({ user }: ProfileGeneralSectionProps) => {
</div> </div>
<div className="grid grid-cols-2 items-center px-6 py-4"> <div className="grid grid-cols-2 items-center px-6 py-4">
<Text size="small" leading="compact" weight="plus"> <Text size="small" leading="compact" weight="plus">
{t("profile.usageInsights")} {t("profile.fields.usageInsightsLabel")}
</Text> </Text>
<StatusBadge color="red" className="w-fit"> <StatusBadge color="red" className="w-fit">
{t("general.disabled")} {t("general.disabled")}
@@ -80,7 +80,7 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
<Form.Item> <Form.Item>
<Form.Label>{t("fields.firstName")}</Form.Label> <Form.Label>{t("fields.firstName")}</Form.Label>
<Form.Control> <Form.Control>
<Input {...field} size="small" /> <Input {...field} />
</Form.Control> </Form.Control>
<Form.ErrorMessage /> <Form.ErrorMessage />
</Form.Item> </Form.Item>
@@ -93,7 +93,7 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
<Form.Item> <Form.Item>
<Form.Label>{t("fields.lastName")}</Form.Label> <Form.Label>{t("fields.lastName")}</Form.Label>
<Form.Control> <Form.Control>
<Input {...field} size="small" /> <Input {...field} />
</Form.Control> </Form.Control>
<Form.ErrorMessage /> <Form.ErrorMessage />
</Form.Item> </Form.Item>
@@ -106,18 +106,16 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
render={({ field: { ref, ...field } }) => ( render={({ field: { ref, ...field } }) => (
<Form.Item className="gap-y-4"> <Form.Item className="gap-y-4">
<div> <div>
<Form.Label>{t("profile.language")}</Form.Label> <Form.Label>{t("profile.fields.languageLabel")}</Form.Label>
<Form.Hint>{t("profile.languageHint")}</Form.Hint> <Form.Hint>{t("profile.edit.languageHint")}</Form.Hint>
</div> </div>
<div> <div>
<Form.Control> <Form.Control>
<Select <Select {...field} onValueChange={field.onChange}>
{...field}
onValueChange={field.onChange}
size="small"
>
<Select.Trigger ref={ref} className="py-1 text-[13px]"> <Select.Trigger ref={ref} className="py-1 text-[13px]">
<Select.Value placeholder="Choose language"> <Select.Value
placeholder={t("profile.edit.languagePlaceholder")}
>
{ {
sortedLanguages.find( sortedLanguages.find(
(language) => language.code === field.value (language) => language.code === field.value
@@ -148,7 +146,9 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
render={({ field: { value, onChange, ...rest } }) => ( render={({ field: { value, onChange, ...rest } }) => (
<Form.Item> <Form.Item>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<Form.Label>{t("profile.usageInsights")}</Form.Label> <Form.Label>
{t("profile.fields.usageInsightsLabel")}
</Form.Label>
<Form.Control> <Form.Control>
<Switch <Switch
{...rest} {...rest}
@@ -160,7 +160,7 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
<Form.Hint> <Form.Hint>
<span> <span>
<Trans <Trans
i18nKey="profile.userInsightsHint" i18nKey="profile.edit.usageInsightsHint"
components={[ components={[
<a <a
key="hint-link" key="hint-link"
@@ -16,7 +16,7 @@ export const ProfileEdit = () => {
return ( return (
<RouteDrawer> <RouteDrawer>
<RouteDrawer.Header className="capitalize"> <RouteDrawer.Header className="capitalize">
<Heading>{t("profile.editProfile")}</Heading> <Heading>{t("profile.edit.header")}</Heading>
</RouteDrawer.Header> </RouteDrawer.Header>
{!isLoading && user && ( {!isLoading && user && (
<EditProfileForm user={user} usageInsights={false} /> <EditProfileForm user={user} usageInsights={false} />