-
Notifications
You must be signed in to change notification settings - Fork 3
feat: org address #1023
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
feat: org address #1023
Conversation
Klakurka
left a comment
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.
Can we apply the loading spinner to the change address/name buttons like we have across the rest of the site?
utils/validators.ts
Outdated
| export const parseUpdateOrganizationPUTRequest = function (params: UpdateOrganizationPUTParameters): UpdateOrganizationInput { | ||
| if (params.userId === '' || params.userId === undefined) throw new Error(RESPONSE_MESSAGES.USER_ID_NOT_PROVIDED_400.message) | ||
| if (params.name === '' || params.name === undefined) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message) | ||
| if ((params.name === '' || params.name === undefined) && (params.address === '' || params.address === undefined)) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message) |
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.
should be in another if bracket with the appropriate error
9954feb to
7d44264
Compare
Klakurka
left a comment
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.
Did you forget to push something?
- Still have the address input showing on the initial creation form.
- The Cancel button is still weird. The Update and Cancel buttons should be sized and positioned like we do on the dialogs.
Yup, I am sure I addressed these in my last commit |
prisma/schema.prisma
Outdated
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
| creatorId String @unique | ||
| address String? |
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.
Should not be nullable. We never let a string be nullable, because the empty string can fulfill that role (unless it is a foreign key, in which case we have to do that to indicate its an optional related field).
services/organizationService.ts
Outdated
| where: { id: organization.id }, | ||
| data: { name } | ||
| data: { | ||
| ...(name !== undefined || name === '' ? { name } : {}), |
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.
Very hard to read, and I think that's why it's wrong — should be name !== '', not name === ''. Same thing for the address in the line below. In any case, there are more readable ways to write this logic, such as:
const updateData: Partial<Organization> = {}
if (name !== undefined && name !== '') updateData.name = name
if (address !== undefined && address !== '') updateData.address = address
return await prisma.organization.update({
where: { id: organization.id },
data: updateData,
})
utils/validators.ts
Outdated
| export const parseUpdateOrganizationPUTRequest = function (params: UpdateOrganizationPUTParameters): UpdateOrganizationInput { | ||
| if (params.userId === '' || params.userId === undefined) throw new Error(RESPONSE_MESSAGES.USER_ID_NOT_PROVIDED_400.message) | ||
| if (params.name === '' || params.name === undefined) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message) | ||
| if ((params.name === '' || params.name === undefined) && (params.address === '' || params.address === undefined)) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_MISSING_PARAMS_400.message) |
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.
Just a nitpick, but this error name "ORGANIZATION_MISSING_PARAMS_400" leads one to believe that the organization itself is missing these, better if it was something like MISSING_PARAMS_TO_UPDATE_ORGANIZATION_400




Related to #1015
Description
Added address to organization
Test plan
Open the dashboard, go to account, check address config