Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zavarin-michael committed Sep 6, 2023
1 parent 1f21f1c commit 590b047
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from './constants'
import classnames from 'classnames'
import { AimOutlined } from '@ant-design/icons'
import { Select } from '@domains/common/components/select'
import { handleSubmitForm } from '../../handlers/circle'
import { handleSubmitForm } from '../../handlers/circleUpdate'
import { useChangeCircleMutation, useGetCircleQuery } from '../../redux/circleApi'
import { getVarsForAddressColumn } from '@domains/common/utils/geo'
import { getUuidFromUrl } from '@domains/common/utils/getUuidFromUrl'
Expand Down Expand Up @@ -104,10 +104,10 @@ export const ChangeCircleForm = () => {
customType={'selectInput'}
className={styles.select}
loading={circlesData.isLoading}
options={circlesAddresses?.map((x: string | undefined) => {
options={circlesAddresses?.map((address: string | undefined) => {
return {
value: x,
label: x,
value: address,
label: address,
}
})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from './constants'
import classnames from 'classnames'
import { AimOutlined } from '@ant-design/icons'
import { Select } from '@domains/common/components/select'
import { handleSubmitForm } from '../../handlers/circle'
import { handleSubmitForm } from '../../handlers/circleCreate'
import { useCreateCircleMutation } from '../../redux/circleApi'
import { getVarsForAddressColumn } from '@domains/common/utils/geo'

Expand Down Expand Up @@ -88,10 +88,10 @@ export const CreateCircleForm = () => {
customType={'selectInput'}
className={styles.select}
loading={circlesData.isLoading}
options={circlesAddresses?.map((x: string | undefined) => {
options={circlesAddresses?.map((address: string | undefined) => {
return {
value: x,
label: x,
value: address,
label: address,
}
})}
/>
Expand Down
27 changes: 27 additions & 0 deletions apps/schools/domains/circle/handlers/circleCreate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FormInstance, message } from 'antd'
import { LoadingRequestMsg, SuccessCreateCircleMsg } from '@domains/user/components/auth/constants/message'
import { removeEmpty } from '@domains/common/utils/form'
import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from '../components/createCircleForm/constants'
import { withLoadingMessage } from '@domains/common/utils/loading'
import { ADDRESS_SEPARATOR } from '@domains/common/utils/geo'

export async function handleSubmitForm(organizationId: string, formComponent: FormInstance, mutation: any) {
const response = await withLoadingMessage(
LoadingRequestMsg,
mutation,
removeEmpty({
organization: organizationId,
name: formComponent.getFieldValue(CIRCLE_NAME),
address: `${formComponent.getFieldValue(CIRCLE_ADDRESS)}${ADDRESS_SEPARATOR}${formComponent.getFieldValue(
ADDRESS_ROOM,
)}`,
}),
)

if ('data' in response) {
message.success(SuccessCreateCircleMsg)
return true
}

return false
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FormInstance, message } from 'antd'
import { LoadingRequestMsg, SuccessUpdateCircleMsg } from '@domains/user/components/auth/constants/message'
import { removeEmpty } from '@domains/common/utils/form'
import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from '../components/createCircleForm/constants'
import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from '../components/changeCircleForm/constants'
import { withLoadingMessage } from '@domains/common/utils/loading'
import { ADDRESS_SEPARATOR } from '@domains/common/utils/geo'

Expand Down

0 comments on commit 590b047

Please sign in to comment.