Skip to content

Commit

Permalink
don't work fully
Browse files Browse the repository at this point in the history
  • Loading branch information
levil664 committed Sep 7, 2023
1 parent 516bf53 commit 7f18af1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Select } from '@domains/common/components/select'
import { handleSubmitForm } from '../../handlers/circleCreate'
import { useCreateCircleMutation } from '../../redux/circleApi'
import { getVarsForAddressColumn } from '@domains/common/utils/geo'
import AddressForm from "@domains/circle/components/addressForm";
import AddressForm from '@domains/circle/components/addressForm'

export const CreateCircleForm = () => {
const validators = useCreateCircleFormValidators()
Expand Down Expand Up @@ -139,7 +139,7 @@ export const CreateCircleForm = () => {
Родители смогут увидеть ваш кружок с помощью карты и узнать информацию о нём!
</Typography.Title>
</div>
<AddressForm/>
<AddressForm />
</Row>
)
}
21 changes: 10 additions & 11 deletions apps/schools/domains/circle/components/map/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { useMemo } from 'react'
import { ValidatorsMap } from '@domains/common/redux/interfaces'
import { PleaseSelectOneOfOptionsMsg } from "@domains/user/components/auth/constants/message";
import { PleaseSelectOneOfOptionsMsg } from '@domains/user/components/auth/constants/message'

export const useAddressFormValidators = () => {
return useMemo<ValidatorsMap>(() => {
return {
city: [
{
required: true,
message: PleaseSelectOneOfOptionsMsg,
return useMemo<ValidatorsMap>(() => {
return {
city: [
{
required: true,
message: PleaseSelectOneOfOptionsMsg,
},
],
}
],
}
}, [this])
}, [this])
}

22 changes: 11 additions & 11 deletions apps/schools/domains/circle/components/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import getConfig from 'next/config'
import { Input } from '@domains/common/components/input'
import { Select } from '@domains/common/components/select'



const MapComponent = () => {
const {
publicRuntimeConfig: {
Expand Down Expand Up @@ -63,10 +61,12 @@ const MapComponent = () => {

if ((accurateAddress.match(/,/g) || []).length === 3) {
const commaIndex = accurateAddress.indexOf(',')
const currentCity = accurateAddress.substring(commaIndex + 1, accurateAddress.indexOf(',', commaIndex + 1)).trim();
const newAddress = accurateAddress.substring(accurateAddress.indexOf(',', commaIndex + 1) + 1).trim();
form.setFieldValue('address', newAddress);
form.setFieldValue('city', currentCity);
const currentCity = accurateAddress
.substring(commaIndex + 1, accurateAddress.indexOf(',', commaIndex + 1))
.trim()
const newAddress = accurateAddress.substring(accurateAddress.indexOf(',', commaIndex + 1) + 1).trim()
form.setFieldValue('address', newAddress)
form.setFieldValue('city', currentCity)
} else {
const commaIndex = address.indexOf(',')
const currentCity = address.slice(0, commaIndex).trim()
Expand Down Expand Up @@ -104,16 +104,16 @@ const MapComponent = () => {
}

const handleCityChange = (e) => {
const selectedCity = cities.find(city => city.name === e);
const selectedCity = cities.find((city) => city.name === e)

if (selectedCity) {
setMapState({
center: selectedCity.coordinates,
zoom: 12,
});
form.setFieldValue('city', selectedCity.name);
})
form.setFieldValue('city', selectedCity.name)
} else {
console.error('Город не найден');
console.error('Город не найден')
}
}

Expand Down Expand Up @@ -168,4 +168,4 @@ const MapComponent = () => {
)
}

export default MapComponent;
export default MapComponent

0 comments on commit 7f18af1

Please sign in to comment.