make a check for the user profile on the DID screen

This commit is contained in:
2026-02-01 16:36:27 -07:00
parent cc7c7eb88b
commit 099d70e8a9

View File

@@ -136,6 +136,38 @@
/>
</span>
</div>
<button class="ml-2 mr-2 mt-4" @click="toggleUserProfile">
User Profile
<font-awesome
v-if="showUserProfile"
icon="chevron-down"
class="text-blue-400"
/>
<font-awesome v-else icon="chevron-right" class="text-blue-400" />
</button>
<div
v-if="showUserProfile"
class="mt-2 px-4 py-3 bg-slate-100 rounded-md"
>
<div v-if="userProfileLoading" class="text-sm text-slate-600">
<font-awesome icon="spinner" class="fa-spin-pulse mr-2" />
Loading
</div>
<div v-else-if="userProfileError" class="text-sm text-slate-600">
{{ userProfileError }}
</div>
<div v-else-if="userProfileData" class="text-sm">
<p
v-if="userProfileData.description"
class="text-slate-700 whitespace-pre-wrap"
>
{{ userProfileData.description }}
</p>
<p v-else class="text-slate-500 italic">No description.</p>
</div>
</div>
<div class="flex justify-between mt-4">
<div class="flex items-center">
<div v-if="activeDid" class="flex justify-between items-end">
@@ -422,6 +454,7 @@ import {
} from "@/constants/notifications";
import { THAT_UNNAMED_PERSON } from "@/constants/entities";
import { getContactMethodLabel } from "@/constants/contacts";
import type { UserProfile } from "@/libs/partnerServer";
/**
* DIDView Component
@@ -473,6 +506,11 @@ export default class DIDView extends Vue {
showGeneralAdvanced = false;
showLargeIdenticonId?: string;
showLargeIdenticonUrl?: string;
showUserProfile = false;
userProfileData: UserProfile | null = null;
userProfileError: string | null = null;
userProfileFetched = false;
userProfileLoading = false;
viewingDid?: string;
capitalizeAndInsertSpacesBeforeCaps = capitalizeAndInsertSpacesBeforeCaps;
@@ -624,7 +662,7 @@ export default class DIDView extends Vue {
this.generateEmbeddingSaving = true;
try {
const headers = await getHeaders(this.activeDid);
const url = `${this.partnerApiServer}/api/partner/userProfile/${encodeURIComponent(this.viewingDid)}/generateEmbedding`;
const url = `${this.partnerApiServer}/api/partner/userProfileGenerateEmbedding/${encodeURIComponent(this.viewingDid)}`;
await this.axios.put(url, { generateEmbedding: newValue }, { headers });
this.generateEmbedding = newValue;
this.notify.success(
@@ -676,6 +714,51 @@ export default class DIDView extends Vue {
this.showDidDetails = !this.showDidDetails;
}
/**
* Toggles the User Profile section and loads profile from server on first expand.
*/
toggleUserProfile() {
this.showUserProfile = !this.showUserProfile;
if (this.showUserProfile && !this.userProfileFetched) {
this.loadUserProfile();
}
}
/**
* Loads the user profile for the viewing DID from the partner API.
* Shows profile content or a message if the DID has no profile or it is not visible.
*/
async loadUserProfile() {
if (!this.viewingDid || !this.activeDid) return;
this.userProfileFetched = true;
this.userProfileLoading = true;
this.userProfileError = null;
this.userProfileData = null;
try {
const headers = await getHeaders(this.activeDid);
const url = `${this.partnerApiServer}/api/partner/userProfileForIssuer/${encodeURIComponent(this.viewingDid)}`;
const response = await this.axios.get(url, { headers });
const data = response.data?.data;
if (data) {
this.userProfileData = data;
}
} catch (err: unknown) {
const axiosErr = err as {
response?: { status?: number; data?: { error?: string } };
};
const status = axiosErr.response?.status;
const message = axiosErr.response?.data?.error;
if (status === 404 && message) {
this.userProfileError = message;
} else {
this.userProfileError =
"This DID does not have a profile or doesn't make it visible to you.";
}
} finally {
this.userProfileLoading = false;
}
}
showLargeProfileImage() {
this.showLargeIdenticonUrl = this.contactFromDid?.profileImageUrl;
}