From f4798f304c52572495dc64d8ce7d495b676e170f Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 23 May 2024 18:01:40 +0200 Subject: [PATCH] feat(search bar): alert 'invalid subplebbit address' if the user forgot to type the tld --- public/translations/ar/default.json | 3 ++- public/translations/bn/default.json | 3 ++- public/translations/cs/default.json | 3 ++- public/translations/da/default.json | 3 ++- public/translations/de/default.json | 3 ++- public/translations/el/default.json | 3 ++- public/translations/en/default.json | 3 ++- public/translations/es/default.json | 3 ++- public/translations/fa/default.json | 3 ++- public/translations/fi/default.json | 3 ++- public/translations/fil/default.json | 3 ++- public/translations/fr/default.json | 3 ++- public/translations/he/default.json | 3 ++- public/translations/hi/default.json | 3 ++- public/translations/hu/default.json | 3 ++- public/translations/id/default.json | 3 ++- public/translations/it/default.json | 3 ++- public/translations/ja/default.json | 3 ++- public/translations/ko/default.json | 3 ++- public/translations/mr/default.json | 3 ++- public/translations/nl/default.json | 3 ++- public/translations/no/default.json | 3 ++- public/translations/pl/default.json | 3 ++- public/translations/pt/default.json | 3 ++- public/translations/ro/default.json | 3 ++- public/translations/ru/default.json | 3 ++- public/translations/sq/default.json | 3 ++- public/translations/sv/default.json | 3 ++- public/translations/te/default.json | 3 ++- public/translations/th/default.json | 3 ++- public/translations/tr/default.json | 3 ++- public/translations/uk/default.json | 3 ++- public/translations/ur/default.json | 3 ++- public/translations/vi/default.json | 3 ++- public/translations/zh/default.json | 3 ++- src/app.tsx | 2 +- src/components/search-bar/search-bar.tsx | 5 +++++ 37 files changed, 76 insertions(+), 36 deletions(-) diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index d146c6c7..1437c5c8 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -303,5 +303,6 @@ "show": "اظهر", "plebbit_options": "خيارات plebbit", "general": "عام", - "own_communities": "المجتمعات الخاصة بي" + "own_communities": "المجتمعات الخاصة بي", + "invalid_community_address": "عنوان المجتمع غير صالح" } \ No newline at end of file diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index 08c3dda6..dac44a14 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -303,5 +303,6 @@ "show": "দেখান", "plebbit_options": "প্লেবিট বিকল্প", "general": "সাধারণ", - "own_communities": "নিজস্ব সম্প্রদায়" + "own_communities": "নিজস্ব সম্প্রদায়", + "invalid_community_address": "অবৈধ সম্প্রদায় ঠিকানা" } \ No newline at end of file diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index 6db59c80..df1be12c 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -303,5 +303,6 @@ "show": "ukázat", "plebbit_options": "plebbit možnosti", "general": "obecné", - "own_communities": "vlastní komunity" + "own_communities": "vlastní komunity", + "invalid_community_address": "Neplatná adresa komunity" } \ No newline at end of file diff --git a/public/translations/da/default.json b/public/translations/da/default.json index 95197a07..54f40e11 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -303,5 +303,6 @@ "show": "vise", "plebbit_options": "plebbit indstillinger", "general": "almindelig", - "own_communities": "egne fællesskaber" + "own_communities": "egne fællesskaber", + "invalid_community_address": "Ugyldig fællesskabsadresse" } \ No newline at end of file diff --git a/public/translations/de/default.json b/public/translations/de/default.json index 7af80197..75c82c90 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -303,5 +303,6 @@ "show": "zeigen", "plebbit_options": "plebbit optionen", "general": "allgemein", - "own_communities": "eigene Gemeinschaften" + "own_communities": "eigene Gemeinschaften", + "invalid_community_address": "Ungültige Gemeindeadresse" } \ No newline at end of file diff --git a/public/translations/el/default.json b/public/translations/el/default.json index 709d0982..c2d50198 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -303,5 +303,6 @@ "show": "εμφάνιση", "plebbit_options": "επιλογές plebbit", "general": "γενικός", - "own_communities": "δικές μου κοινότητες" + "own_communities": "δικές μου κοινότητες", + "invalid_community_address": "Μη έγκυρη διεύθυνση κοινότητας" } \ No newline at end of file diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 803a822d..f8b44050 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -303,5 +303,6 @@ "show": "show", "plebbit_options": "plebbit options", "general": "general", - "own_communities": "own communities" + "own_communities": "own communities", + "invalid_community_address": "Invalid community address" } \ No newline at end of file diff --git a/public/translations/es/default.json b/public/translations/es/default.json index 8443369e..4feddba4 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -303,5 +303,6 @@ "show": "mostrar", "plebbit_options": "opciones plebbit", "general": "general", - "own_communities": "comunidades propias" + "own_communities": "comunidades propias", + "invalid_community_address": "Dirección de comunidad no válida" } \ No newline at end of file diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index 4dc44161..4f00f52b 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -303,5 +303,6 @@ "show": "نمایش", "plebbit_options": "گزینه های plebbit", "general": "عمومی", - "own_communities": "انجمن‌های خودم" + "own_communities": "انجمن‌های خودم", + "invalid_community_address": "آدرس انجمن نامعتبر است" } \ No newline at end of file diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index 4743ab81..2da6b41b 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -303,5 +303,6 @@ "show": "näyttää", "plebbit_options": "plebbit-vaihtoehdot", "general": "yleinen", - "own_communities": "omat yhteisöt" + "own_communities": "omat yhteisöt", + "invalid_community_address": "Virheellinen yhteisön osoite" } \ No newline at end of file diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index 8ac721fa..98f1945e 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -303,5 +303,6 @@ "show": "ipakita", "plebbit_options": "mga pagpipilian ng plebbit", "general": "pangkalahatan", - "own_communities": "sariling mga pamayanan" + "own_communities": "sariling mga pamayanan", + "invalid_community_address": "Hindi wastong address ng pamayanan" } \ No newline at end of file diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index 8dddb11e..9da034b3 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -303,5 +303,6 @@ "show": "montrer", "plebbit_options": "options plebbit", "general": "général", - "own_communities": "communautés propres" + "own_communities": "communautés propres", + "invalid_community_address": "Adresse de la communauté non valide" } \ No newline at end of file diff --git a/public/translations/he/default.json b/public/translations/he/default.json index 3e79849c..f22ac893 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -303,5 +303,6 @@ "show": "תצוגה", "plebbit_options": "אפשרויות plebbit", "general": "כללי", - "own_communities": "הקהילות שלי" + "own_communities": "הקהילות שלי", + "invalid_community_address": "כתובת הקהילה אינה חוקית" } \ No newline at end of file diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index dfe1bf01..7f4db9ee 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -303,5 +303,6 @@ "show": "दिखाएँ", "plebbit_options": "plebbit विकल्प", "general": "सामान्य", - "own_communities": "खुद की समुदायें" + "own_communities": "खुद की समुदायें", + "invalid_community_address": "अमान्य समुदाय पता" } \ No newline at end of file diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index 04dcfd28..c686121d 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -303,5 +303,6 @@ "show": "mutat", "plebbit_options": "plebbit lehetőségek", "general": "általános", - "own_communities": "saját közösségek" + "own_communities": "saját közösségek", + "invalid_community_address": "Érvénytelen közösségi cím" } \ No newline at end of file diff --git a/public/translations/id/default.json b/public/translations/id/default.json index 347a6e08..725e3a84 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -303,5 +303,6 @@ "show": "menunjukkan", "plebbit_options": "opsi plebbit", "general": "umum", - "own_communities": "komunitas sendiri" + "own_communities": "komunitas sendiri", + "invalid_community_address": "Alamat komunitas tidak valid" } \ No newline at end of file diff --git a/public/translations/it/default.json b/public/translations/it/default.json index c7628d73..5a869e76 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -303,5 +303,6 @@ "show": "mostra", "plebbit_options": "opzioni plebbit", "general": "generali", - "own_communities": "comunità che possiedo" + "own_communities": "comunità che possiedo", + "invalid_community_address": "Indirizzo comunità non valido" } \ No newline at end of file diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 6a6d3e94..783f9629 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -303,5 +303,6 @@ "show": "表示", "plebbit_options": "plebbitのオプション", "general": "一般的な", - "own_communities": "自分のコミュニティ" + "own_communities": "自分のコミュニティ", + "invalid_community_address": "無効なコミュニティアドレス" } \ No newline at end of file diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index 3b575b52..3d042d85 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -303,5 +303,6 @@ "show": "보여주다", "plebbit_options": "plebbit 옵션", "general": "일반", - "own_communities": "나의 커뮤니티" + "own_communities": "나의 커뮤니티", + "invalid_community_address": "잘못된 커뮤니티 주소" } \ No newline at end of file diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index 2b9afe0a..6af94f8a 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -303,5 +303,6 @@ "show": "दाखवा", "plebbit_options": "प्लेबिट पर्याय", "general": "सामान्य", - "own_communities": "स्वत: समुदाये" + "own_communities": "स्वत: समुदाये", + "invalid_community_address": "अवैध समुदाय पत्ता" } \ No newline at end of file diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index 8cef5c4b..4fb9c5ae 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -303,5 +303,6 @@ "show": "tonen", "plebbit_options": "plebbit-opties", "general": "algemeen", - "own_communities": "eigen gemeenschappen" + "own_communities": "eigen gemeenschappen", + "invalid_community_address": "Ongeldig gemeenschapsadres" } \ No newline at end of file diff --git a/public/translations/no/default.json b/public/translations/no/default.json index 9a5da4e2..cdda3f88 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -303,5 +303,6 @@ "show": "vise", "plebbit_options": "plebbit alternativer", "general": "generell", - "own_communities": "egne fellesskap" + "own_communities": "egne fellesskap", + "invalid_community_address": "Ugyldig fellesskapsadresse" } \ No newline at end of file diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 84aef444..0d14a53c 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -303,5 +303,6 @@ "show": "pokazać", "plebbit_options": "opcje plebbit", "general": "ogólny", - "own_communities": "własne społeczności" + "own_communities": "własne społeczności", + "invalid_community_address": "Nieprawidłowy adres społeczności" } \ No newline at end of file diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 7b856031..f95a86ad 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -303,5 +303,6 @@ "show": "mostrar", "plebbit_options": "opções plebbit", "general": "geral", - "own_communities": "comunidades próprias" + "own_communities": "comunidades próprias", + "invalid_community_address": "Endereço da comunidade inválido" } \ No newline at end of file diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index f8936269..bd3b1035 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -303,5 +303,6 @@ "show": "arată", "plebbit_options": "opțiuni plebbit", "general": "general", - "own_communities": "comunități proprii" + "own_communities": "comunități proprii", + "invalid_community_address": "Adresă comunitară nevalidă" } \ No newline at end of file diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index 0f251866..b4d320d8 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -303,5 +303,6 @@ "show": "показать", "plebbit_options": "опции plebbit", "general": "общий", - "own_communities": "собственные сообщества" + "own_communities": "собственные сообщества", + "invalid_community_address": "Недействительный адрес сообщества" } \ No newline at end of file diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index 0efa1026..3144682c 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -303,5 +303,6 @@ "show": "shfaq", "plebbit_options": "opsione plebbit", "general": "i përgjithshëm", - "own_communities": "komunitete të mia" + "own_communities": "komunitete të mia", + "invalid_community_address": "Adresa e komunitetit e pavlefshme" } \ No newline at end of file diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index fe279cb2..fd9c4e74 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -303,5 +303,6 @@ "show": "visa", "plebbit_options": "plebbit-alternativ", "general": "allmän", - "own_communities": "egna samhällen" + "own_communities": "egna samhällen", + "invalid_community_address": "Ogiltig samhällsadress" } \ No newline at end of file diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 01e9c748..37709d95 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -303,5 +303,6 @@ "show": "చూపించు", "plebbit_options": "plebbit ఎంపికలు", "general": "సాధారణ", - "own_communities": "నా సముదాయాలు" + "own_communities": "నా సముదాయాలు", + "invalid_community_address": "అమాన్యమైన సముదాయ చిరునామా" } \ No newline at end of file diff --git a/public/translations/th/default.json b/public/translations/th/default.json index f46b3bde..d22a40f0 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -303,5 +303,6 @@ "show": "แสดง", "plebbit_options": "ตัวเลือก plebbit", "general": "ทั่วไป", - "own_communities": "ชุมชนของฉัน" + "own_communities": "ชุมชนของฉัน", + "invalid_community_address": "ที่อยู่ชุมชนไม่ถูกต้อง" } \ No newline at end of file diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index efde2ecd..6aaf6daa 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -303,5 +303,6 @@ "show": "göstermek", "plebbit_options": "plebbit seçenekleri", "general": "genel", - "own_communities": "kendi topluluklarım" + "own_communities": "kendi topluluklarım", + "invalid_community_address": "Geçersiz topluluk adresi" } \ No newline at end of file diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index 9da4132e..eb8de81d 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -303,5 +303,6 @@ "show": "показати", "plebbit_options": "плебіт варіанти", "general": "загальний", - "own_communities": "власні спільноти" + "own_communities": "власні спільноти", + "invalid_community_address": "Недійсна адреса спільноти" } \ No newline at end of file diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index d3fe3d9c..a9acf943 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -303,5 +303,6 @@ "show": "دکھائیں", "plebbit_options": "پلیبٹ اختیارات", "general": "عام", - "own_communities": "اپنی کمیونٹیاں" + "own_communities": "اپنی کمیونٹیاں", + "invalid_community_address": "غیر درست مجتمع کا پتہ" } \ No newline at end of file diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index 983dff8d..82b949dd 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -303,5 +303,6 @@ "show": "hiển thị", "plebbit_options": "tùy chọn plebbit", "general": "chung", - "own_communities": "cộng đồng của riêng tôi" + "own_communities": "cộng đồng của riêng tôi", + "invalid_community_address": "Địa chỉ cộng đồng không hợp lệ" } \ No newline at end of file diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index 4293737a..9ed2ecf8 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -303,5 +303,6 @@ "show": "显示", "plebbit_options": "plebbit选项", "general": "一般", - "own_communities": "自己的社区" + "own_communities": "自己的社区", + "invalid_community_address": "无效的社区地址" } \ No newline at end of file diff --git a/src/app.tsx b/src/app.tsx index fcea846f..ed1ea7de 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -30,7 +30,7 @@ const CheckRouteParams = () => { const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0); const isValidCommentCid = !commentCid || /^Qm[a-zA-Z0-9]{44}$/.test(commentCid); - const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3K[a-zA-Z0-9]{44}$/.test(subplebbitAddress); + const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3KooW[a-zA-Z0-9]{44}$/.test(subplebbitAddress); const isSortTypeValid = !sortType || sortTypes.includes(sortType); const isTimeFilterNameValid = !timeFilterName || timeFilterNames.includes(timeFilterName as any); const isAccountCommentIndexValid = !accountCommentIndex || !isNaN(parseInt(accountCommentIndex)); diff --git a/src/components/search-bar/search-bar.tsx b/src/components/search-bar/search-bar.tsx index da9177e7..f8f4e62d 100644 --- a/src/components/search-bar/search-bar.tsx +++ b/src/components/search-bar/search-bar.tsx @@ -50,6 +50,11 @@ const SearchBar = ({ isFocused = false }: SearchBarProps) => { } const searchInput = searchInputRef.current?.value; if (searchInput) { + const isValidSubplebbitAddress = searchInput.includes('.') || /^12D3KooW[a-zA-Z0-9]{44}$/.test(searchInput); + if (!isValidSubplebbitAddress) { + alert(t('invalid_community_address')); + return; + } searchInputRef.current.value = ''; navigate(`/p/${searchInput}`); }