feat: show attributes in profile (#17920)
This commit is contained in:
1 parent
5720ec8038
commit
8052d27d0b
2 files changed
+42
-6
No files matched your search
@@ -11,6 +11,7 @@ import { z } from "zod";
|
||||
|
||||
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { DisplayInfo } from "@calcom/features/users/components/UserTable/EditSheet/DisplayInfo";
|
||||
import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
@@ -598,6 +599,11 @@ const ProfileForm = ({
|
||||
handleAccountDisconnect(getUpdatedFormValues(formMethods.getValues()));
|
||||
};
|
||||
|
||||
const { data: usersAttributes, isPending: usersAttributesPending } =
|
||||
trpc.viewer.attributes.getByUserId.useQuery({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
const {
|
||||
formState: { isSubmitting, isDirty },
|
||||
} = formMethods;
|
||||
@@ -696,6 +702,28 @@ const ProfileForm = ({
|
||||
height="80px"
|
||||
/>
|
||||
</div>
|
||||
{usersAttributes && usersAttributes?.length > 0 && (
|
||||
<div className="mt-6 flex flex-col">
|
||||
<Label>{t("attributes")}</Label>
|
||||
<div className="flex flex-col space-y-4">
|
||||
{usersAttributes.map((attribute, index) => (
|
||||
<>
|
||||
<DisplayInfo
|
||||
key={index}
|
||||
label={attribute.name}
|
||||
labelClassname="font-normal text-sm text-subtle"
|
||||
valueClassname="text-emphasis inline-flex items-center gap-1 font-normal text-sm leading-5"
|
||||
value={
|
||||
["TEXT", "NUMBER", "SINGLE_SELECT"].includes(attribute.type)
|
||||
? attribute.options[0].value
|
||||
: attribute.options.map((option) => option.value)
|
||||
}
|
||||
/>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{/* // For Non-Cal indentities, we merge the values from DB and the user logging in,
|
||||
so essentially there is no point in allowing them to disconnect, since when they log in they will get logged into the same account */}
|
||||
{!isCALIdentityProvider && user.email !== user.identityProviderEmail && (
|
||||
|
||||
Reference in new issue
Block a user