feat: wired linking account api and form state, updated card ui

This commit is contained in:
MTG2000
2022-08-17 13:31:13 +03:00
parent 5a7bac8325
commit 1be2bb4fae
7 changed files with 150 additions and 104 deletions

View File

@@ -339,7 +339,7 @@ export interface NexusGenFieldTypes {
deleteStory: NexusGenRootTypes['Story'] | null; // Story
donate: NexusGenRootTypes['Donation']; // Donation!
updateProfileDetails: NexusGenRootTypes['MyProfile'] | null; // MyProfile
updateUserPreferences: NexusGenRootTypes['MyProfile'][]; // [MyProfile!]!
updateUserPreferences: NexusGenRootTypes['MyProfile']; // MyProfile!
vote: NexusGenRootTypes['Vote']; // Vote!
}
MyProfile: { // field return type

View File

@@ -118,7 +118,7 @@ type Mutation {
deleteStory(id: Int!): Story
donate(amount_in_sat: Int!): Donation!
updateProfileDetails(data: ProfileDetailsInput): MyProfile
updateUserPreferences(userKeys: [UserKeyInputType!]): [MyProfile!]!
updateUserPreferences(userKeys: [UserKeyInputType!]): MyProfile!
vote(amount_in_sat: Int!, item_id: Int!, item_type: VOTE_ITEM_TYPE!): Vote!
}

View File

@@ -161,7 +161,7 @@ const UserKeyInputType = inputObjectType({
const updateUserPreferences = extendType({
type: 'Mutation',
definition(t) {
t.nonNull.list.nonNull.field('updateUserPreferences', {
t.nonNull.field('updateUserPreferences', {
type: 'MyProfile',
args: { userKeys: list(nonNull(UserKeyInputType)) },
async resolve(_root, args, ctx) {
@@ -182,7 +182,7 @@ const updateUserPreferences = extendType({
equals: user.id,
},
key: {
in: args.data.map(i => i.key)
in: args.userKeys.map(i => i.key)
}
},
},
@@ -192,15 +192,15 @@ const updateUserPreferences = extendType({
})).map(i => i.key);
const newKeys = [];
for (let i = 0; i < args.data.length; i++) {
const item = args.data[i];
for (let i = 0; i < args.userKeys.length; i++) {
const item = args.userKeys[i];
if (userKeys.includes(item.key))
newKeys.push(item);
}
if (newKeys.length === 0)
throw new Error("You can't delete all your keys")
throw new Error("You can't delete all your wallets keys")
await prisma.userKey.deleteMany({
where: {