Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "org.commitglobal.votemonitor",
"buildNumber": "112",
"buildNumber": "113",
"config": {
"usesNonExemptEncryption": false
},
Expand All @@ -31,7 +31,7 @@
},
"android": {
"softwareKeyboardLayoutMode": "pan",
"versionCode": 116,
"versionCode": 117,
"adaptiveIcon": {
"foregroundImage": "./assets/icons/adaptive-icon.png",
"backgroundColor": "#FDD20C"
Expand Down
30 changes: 10 additions & 20 deletions mobile/app/(observer)/(app)/(drawer)/(tabs)/(observation)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import * as Clipboard from "expo-clipboard";
import { router, useNavigation } from "expo-router";
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import {
Popup
} from 'react-native-map-link';
import { Popup } from "react-native-map-link";
import Toast from "react-native-toast-message";
import { YStack } from "tamagui";
import Header from "../../../../../../components/Header";
Expand Down Expand Up @@ -63,22 +61,14 @@ const Index = () => {
.filter(Boolean)
.join(" ");

return {
address: fullAddress,
latitude: selectedPollingStation.latitude,
longitude: selectedPollingStation.longitude,
dialogTitle: "dialog title",
dialogMessage: "dialog message",
cancelText: "cancel",
}

// address: fullAddress,
// latitude: selectedPollingStation.latitude,
// longitude: selectedPollingStation.longitude,
// dialogTitle: "dialog title",
// dialogMessage: "dialog message",
// cancelText: "cancel",
// });
return {
address: fullAddress,
latitude: selectedPollingStation.latitude,
longitude: selectedPollingStation.longitude,
dialogTitle: t("navigate_to_polling_station.title"),
dialogMessage: t("navigate_to_polling_station.description"),
cancelText: t("navigate_to_polling_station.actions.cancel"),
};
}, [selectedPollingStation, visits]);

const handleCopyPollingStationInfo = async () => {
Expand Down Expand Up @@ -179,7 +169,7 @@ const Index = () => {
</OptionsSheet>
)}

<Popup
<Popup
isVisible={openSelectNavigationAppSheet}
setIsVisible={setOpenSelectNavigationAppSheet}
onCancelPressed={() => setOpenSelectNavigationAppSheet(false)}
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/az/translations_AZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@
"copy_success_toast": "Seçki məntəqəsi məlumatları mübadilə buferinə kopyalandı",
"copy_error_toast": "Seçki məntəqəsi məlumatlarını kopyalamaq mümkün olmadı",
"navigate_to_polling_station": "Seçki məntəqəsinə keçid et"
},
"navigate_to_polling_station": {
"title": "Seçki məntəqəsinə keçid et",
"description": "Seçki məntəqəsinə istiqamətləri almaq üçün tətbiq seçin.",
"cancel": "Ləğv etmək"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/bg/translations_BG.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@
"form_details_button_label": "Информация за изборната секция",
"number_of_questions": "{{value}} въпроса",
"answer_questions": "Отговорете на въпросите"
},
"navigate_to_polling_station": {
"title": "Преминаване до избирателната секция",
"description": "Изберете приложение, за да получите упътвания до избирателната секция",
"cancel": "Откажете"
}
},
"forms": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/de/translations_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
"copy_success_toast": "Die Details zum Wahllokal wurden in die Zwischenablage kopiert",
"copy_error_toast": "Die Details zum Wahllokal konnten nicht kopiert werden",
"navigate_to_polling_station": "Zur Wahllokal-Ansicht wechseln"
},
"navigate_to_polling_station": {
"title": "Zum Wahllokal navigieren",
"description": "Wählen Sie eine Karten-App, um eine Wegbeschreibung zum Wahllokal zu erhalten.",
"cancel": "Abbrechen"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
"copy_success_toast": "Polling station details was copied to clipboard",
"copy_error_toast": "Failed to copy polling station details",
"navigate_to_polling_station": "Navigate to polling station"
},
"navigate_to_polling_station": {
"title": "Navigate to polling station",
"description": "Select a map app to get directions to the polling station.",
"cancel": "Cancel"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/es/translations_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@
"copy_success_toast": "Los detalles de la estación de votación se copiaron al portapapeles",
"copy_error_toast": "No se pudieron copiar los detalles de la estación de votación",
"navigate_to_polling_station": "Navegar a la estación de votación"
},
"navigate_to_polling_station": {
"title": "Navegar a la estación de votación",
"description": "Seleccione una aplicación para obtener indicaciones para llegar al centro de votación.",
"cancel": "Cancelar"
}
},
"polling_station_information_form": {
Expand Down
7 changes: 6 additions & 1 deletion mobile/assets/locales/hy/translations_HY.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,17 @@
"error": "Խնդրում ենք ընտրել տարբերակներից մեկը"
}
},
"options_menu": {
"options_menu": {
"manage_my_polling_stations": "Կառավարել իմ ընտրատեղամասերը",
"copy_polling_station_information": "Պատճենել ընտրատեղամասի տվյալները սեղմատախտակին",
"copy_success_toast": "Ընտրատեղամասի տվյալները պատճենվել են սեղմատախտակին",
"copy_error_toast": "Չհաջողվեց պատճենել ընտրատեղամասի տվյալները",
"navigate_to_polling_station": "Ուղղորդվել դեպի ընտրատեղամաս"
},
"navigate_to_polling_station": {
"title": "Ուղղորդվել դեպի ընտրատեղամաս",
"description": "Ընտրեք հավելված՝ ընտրատեղամաս տանող ուղղությունները ստանալու համար:",
"cancel": "Չեղարկել"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/ka/translations_KA.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@
"copy_success_toast": "საარჩევნო უბნის დეტალები ბუფერში დაკოპირდა",
"copy_error_toast": "საარჩევნო უბნის დეტალების კოპირება ვერ მოხერხდა",
"navigate_to_polling_station": "საარჩევნო უბნაზე გადასვლა"
},
"navigate_to_polling_station": {
"title": "საარჩევნო უბნაზე გადასვლა",
"description": "აირჩიეთ რუკის აპი საარჩევნო უბნაზე გადასვლისთვის.",
"cancel": "გაუქმება"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/pl/translations_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@
"copy_success_toast": "Dane komisji wyborczej zostały skopiowane do schowka",
"copy_error_toast": "Nie udało się skopiować danych komisji wyborczej",
"navigate_to_polling_station": "Przejść do komisji wyborczej"
},
"navigate_to_polling_station": {
"title": "Przejść do lokalu wyborczego",
"description": "Wybierz aplikację, aby uzyskać wskazówki dojazdu do lokalu wyborczego.",
"cancel": "Anuluj"
}
},
"shit, you in the Polish numbers trap": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/ro/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
"copy_success_toast": "Detaliile secției de votare au fost copiate în clipboard",
"copy_error_toast": "Nu s-au putut copia detaliile secției de votare",
"navigate_to_polling_station": "Navighează către secția de votare"
},
"navigate_to_polling_station": {
"title": "Navighează către secția de votare",
"description": "Selectați o aplicație pentru a obține indicații către secția de votare.",
"cancel": "Renunță"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/ru/translations_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@
"copy_success_toast": "Данные избирательного участка скопированы в буфер обмена",
"copy_error_toast": "Не удалось скопировать данные избирательного участка",
"navigate_to_polling_station": "Перейти к избирательному участку"
},
"navigate_to_polling_station": {
"title": "Перейти к избирательному участку",
"description": "Выберите приложение, чтобы проложить маршрут до избирательного участка.",
"cancel": "Отмена"
}
},
"polling_station_information_form": {
Expand Down
5 changes: 5 additions & 0 deletions mobile/assets/locales/sr/translations_SR.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@
"form_details_button_label": "Informacije o biračkom mestu.",
"number_of_questions": "{{value}} pitanja",
"answer_questions": "Odgovorite na pitanja"
},
"navigate_to_polling_station": {
"title": "Navegacija na biračko mesto",
"description": "Изаберите апликацију да бисте добили упутства до бирачког места.",
"cancel": "Otkaži"
}
},
"forms": {
Expand Down
71 changes: 63 additions & 8 deletions mobile/components/PollingStationGeneral.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { router } from "expo-router";
import { YStack } from "tamagui";
import PollingStationInfo from "./PollingStationInfo";
import PollingStationInfoDefault from "./PollingStationInfoDefault";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { XStack, YStack } from "tamagui";
import { getFormLanguagePreference, setFormLanguagePreference } from "../common/language.preferences";
import {
PollingStationInformationAPIResponse,
PollingStationInformationFormAPIResponse,
} from "../services/definitions.api";
import CardFooter from "./CardFooter";
import Button from "./Button";
import Card from "./Card";
import { useTranslation } from "react-i18next";
import { Typography } from "./Typography";
import CardFooter from "./CardFooter";
import { Dialog } from "./Dialog";
import PollingStationInfo from "./PollingStationInfo";
import PollingStationInfoDefault from "./PollingStationInfoDefault";
import { PSITime } from "./PSITime";
import { getFormLanguagePreference, setFormLanguagePreference } from "../common/language.preferences";
import SelectFormLanguageDialogContent from "./SelectFormLanguageDialogContent";
import { Typography } from "./Typography";
import { useState } from "react";
import { deleteSecureStoreItemAsync } from "../helpers/SecureStoreWrapper";
Comment thread Fixed

interface PollingStationGeneralProps {
psiData: PollingStationInformationAPIResponse | null | undefined;
Expand All @@ -23,8 +29,10 @@
psiFormQuestions,
}) => {
const { t } = useTranslation("observation");
const [displayLanguageDialog, setDisplayLanguageDialog] = useState<boolean>(false);

const onConfirmFormLanguage = (language: string) => {
setDisplayLanguageDialog(false);
setFormLanguagePreference({ formId: psiFormQuestions.id, language });

router.push(
Expand All @@ -34,7 +42,6 @@

const openForm = async () => {
if (!psiFormQuestions?.languages?.length) {
// TODO: Display error toast
console.log("No language exists");
}

Expand All @@ -44,9 +51,17 @@
onConfirmFormLanguage( preferedLanguage);
} else if (psiFormQuestions?.languages?.length === 1) {
onConfirmFormLanguage(psiFormQuestions.languages[0]);
} else {
setDisplayLanguageDialog(true);
}
};

const {
control,
handleSubmit,
formState: { errors },
} = useForm({});


return (
<YStack gap="$xxs">
Expand Down Expand Up @@ -75,6 +90,46 @@
></CardFooter>
</Card>
)}

{displayLanguageDialog && (
<Controller
key={psiFormQuestions.id}
name={'psi'}
control={control}
rules={{
required: { value: true, message: t("forms.select_language_modal.error") },
}}
render={({ field: { onChange, value } }) => (
<Dialog
open={displayLanguageDialog}
header={
<Typography preset="heading">{t("forms.select_language_modal.header")}</Typography>
}
content={
<SelectFormLanguageDialogContent
languages={psiFormQuestions.languages}
error={errors.psi}
value={value}
onChange={onChange}
/>
}
footer={
<XStack gap="$md">
<Button preset="chromeless" onPress={setDisplayLanguageDialog.bind(null, false)}>
{t("cancel", { ns: "common" })}
</Button>
<Button
onPress={handleSubmit(() => onConfirmFormLanguage(value))}
flex={1}
>
{t("save", { ns: "common" })}
</Button>
</XStack>
}
/>
)}
/>
)}
</YStack>
);
};
2 changes: 1 addition & 1 deletion mobile/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { setAuthTokens } from "../helpers/authTokensSetter";
* - Redirects to login
*/

const API_BASE_URL = process.env.EXPO_PUBLIC_API_BASE_URL;
const API_BASE_URL = 'https://api.votemonitor.org/api/';

const TIMEOUT = 60 * 1000; // 60 seconds

Expand Down
Loading