-
-
+
+ (
+ {
+ onChange(v);
+ handleSubmit(onSubmit)();
+ }} />
+ )}
+ />
+
+
+
+ {/* reset()}
+ /> */}
)
diff --git a/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/RemoveWalletKeyModal.tsx b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/RemoveWalletKeyModal.tsx
new file mode 100644
index 0000000..53f9d46
--- /dev/null
+++ b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/RemoveWalletKeyModal.tsx
@@ -0,0 +1,48 @@
+import { ModalCard, modalCardVariants } from 'src/Components/Modals/ModalsContainer/ModalsContainer'
+import { motion } from 'framer-motion'
+import { IoClose } from 'react-icons/io5'
+import Button from 'src/Components/Button/Button'
+import { useAppDispatch } from 'src/utils/hooks'
+import { PayloadAction } from '@reduxjs/toolkit'
+
+interface Props extends ModalCard {
+ callbackAction: PayloadAction<{ confirmed: boolean }>
+}
+
+
+
+export default function RemoveWalletKeyModal({
+ onClose, direction, callbackAction,
+}: Props) {
+
+ const dispatch = useAppDispatch();
+
+ const handleConfirm = () => {
+ const action = Object.assign({}, callbackAction);
+ action.payload = { confirmed: true }
+ dispatch(action)
+ onClose?.();
+ }
+
+ return (
+
+
+ Remove key?
+
+
π
+
Are you sure you want to remove this key from your account? Once deleted, you wonβt be able to recover it.
+
+
+
+
+
+
+ )
+}
diff --git a/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/index.ts b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/index.ts
new file mode 100644
index 0000000..c056033
--- /dev/null
+++ b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal/index.ts
@@ -0,0 +1,3 @@
+import { lazyModal } from 'src/utils/helperFunctions';
+
+export const { LazyComponent: RemoveWalletKeyModal } = lazyModal(() => import('./RemoveWalletKeyModal'))
\ No newline at end of file
diff --git a/src/features/Profiles/pages/EditProfilePage/PreferencesTab/profilePreferences.graphql b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/profilePreferences.graphql
new file mode 100644
index 0000000..0f23571
--- /dev/null
+++ b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/profilePreferences.graphql
@@ -0,0 +1,23 @@
+query MyProfilePreferences {
+ me {
+ id
+ walletsKeys {
+ key
+ name
+ }
+ nostr_prv_key
+ nostr_pub_key
+ }
+}
+
+mutation UpdateUserPreferences($walletsKeys: [UserKeyInputType!]) {
+ updateUserPreferences(userKeys: $walletsKeys) {
+ id
+ walletsKeys {
+ key
+ name
+ }
+ nostr_pub_key
+ nostr_prv_key
+ }
+}
diff --git a/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx b/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx
index 3f616c7..941814c 100644
--- a/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx
+++ b/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx
@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom'
import Button from 'src/Components/Button/Button'
import Card from 'src/Components/Card/Card'
import Avatar from 'src/features/Profiles/Components/Avatar/Avatar'
-import { useProfileQuery } from 'src/graphql'
import { trimText } from 'src/utils/helperFunctions'
import { useAppSelector } from 'src/utils/hooks'
import { createRoute } from 'src/utils/routing'
@@ -17,14 +16,10 @@ interface Props {
export default function SaveChangesCard(props: Props) {
- const userId = useAppSelector(state => state.user.me?.id!)
- const profileQuery = useProfileQuery({
- variables: {
- profileId: userId,
- },
- })
+ const user = useAppSelector(state => state.user.me)
- if (!profileQuery.data?.profile)
+
+ if (!user)
return <>>
@@ -38,18 +33,18 @@ export default function SaveChangesCard(props: Props) {
-
+ to={createRoute({ type: 'profile', id: user.id, username: user.name })}>
+
-
{profileQuery.data.profile ? trimText(profileQuery.data.profile.name, 30) : "Anonymouse"}
- {profileQuery.data.profile.jobTitle &&
{profileQuery.data.profile.jobTitle}
}
+
{user ? trimText(user.name, 30) : "Anonymouse"}
+ {user.jobTitle &&
{user.jobTitle}
}
{/* {showTimeAgo &&
{dayjs().diff(props.date, 'hour') < 24 ? `${dayjs().diff(props.date, 'hour')}h ago` : undefined}
} */}
-
{trimText(profileQuery.data.profile.bio, 120)}
+
{trimText(user.bio, 120)}
+ )
+}
diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx
index 9f354a6..2af4dbe 100644
--- a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx
+++ b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx
@@ -1,33 +1,23 @@
import { SubmitHandler, useForm } from "react-hook-form"
import Button from "src/Components/Button/Button";
-import { User, useUpdateProfileAboutMutation } from "src/graphql";
+import { User, useUpdateProfileAboutMutation, useMyProfileAboutQuery, UpdateProfileAboutMutationVariables } from "src/graphql";
import { NotificationsService } from "src/services/notifications.service";
import * as yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import Avatar from "src/features/Profiles/Components/Avatar/Avatar";
-import { usePrompt } from "src/utils/hooks";
+import { useAppDispatch, usePrompt } from "src/utils/hooks";
import SaveChangesCard from "../SaveChangesCard/SaveChangesCard";
import { toast } from "react-toastify";
import Card from "src/Components/Card/Card";
+import LoadingPage from "src/Components/LoadingPage/LoadingPage";
+import NotFoundPage from "src/features/Shared/pages/NotFoundPage/NotFoundPage";
+import { setUser } from "src/redux/features/user.slice";
+import UpdateProfileAboutTabSkeleton from "./UpdateMyProfileTab.Skeleton";
interface Props {
- data: Pick
,
- onClose?: () => void;
}
-type IFormInputs = Props['data'];
+type IFormInputs = NonNullable;
const schema: yup.SchemaOf = yup.object({
name: yup.string().trim().required().min(2),
@@ -63,21 +53,35 @@ const schema: yup.SchemaOf = yup.object({
}).required();
-export default function UpdateMyProfileTab({ data, onClose }: Props) {
+export default function UpdateMyProfileTab() {
const { register, formState: { errors, isDirty, }, handleSubmit, reset } = useForm({
- defaultValues: data,
+ defaultValues: {},
resolver: yupResolver(schema),
mode: 'onBlur',
});
+
+ const profileQuery = useMyProfileAboutQuery({
+ onCompleted: data => {
+ if (data.me)
+ reset(data.me)
+ }
+ })
const [mutate, mutationStatus] = useUpdateProfileAboutMutation();
-
-
+ const dispatch = useAppDispatch()
usePrompt('You may have some unsaved changes. You still want to leave?', isDirty)
+
+ if (profileQuery.loading)
+ return
+
+ if (!profileQuery.data?.me)
+ return
+
+
const onSubmit: SubmitHandler = data => {
const toastId = toast.loading("Saving changes...", NotificationsService.defaultOptions)
@@ -98,9 +102,12 @@ export default function UpdateMyProfileTab({ data, onClose }: Props) {
website: data.website,
}
},
- onCompleted: () => {
- reset(data);
- toast.update(toastId, { render: "Saved changes successfully", type: "success", ...NotificationsService.defaultOptions, isLoading: false });
+ onCompleted: ({ updateProfileDetails: data }) => {
+ if (data) {
+ dispatch(setUser(data))
+ reset(data);
+ toast.update(toastId, { render: "Saved changes successfully", type: "success", ...NotificationsService.defaultOptions, isLoading: false });
+ }
}
})
.catch(() => {
@@ -114,7 +121,7 @@ export default function UpdateMyProfileTab({ data, onClose }: Props) {
diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql
new file mode 100644
index 0000000..3517a9b
--- /dev/null
+++ b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql
@@ -0,0 +1,37 @@
+query MyProfileAbout {
+ me {
+ id
+ name
+ avatar
+ join_date
+ role
+ email
+ jobTitle
+ lightning_address
+ website
+ twitter
+ github
+ linkedin
+ bio
+ location
+ }
+}
+
+mutation updateProfileAbout($data: ProfileDetailsInput) {
+ updateProfileDetails(data: $data) {
+ id
+ name
+ avatar
+ join_date
+ role
+ email
+ jobTitle
+ lightning_address
+ website
+ twitter
+ github
+ linkedin
+ bio
+ location
+ }
+}
diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/updateProfile.graphql b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/updateProfile.graphql
deleted file mode 100644
index a1b690f..0000000
--- a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/updateProfile.graphql
+++ /dev/null
@@ -1,18 +0,0 @@
-mutation updateProfileAbout($data: UpdateProfileInput) {
- updateProfile(data: $data) {
- id
- name
- avatar
- join_date
- website
- role
- email
- lightning_address
- jobTitle
- twitter
- github
- linkedin
- bio
- location
- }
-}
diff --git a/src/features/Profiles/pages/ProfilePage/profile.graphql b/src/features/Profiles/pages/ProfilePage/profile.graphql
index a118e4e..60feb92 100644
--- a/src/features/Profiles/pages/ProfilePage/profile.graphql
+++ b/src/features/Profiles/pages/ProfilePage/profile.graphql
@@ -24,7 +24,5 @@ query profile($profileId: Int!) {
icon
}
}
- nostr_prv_key
- nostr_pub_key
}
}
diff --git a/src/graphql/index.tsx b/src/graphql/index.tsx
index 612d9a3..f9f95ac 100644
--- a/src/graphql/index.tsx
+++ b/src/graphql/index.tsx
@@ -35,6 +35,24 @@ export type Award = {
url: Scalars['String'];
};
+export type BaseUser = {
+ avatar: Scalars['String'];
+ bio: Maybe
;
+ email: Maybe;
+ github: Maybe;
+ id: Scalars['Int'];
+ jobTitle: Maybe;
+ join_date: Scalars['Date'];
+ lightning_address: Maybe;
+ linkedin: Maybe;
+ location: Maybe;
+ name: Scalars['String'];
+ role: Maybe;
+ stories: Array;
+ twitter: Maybe;
+ website: Maybe;
+};
+
export type Bounty = PostBase & {
__typename?: 'Bounty';
applicants_count: Scalars['Int'];
@@ -121,7 +139,8 @@ export type Mutation = {
createStory: Maybe;
deleteStory: Maybe;
donate: Donation;
- updateProfile: Maybe;
+ updateProfileDetails: Maybe;
+ updateUserPreferences: MyProfile;
vote: Vote;
};
@@ -153,8 +172,13 @@ export type MutationDonateArgs = {
};
-export type MutationUpdateProfileArgs = {
- data: InputMaybe;
+export type MutationUpdateProfileDetailsArgs = {
+ data: InputMaybe;
+};
+
+
+export type MutationUpdateUserPreferencesArgs = {
+ userKeys: InputMaybe>;
};
@@ -164,6 +188,28 @@ export type MutationVoteArgs = {
item_type: Vote_Item_Type;
};
+export type MyProfile = BaseUser & {
+ __typename?: 'MyProfile';
+ avatar: Scalars['String'];
+ bio: Maybe;
+ email: Maybe;
+ github: Maybe;
+ id: Scalars['Int'];
+ jobTitle: Maybe;
+ join_date: Scalars['Date'];
+ lightning_address: Maybe;
+ linkedin: Maybe;
+ location: Maybe;
+ name: Scalars['String'];
+ nostr_prv_key: Maybe;
+ nostr_pub_key: Maybe;
+ role: Maybe;
+ stories: Array;
+ twitter: Maybe;
+ walletsKeys: Array;
+ website: Maybe;
+};
+
export enum Post_Type {
Bounty = 'Bounty',
Question = 'Question',
@@ -193,6 +239,20 @@ export type PostComment = {
votes_count: Scalars['Int'];
};
+export type ProfileDetailsInput = {
+ avatar: InputMaybe;
+ bio: InputMaybe;
+ email: InputMaybe;
+ github: InputMaybe;
+ jobTitle: InputMaybe;
+ lightning_address: InputMaybe;
+ linkedin: InputMaybe;
+ location: InputMaybe;
+ name: InputMaybe;
+ twitter: InputMaybe;
+ website: InputMaybe;
+};
+
export type Project = {
__typename?: 'Project';
awards: Array;
@@ -224,7 +284,7 @@ export type Query = {
getProject: Project;
getTrendingPosts: Array;
hottestProjects: Array;
- me: Maybe;
+ me: Maybe;
newProjects: Array;
officialTags: Array;
popularTags: Array;
@@ -361,21 +421,7 @@ export type Tag = {
title: Scalars['String'];
};
-export type UpdateProfileInput = {
- avatar: InputMaybe;
- bio: InputMaybe;
- email: InputMaybe;
- github: InputMaybe;
- jobTitle: InputMaybe;
- lightning_address: InputMaybe;
- linkedin: InputMaybe;
- location: InputMaybe;
- name: InputMaybe;
- twitter: InputMaybe;
- website: InputMaybe;
-};
-
-export type User = {
+export type User = BaseUser & {
__typename?: 'User';
avatar: Scalars['String'];
bio: Maybe;
@@ -388,14 +434,17 @@ export type User = {
linkedin: Maybe;
location: Maybe;
name: Scalars['String'];
- nostr_prv_key: Maybe;
- nostr_pub_key: Maybe;
role: Maybe;
stories: Array;
twitter: Maybe;
website: Maybe;
};
+export type UserKeyInputType = {
+ key: Scalars['String'];
+ name: Scalars['String'];
+};
+
export enum Vote_Item_Type {
Bounty = 'Bounty',
PostComment = 'PostComment',
@@ -416,6 +465,12 @@ export type Vote = {
payment_request: Scalars['String'];
};
+export type WalletKey = {
+ __typename?: 'WalletKey';
+ key: Scalars['String'];
+ name: Scalars['String'];
+};
+
export type OfficialTagsQueryVariables = Exact<{ [key: string]: never; }>;
@@ -436,7 +491,7 @@ export type SearchProjectsQuery = { __typename?: 'Query', searchProjects: Array<
export type MeQueryVariables = Exact<{ [key: string]: never; }>;
-export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any } | null };
+export type MeQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, join_date: any, jobTitle: string | null, bio: string | null } | null };
export type DonationsStatsQueryVariables = Exact<{ [key: string]: never; }>;
@@ -515,19 +570,36 @@ export type PostDetailsQueryVariables = Exact<{
export type PostDetailsQuery = { __typename?: 'Query', getPostById: { __typename?: 'Bounty', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, cover_image: string | null, deadline: string, reward_amount: number, applicants_count: number, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }>, applications: Array<{ __typename?: 'BountyApplication', id: number, date: string, workplan: string, author: { __typename?: 'Author', id: number, name: string, avatar: string } }> } | { __typename?: 'Question', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }> } | { __typename?: 'Story', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, cover_image: string | null, is_published: boolean | null, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }> } };
+export type MyProfilePreferencesQueryVariables = Exact<{ [key: string]: never; }>;
+
+
+export type MyProfilePreferencesQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, nostr_prv_key: string | null, nostr_pub_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } | null };
+
+export type UpdateUserPreferencesMutationVariables = Exact<{
+ walletsKeys: InputMaybe | UserKeyInputType>;
+}>;
+
+
+export type UpdateUserPreferencesMutation = { __typename?: 'Mutation', updateUserPreferences: { __typename?: 'MyProfile', id: number, nostr_pub_key: string | null, nostr_prv_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } };
+
+export type MyProfileAboutQueryVariables = Exact<{ [key: string]: never; }>;
+
+
+export type MyProfileAboutQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null } | null };
+
+export type UpdateProfileAboutMutationVariables = Exact<{
+ data: InputMaybe;
+}>;
+
+
+export type UpdateProfileAboutMutation = { __typename?: 'Mutation', updateProfileDetails: { __typename?: 'MyProfile', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null } | null };
+
export type ProfileQueryVariables = Exact<{
profileId: Scalars['Int'];
}>;
-export type ProfileQuery = { __typename?: 'Query', profile: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null, nostr_prv_key: string | null, nostr_pub_key: string | null, stories: Array<{ __typename?: 'Story', id: number, title: string, createdAt: any, tags: Array<{ __typename?: 'Tag', id: number, title: string, icon: string | null }> }> } | null };
-
-export type UpdateProfileAboutMutationVariables = Exact<{
- data: InputMaybe;
-}>;
-
-
-export type UpdateProfileAboutMutation = { __typename?: 'Mutation', updateProfile: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, website: string | null, role: string | null, email: string | null, lightning_address: string | null, jobTitle: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null } | null };
+export type ProfileQuery = { __typename?: 'Query', profile: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null, stories: Array<{ __typename?: 'Story', id: number, title: string, createdAt: any, tags: Array<{ __typename?: 'Tag', id: number, title: string, icon: string | null }> }> } | null };
export type CategoryPageQueryVariables = Exact<{
categoryId: Scalars['Int'];
@@ -698,6 +770,8 @@ export const MeDocument = gql`
name
avatar
join_date
+ jobTitle
+ bio
}
}
`;
@@ -1306,9 +1380,88 @@ export function usePostDetailsLazyQuery(baseOptions?: Apollo.LazyQueryHookOption
export type PostDetailsQueryHookResult = ReturnType;
export type PostDetailsLazyQueryHookResult = ReturnType;
export type PostDetailsQueryResult = Apollo.QueryResult;
-export const ProfileDocument = gql`
- query profile($profileId: Int!) {
- profile(id: $profileId) {
+export const MyProfilePreferencesDocument = gql`
+ query MyProfilePreferences {
+ me {
+ id
+ walletsKeys {
+ key
+ name
+ }
+ nostr_prv_key
+ nostr_pub_key
+ }
+}
+ `;
+
+/**
+ * __useMyProfilePreferencesQuery__
+ *
+ * To run a query within a React component, call `useMyProfilePreferencesQuery` and pass it any options that fit your needs.
+ * When your component renders, `useMyProfilePreferencesQuery` returns an object from Apollo Client that contains loading, error, and data properties
+ * you can use to render your UI.
+ *
+ * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
+ *
+ * @example
+ * const { data, loading, error } = useMyProfilePreferencesQuery({
+ * variables: {
+ * },
+ * });
+ */
+export function useMyProfilePreferencesQuery(baseOptions?: Apollo.QueryHookOptions) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useQuery(MyProfilePreferencesDocument, options);
+ }
+export function useMyProfilePreferencesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useLazyQuery(MyProfilePreferencesDocument, options);
+ }
+export type MyProfilePreferencesQueryHookResult = ReturnType;
+export type MyProfilePreferencesLazyQueryHookResult = ReturnType;
+export type MyProfilePreferencesQueryResult = Apollo.QueryResult;
+export const UpdateUserPreferencesDocument = gql`
+ mutation UpdateUserPreferences($walletsKeys: [UserKeyInputType!]) {
+ updateUserPreferences(userKeys: $walletsKeys) {
+ id
+ walletsKeys {
+ key
+ name
+ }
+ nostr_pub_key
+ nostr_prv_key
+ }
+}
+ `;
+export type UpdateUserPreferencesMutationFn = Apollo.MutationFunction;
+
+/**
+ * __useUpdateUserPreferencesMutation__
+ *
+ * To run a mutation, you first call `useUpdateUserPreferencesMutation` within a React component and pass it any options that fit your needs.
+ * When your component renders, `useUpdateUserPreferencesMutation` returns a tuple that includes:
+ * - A mutate function that you can call at any time to execute the mutation
+ * - An object with fields that represent the current status of the mutation's execution
+ *
+ * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
+ *
+ * @example
+ * const [updateUserPreferencesMutation, { data, loading, error }] = useUpdateUserPreferencesMutation({
+ * variables: {
+ * walletsKeys: // value for 'walletsKeys'
+ * },
+ * });
+ */
+export function useUpdateUserPreferencesMutation(baseOptions?: Apollo.MutationHookOptions) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useMutation(UpdateUserPreferencesDocument, options);
+ }
+export type UpdateUserPreferencesMutationHookResult = ReturnType;
+export type UpdateUserPreferencesMutationResult = Apollo.MutationResult;
+export type UpdateUserPreferencesMutationOptions = Apollo.BaseMutationOptions;
+export const MyProfileAboutDocument = gql`
+ query MyProfileAbout {
+ me {
id
name
avatar
@@ -1323,61 +1476,48 @@ export const ProfileDocument = gql`
linkedin
bio
location
- stories {
- id
- title
- createdAt
- tags {
- id
- title
- icon
- }
- }
- nostr_prv_key
- nostr_pub_key
}
}
`;
/**
- * __useProfileQuery__
+ * __useMyProfileAboutQuery__
*
- * To run a query within a React component, call `useProfileQuery` and pass it any options that fit your needs.
- * When your component renders, `useProfileQuery` returns an object from Apollo Client that contains loading, error, and data properties
+ * To run a query within a React component, call `useMyProfileAboutQuery` and pass it any options that fit your needs.
+ * When your component renders, `useMyProfileAboutQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
- * const { data, loading, error } = useProfileQuery({
+ * const { data, loading, error } = useMyProfileAboutQuery({
* variables: {
- * profileId: // value for 'profileId'
* },
* });
*/
-export function useProfileQuery(baseOptions: Apollo.QueryHookOptions) {
+export function useMyProfileAboutQuery(baseOptions?: Apollo.QueryHookOptions) {
const options = {...defaultOptions, ...baseOptions}
- return Apollo.useQuery(ProfileDocument, options);
+ return Apollo.useQuery(MyProfileAboutDocument, options);
}
-export function useProfileLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) {
+export function useMyProfileAboutLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) {
const options = {...defaultOptions, ...baseOptions}
- return Apollo.useLazyQuery(ProfileDocument, options);
+ return Apollo.useLazyQuery(MyProfileAboutDocument, options);
}
-export type ProfileQueryHookResult = ReturnType;
-export type ProfileLazyQueryHookResult = ReturnType;
-export type ProfileQueryResult = Apollo.QueryResult;
+export type MyProfileAboutQueryHookResult = ReturnType;
+export type MyProfileAboutLazyQueryHookResult = ReturnType;
+export type MyProfileAboutQueryResult = Apollo.QueryResult;
export const UpdateProfileAboutDocument = gql`
- mutation updateProfileAbout($data: UpdateProfileInput) {
- updateProfile(data: $data) {
+ mutation updateProfileAbout($data: ProfileDetailsInput) {
+ updateProfileDetails(data: $data) {
id
name
avatar
join_date
- website
role
email
- lightning_address
jobTitle
+ lightning_address
+ website
twitter
github
linkedin
@@ -1412,6 +1552,64 @@ export function useUpdateProfileAboutMutation(baseOptions?: Apollo.MutationHookO
export type UpdateProfileAboutMutationHookResult = ReturnType;
export type UpdateProfileAboutMutationResult = Apollo.MutationResult;
export type UpdateProfileAboutMutationOptions = Apollo.BaseMutationOptions;
+export const ProfileDocument = gql`
+ query profile($profileId: Int!) {
+ profile(id: $profileId) {
+ id
+ name
+ avatar
+ join_date
+ role
+ email
+ jobTitle
+ lightning_address
+ website
+ twitter
+ github
+ linkedin
+ bio
+ location
+ stories {
+ id
+ title
+ createdAt
+ tags {
+ id
+ title
+ icon
+ }
+ }
+ }
+}
+ `;
+
+/**
+ * __useProfileQuery__
+ *
+ * To run a query within a React component, call `useProfileQuery` and pass it any options that fit your needs.
+ * When your component renders, `useProfileQuery` returns an object from Apollo Client that contains loading, error, and data properties
+ * you can use to render your UI.
+ *
+ * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
+ *
+ * @example
+ * const { data, loading, error } = useProfileQuery({
+ * variables: {
+ * profileId: // value for 'profileId'
+ * },
+ * });
+ */
+export function useProfileQuery(baseOptions: Apollo.QueryHookOptions) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useQuery(ProfileDocument, options);
+ }
+export function useProfileLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useLazyQuery(ProfileDocument, options);
+ }
+export type ProfileQueryHookResult = ReturnType;
+export type ProfileLazyQueryHookResult = ReturnType;
+export type ProfileQueryResult = Apollo.QueryResult;
export const CategoryPageDocument = gql`
query CategoryPage($categoryId: Int!) {
projectsByCategory(category_id: $categoryId) {
diff --git a/src/mocks/data/users.ts b/src/mocks/data/users.ts
index ac8f844..c292050 100644
--- a/src/mocks/data/users.ts
+++ b/src/mocks/data/users.ts
@@ -1,12 +1,12 @@
-import { User } from "src/graphql";
+import { MyProfile, User } from "src/graphql";
import { posts } from "./posts";
-export const user: User = {
+export const user: User & MyProfile = {
id: 123,
email: "mtg0987654321@gmail.com",
avatar: "https://avatars.dicebear.com/api/bottts/Mtgmtg.svg",
bio: "Lorem asiop asklh kluiw wekjhl shkj kljhsva klu khsc klhlkbs mjklwqr kmlk sadlfui mewr qiumnk, asdjomi cskhsdf.",
- name: "123123124asdfsadfsa8d7fsadfasdf",
+ name: "Mtg",
github: "MTG2000",
jobTitle: "Front-end Web Developer",
join_date: new Date(2021).toISOString(),
@@ -14,9 +14,19 @@ export const user: User = {
linkedin: "https://www.linkedin.com/in/mtg-softwares-dev/",
location: "Germany, Berlin",
role: "user",
- twitter: "john-doe",
+ twitter: "mtg",
website: "https://mtg-dev.tech",
stories: posts.stories,
nostr_prv_key: "123123124asdfsadfsa8d7fsadfasdf",
nostr_pub_key: "123124123123dfsadfsa8d7f11sadfasdf",
+ walletsKeys: [
+ {
+ key: "1645h234j2421zxvertw",
+ name: "My Alby wallet key"
+ },
+ {
+ key: "6643534534534534543",
+ name: "My Phoenix wallet key"
+ },
+ ]
}
diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts
index a1fb79b..94b5557 100644
--- a/src/mocks/handlers.ts
+++ b/src/mocks/handlers.ts
@@ -29,6 +29,8 @@ import {
MeQuery,
ProfileQuery,
GetMyDraftsQuery,
+ MyProfileAboutQuery,
+ MyProfilePreferencesQuery,
} from 'src/graphql'
const delay = (ms = 1000) => new Promise((res) => setTimeout(res, ms + Math.random() * 1000))
@@ -195,6 +197,7 @@ export const handlers = [
graphql.query('Me', async (req, res, ctx) => {
await delay()
+ console.log("ME");
return res(
ctx.data({
@@ -203,6 +206,27 @@ export const handlers = [
)
}),
+
+ graphql.query('MyProfileAbout', async (req, res, ctx) => {
+ await delay()
+ return res(
+ ctx.data({
+ me: me(),
+ })
+ )
+ }),
+
+ graphql.query('MyProfilePreferences', async (req, res, ctx) => {
+ await delay()
+ return res(
+ ctx.data({
+ me: me(),
+ })
+ )
+ }),
+
+
+
graphql.query('profile', async (req, res, ctx) => {
await delay()
diff --git a/src/mocks/resolvers.ts b/src/mocks/resolvers.ts
index c3e5ccc..d09f614 100644
--- a/src/mocks/resolvers.ts
+++ b/src/mocks/resolvers.ts
@@ -1,5 +1,5 @@
import { MOCK_DATA } from "./data";
-import { Query, QueryGetFeedArgs, QueryGetPostByIdArgs } from 'src/graphql'
+import { MyProfile, Query, QueryGetFeedArgs, QueryGetPostByIdArgs, User } from 'src/graphql'
import { Chance } from "chance";
import { tags } from "./data/tags";
import { hackathons } from "./data/hackathon";
@@ -72,11 +72,16 @@ export function getAllHackathons() {
}
export function me() {
- return MOCK_DATA['user']
+ return {
+ ...MOCK_DATA['user'],
+ __typename: "MyProfile",
+ } as MyProfile
}
+
+
export function profile() {
- return MOCK_DATA['user']
+ return { ...MOCK_DATA['user'], __typename: 'User' } as User
}
export function getMyDrafts(): Query['getMyDrafts'] {
diff --git a/src/redux/features/modals.slice.ts b/src/redux/features/modals.slice.ts
index c6c3a27..c718a4f 100644
--- a/src/redux/features/modals.slice.ts
+++ b/src/redux/features/modals.slice.ts
@@ -8,7 +8,8 @@ import { InsertLinkModal } from 'src/Components/Inputs/TextEditor/InsertLinkModa
import { Claim_FundWithdrawCard, Claim_CopySignatureCard, Claim_GenerateSignatureCard, Claim_SubmittedCard } from "src/features/Projects/pages/ProjectPage/ClaimProject";
import { ModalCard } from "src/Components/Modals/ModalsContainer/ModalsContainer";
import { ConfirmModal } from "src/Components/Modals/ConfirmModal";
-import { LinkingAccountModal } from "src/features/Profiles/pages/EditProfilePage/AccountCard/LinkingAccountModal";
+import { LinkingAccountModal } from "src/features/Profiles/pages/EditProfilePage/PreferencesTab/LinkingAccountModal";
+import { RemoveWalletKeyModal } from "src/features/Profiles/pages/EditProfilePage/PreferencesTab/RemoveWalletKeyModal";
import { ComponentProps } from "react";
import { generateId } from "src/utils/helperFunctions";
@@ -24,19 +25,27 @@ export enum Direction {
export const ALL_MODALS = {
+ //Projects
ProjectDetailsCard,
+
+ // Auth
Login_ScanningWalletCard,
Login_NativeWalletCard,
Login_SuccessCard,
Login_ExternalWalletCard,
- VoteCard,
Claim_GenerateSignatureCard,
Claim_CopySignatureCard,
Claim_SubmittedCard,
Claim_FundWithdrawCard,
+
+ // Misc
ConfirmModal,
+ VoteCard,
NoWeblnModal,
+
+ // User Wallets Keys
LinkingAccountModal,
+ RemoveWalletKeyModal,
// Text Editor Modals
InsertImageModal,
diff --git a/src/redux/features/user.slice.ts b/src/redux/features/user.slice.ts
index 3cd58d6..24918b4 100644
--- a/src/redux/features/user.slice.ts
+++ b/src/redux/features/user.slice.ts
@@ -1,12 +1,14 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import { MyProfile } from "src/graphql";
interface StoreState {
- me: {
- id: number;
- name: string;
- avatar: string;
- join_date: string;
- }
+ me: Pick
| undefined // fetching user data if exist
| null // user not logged in