Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the wrong organization profile object #946

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.80.3",
"version": "0.80.4-rc.2",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/components/card-pipeline/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const Head = ({
<div className="flex flex-row p-3">
<div className="mr-auto flex flex-row gap-x-2">
<EntityAvatar
src={pipeline.owner.profile_avatar ?? null}
src={pipeline.owner?.profile?.avatar ?? null}
className="h-8 w-8"
entityName={ownerID}
fallbackImg={
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/lib/vdp-sdk/mgmt/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type UserProfile = {
public_email?: string;
company_name?: string;
avatar?: string;
social_profiles?: {
social_profiles_links?: {
webiste?: string;
x?: string;
github?: string;
Expand Down
9 changes: 3 additions & 6 deletions packages/toolkit/src/lib/vdp-sdk/organization/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import {
OrganizationMembership,
MembershipState,
UserMembership,
OrganizationProfile,
} from "./types";

export type CreateOrganizationPayload = {
id: string;
org_name: string;
profile_avatar?: Nullable<string>;
profile_data?: Nullable<GeneralRecord>;
profile?: OrganizationProfile;
};

export type CreateOrganizationResponse = {
Expand Down Expand Up @@ -46,9 +45,7 @@ export type UpdateOrganizationResponse = {

export type UpdateOrganizationPayload = {
id: string;
org_name: string;
profile_avatar?: Nullable<string>;
profile_data?: Nullable<GeneralRecord>;
profile?: Partial<OrganizationProfile>;
};

export async function updateOrganizationMutation({
Expand Down
19 changes: 14 additions & 5 deletions packages/toolkit/src/lib/vdp-sdk/organization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ import { GeneralRecord, Nullable } from "../../type";
import { User } from "../mgmt";
import { StripeSubscriptionDetail } from "../types";

export type OrganizationProfile = {
display_name?: string;
bio?: string;
public_email?: string;
avatar?: string;
social_profiles_links?: {
webiste?: string;
x?: string;
github?: string;
};
};

export type Organization = {
name: string;
uid: string;
id: string;
create_time: string;
update_time: string;
org_name: string;
customer_id: string;
profile_avatar: Nullable<string>;
profile_data: Nullable<GeneralRecord>;
owner: Nullable<User>;
owner: User;
profile?: OrganizationProfile;
};

export type OrganizationSubscriptionPlan =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const TabShare = () => {
<div className="flex flex-row">
<div className="mr-auto flex flex-row gap-x-2">
<EntityAvatar
src={pipeline.data?.owner.profile_avatar ?? null}
src={pipeline.data?.owner?.profile.avatar ?? null}
entityName={pipeline.data?.owner_name ?? ""}
className="h-[30px] w-[30px]"
fallbackImg={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const Head = () => {
{entityObject.isSuccess ? (
entityObject.namespaceType === "NAMESPACE_ORGANIZATION" ? (
<EntityAvatar
src={organization.data?.profile_avatar ?? null}
src={organization.data?.profile?.avatar ?? null}
entityName={organization.data?.name ?? ""}
className="h-6 w-6"
fallbackImg={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const UserProfileBio = ({
>
<EntityAvatar
entityName={membership.organization.name}
src={membership.organization.profile_avatar ?? null}
src={membership.organization.profile?.avatar ?? null}
className="h-5 w-5"
fallbackImg={
<Icons.User02 className="h-5 w-5 stroke-semantic-fg-secondary" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ export const UserProfileView = () => {
entityObject.isSuccess &&
me.data.id === String(entityObject.entity)
}
twitterLink={user.data.profile?.social_profiles?.x ?? null}
githubLink={user.data.profile?.social_profiles?.github ?? null}
twitterLink={user.data.profile?.social_profiles_links?.x ?? null}
githubLink={
user.data.profile?.social_profiles_links?.github ?? null
}
/>
) : (
<UserProfileBio.Skeleton />
Expand Down
6 changes: 3 additions & 3 deletions packages/toolkit/src/view/settings/user/UserProfileTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import { useUpdateAuthenticatedUser } from "../../../lib";

export const UserProfileTabSchema = z.object({
id: z.string().min(1, "User name is required"),
profile_avatar: z.string().optional(),
newsletter_subscription: z.boolean(),

profile: z
.object({
avatar: z.string().optional(),
display_name: z.string().optional(),
company_name: z.string().optional(),
bio: z.string().optional(),
Expand Down Expand Up @@ -132,7 +132,7 @@ export const UserProfileTab = () => {
setIsOpenProfileAvatar(false);
setProfileAvatar(null);

form.resetField("profile_avatar");
form.resetField("profile.avatar");
}

return (
Expand Down Expand Up @@ -279,7 +279,7 @@ export const UserProfileTab = () => {
<Setting.TabSectionContent className="gap-y-4">
<Form.Field
control={form.control}
name="profile_avatar"
name="profile.avatar"
render={({ field }) => {
return (
<Form.Item className="w-full">
Expand Down
Loading