-
Notifications
You must be signed in to change notification settings - Fork 0
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: Add customerId in user table #9
Merged
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
51b6c9d
fix:add customerId in user table
e1ad2b5
fix: format
08e4c2d
feat:CustomerId service
b176827
feat:build
2379c20
format
ffc0ae7
change model and interface
7a6848e
fix:changes in user table and service
99ac17f
fix:build
e2035ff
fix:small adjust
86883cd
fix:table
40d469f
fix:refactor updateCustomerId
3beadf8
fix:refactor updateCustomerId
20e2ef0
format
966ff0f
fix: validationDb
a3dd692
fix: validationDb
127b942
fix:validationDb and model
70f279c
format
49dbf0e
fix: updatee
e4ca6be
Merge branch 'master' of https://github.com/Duna-System/duna-web-plat…
78fd120
fix:photogrammetry field
9984e94
fix:build
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { IUsers } from '../../interfaces'; | ||
export declare function updateCustomerId(email: string, updates: Partial<IUsers['paymentInfo']>): Promise<IUsers | null>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateCustomerId = void 0; | ||
const duna_web_platform_error_defs_1 = require("duna-web-platform-error-defs"); | ||
const validationUserModel_1 = require("../validationUserModel"); | ||
function updateCustomerId(email, updates) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const filter = { email }; | ||
const update = { | ||
$set: { | ||
'paymentInfo.customerId': updates.customerId, | ||
'paymentInfo.plan': updates.plan, | ||
'paymentInfo.expirationDate': updates.expirationDate, | ||
}, | ||
}; | ||
const options = { new: true }; | ||
const updatedUser = yield validationUserModel_1.UserModel.findOneAndUpdate(filter, update, options); | ||
if (!updatedUser) { | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.UserNotFound.Message; | ||
throw err; | ||
} | ||
return updatedUser; | ||
} | ||
catch (error) { | ||
console.error('Error in updateCustomerId:', error); | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.InternalServerError; | ||
err.Details = 'Error updating user data.'; | ||
throw err; | ||
} | ||
}); | ||
} | ||
exports.updateCustomerId = updateCustomerId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ErrorMessages } from 'duna-web-platform-error-defs' | ||
import { IUsers } from '../../interfaces' | ||
import { UserModel } from '../validationUserModel' | ||
|
||
export async function updateCustomerId( | ||
email: string, | ||
updates: Partial<IUsers['paymentInfo']> | ||
): Promise<IUsers | null> { | ||
try { | ||
const filter = { email } | ||
const update = { | ||
$set: { | ||
'paymentInfo.customerId': updates.customerId, | ||
'paymentInfo.plan': updates.plan, | ||
'paymentInfo.expirationDate': updates.expirationDate, | ||
}, | ||
} | ||
|
||
const options = { new: true } | ||
|
||
const updatedUser = await UserModel.findOneAndUpdate( | ||
filter, | ||
update, | ||
options | ||
) | ||
|
||
if (!updatedUser) { | ||
const err = ErrorMessages.UserNotFound.Message | ||
throw err | ||
} | ||
|
||
return updatedUser | ||
} catch (error) { | ||
console.error('Error in updateCustomerId:', error) | ||
const err = ErrorMessages.InternalServerError | ||
err.Details = 'Error updating user data.' | ||
throw err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
não faltou atualizar
validationDbUsers.ts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O validationDbUsers.ts é uma validação com os campos required, o bruno e eu estamos pensando na possibilidade de que o cadastro da stripe possa não acontecer, nesse caso o nosso cadastro não seria impactado. Quando o usuario se cadastrar na stripe de fato , ele atualiza a tabela do users com o campo customerId.