From 0554717bc676c6b74e9f7c7b967ba48649ef80fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Fri, 8 May 2026 17:17:11 +0300 Subject: [PATCH] =?UTF-8?q?Intranet=20LocationPicker=20d=C3=BCzeltmesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Seeds/LanguagesData.json | 30 +++++++ ui/.env | 19 ++++- ui/src/views/admin/files/FileManager.tsx | 4 +- .../intranet/SocialWall/LocationPicker.tsx | 85 ++++++++++++++----- 4 files changed, 114 insertions(+), 24 deletions(-) diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index 30e40ef..7dd9f88 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -12306,6 +12306,36 @@ "en": "Google Maps could not be loaded. Please check your internet connection.", "tr": "Google Maps yüklenemedi. Lütfen internet bağlantınızı kontrol edin." }, + { + "resourceName": "Platform", + "key": "App.Platform.Intranet.SocialWall.LocationPicker.NoResults", + "en": "No results found", + "tr": "Sonuç bulunamadı" + }, + { + "resourceName": "Platform", + "key": "App.Platform.Intranet.SocialWall.LocationPicker.OverQueryLimit", + "en": "Google Places query limit exceeded. Please try again later.", + "tr": "Google Places sorgu limiti aşıldı. Lütfen daha sonra tekrar deneyiniz." + }, + { + "resourceName": "Platform", + "key": "App.Platform.Intranet.SocialWall.LocationPicker.RequestDenied", + "en": "Google Places request denied. Please check your API key, billing, or permissions settings.", + "tr": "Google Places isteği reddedildi. API key, billing veya yetki ayarlarını kontrol ediniz." + }, + { + "resourceName": "Platform", + "key": "App.Platform.Intranet.SocialWall.LocationPicker.InvalidRequest", + "en": "Invalid location search request. Please check your input and try again.", + "tr": "Geçersiz konum arama isteği." + }, + { + "resourceName": "Platform", + "key": "App.Platform.Intranet.SocialWall.LocationPicker.UnknownError", + "en": "Google Places returned a temporary error. Please try again.", + "tr": "Google Places geçici bir hata döndürdü. Lütfen tekrar deneyiniz." + }, { "resourceName": "Platform", "key": "App.Platform.Intranet.SocialWall.LocationPicker.SearchFailed", diff --git a/ui/.env b/ui/.env index 25df089..c37b558 100644 --- a/ui/.env +++ b/ui/.env @@ -2,4 +2,21 @@ VITE_API_URL='https://localhost:44344' VITE_CDN_URL='http://localhost:4005' VITE_REACT_APP_VERSION=$npm_package_version VITE_AI_URL='https://ai.sozsoft.com/webhook/' -VITE_GOOGLE_MAPS_API_KEY='AIzaSyAefS2rvF-xwq7OHpZ27UYxXPbMo6OwACc' \ No newline at end of file +VITE_GOOGLE_MAPS_API_KEY='AIzaSyAefS2rvF-xwq7OHpZ27UYxXPbMo6OwACc' +# Google Cloud Console’da: + +# APIs & Services > Enabled APIs & services bölümüne gir. +# Şunların aktif olduğundan emin ol: +# Maps JavaScript API +# Places API + +# Eğer ileride koordinat/adres çözümleme yapıyorsan ayrıca: + +# Geocoding API +# APIs & Services > Credentials > API Key içine gir. +# API restrictions bölümünde: + +# Eğer Restrict key seçiliyse, izinli API listesine şunları ekle: + +# Maps JavaScript API +# Places API \ No newline at end of file diff --git a/ui/src/views/admin/files/FileManager.tsx b/ui/src/views/admin/files/FileManager.tsx index 3684fcb..ee06de1 100644 --- a/ui/src/views/admin/files/FileManager.tsx +++ b/ui/src/views/admin/files/FileManager.tsx @@ -1001,7 +1001,7 @@ const FileManager = () => { size="sm" icon={} className={classNames( - 'rounded-r-none border-r px-2 sm:px-3', + 'rounded-r-none border-r ', viewMode === 'grid' && 'bg-blue-50 dark:bg-blue-900/20 text-blue-600', )} onClick={() => setViewMode('grid')} @@ -1012,7 +1012,7 @@ const FileManager = () => { size="sm" icon={} className={classNames( - 'rounded-l-none px-2 sm:px-3', + 'rounded-l-none ', viewMode === 'list' && 'bg-blue-50 dark:bg-blue-900/20 text-blue-600', )} onClick={() => setViewMode('list')} diff --git a/ui/src/views/intranet/SocialWall/LocationPicker.tsx b/ui/src/views/intranet/SocialWall/LocationPicker.tsx index d217a57..ed51212 100644 --- a/ui/src/views/intranet/SocialWall/LocationPicker.tsx +++ b/ui/src/views/intranet/SocialWall/LocationPicker.tsx @@ -29,7 +29,7 @@ declare global { } const LocationPicker: React.FC = ({ onSelect, onClose }) => { - const { translate } = useLocalization(); + const { translate } = useLocalization() const [searchQuery, setSearchQuery] = useState('') const [locations, setLocations] = useState([]) const [selectedLocation, setSelectedLocation] = useState(null) @@ -82,7 +82,7 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => script.src = `https://maps.googleapis.com/maps/api/js?key=${GOOGLE_API_KEY}&libraries=places&language=tr` script.async = true script.defer = true - + script.onload = () => { if (window.google && window.google.maps && window.google.maps.places) { setIsGoogleLoaded(true) @@ -108,6 +108,28 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => searchInputRef.current?.focus() }, []) + const getGooglePlacesErrorMessage = (status: any) => { + switch (status) { + case window.google.maps.places.PlacesServiceStatus.ZERO_RESULTS: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.NoResults') + + case window.google.maps.places.PlacesServiceStatus.OVER_QUERY_LIMIT: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.OverQueryLimit') + + case window.google.maps.places.PlacesServiceStatus.REQUEST_DENIED: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.RequestDenied') + + case window.google.maps.places.PlacesServiceStatus.INVALID_REQUEST: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.InvalidRequest') + + case window.google.maps.places.PlacesServiceStatus.UNKNOWN_ERROR: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.UnknownError') + + default: + return translate('::App.Platform.Intranet.SocialWall.LocationPicker.SearchFailed') + } + } + // Google Places Autocomplete ile konum arama useEffect(() => { if (debounceTimerRef.current) { @@ -134,28 +156,32 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => { input: searchQuery, componentRestrictions: { country: 'tr' }, - language: 'tr' + language: 'tr', }, async (predictions: any, status: any) => { if (status === window.google.maps.places.PlacesServiceStatus.ZERO_RESULTS) { setLocations([]) + setError(getGooglePlacesErrorMessage(status)) setIsLoading(false) return } if (status !== window.google.maps.places.PlacesServiceStatus.OK) { - setError(translate('::App.Platform.Intranet.SocialWall.LocationPicker.SearchFailed')) + setLocations([]) + setError(getGooglePlacesErrorMessage(status)) setIsLoading(false) return } if (!predictions || predictions.length === 0) { setLocations([]) + setError(translate('::App.Platform.Intranet.SocialWall.LocationPicker.NoResults')) setIsLoading(false) return } - // Her bir prediction için detaylı bilgi al + setError(null) + const detailedLocations: LocationData[] = [] let completed = 0 @@ -163,7 +189,7 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => placesServiceRef.current.getDetails( { placeId: prediction.place_id, - fields: ['name', 'formatted_address', 'geometry', 'place_id'] + fields: ['name', 'formatted_address', 'geometry', 'place_id'], }, (place: any, placeStatus: any) => { completed++ @@ -175,19 +201,24 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => address: place.formatted_address, lat: place.geometry.location.lat(), lng: place.geometry.location.lng(), - placeId: place.place_id + placeId: place.place_id, }) } - // Tüm istekler tamamlandıysa state'i güncelle if (completed === predictions.length) { + if (detailedLocations.length === 0) { + setError('Konum detayları alınamadı. API yetkilerini kontrol ediniz.') + } else { + setError(null) + } + setLocations(detailedLocations) setIsLoading(false) } - } + }, ) }) - } + }, ) } catch (err) { console.error('Location search error:', err) @@ -224,7 +255,9 @@ const LocationPicker: React.FC = ({ onSelect, onClose }) => > {/* Header */}
-

{translate('::App.Platform.Intranet.SocialWall.LocationPicker.AddLocation')}

+

+ {translate('::App.Platform.Intranet.SocialWall.LocationPicker.AddLocation')} +