diff --git a/src/frontend/src/ExportedRoutes.js b/src/frontend/src/ExportedRoutes.js index 554fe08c3..83819326e 100644 --- a/src/frontend/src/ExportedRoutes.js +++ b/src/frontend/src/ExportedRoutes.js @@ -48,6 +48,8 @@ import TransactionDetail from "@/modules/Transactions/Transaction.vue" import TransactionList from "@/modules/Transactions/Transactions.vue" import UnauthorizedPage from "@/modules/Unauthorized/index.vue" import AddVillage from "@/modules/Village/AddVillage.vue" +import VillageDetail from "@/modules/Village/VillageDetail.vue" +import VillageList from "@/modules/Village/Villages.vue" import Welcome from "@/modules/Welcome/index.vue" import AfricasTalkingOverview from "@/plugins/africas-talking/modules/Overview/Overview.vue" import AngazaShsOverview from "@/plugins/angaza-shs/modules/Overview/Overview.vue" @@ -457,6 +459,45 @@ export const exportedRoutes = [ }, ], }, + { + path: "/villages", + component: ChildRouteWrapper, + meta: { + permissions: ["settings"], + sidebar: { + enabled: true, + name: "Villages", + icon: "location_city", + }, + }, + children: [ + { + path: "", + component: VillageList, + meta: { + layout: "default", + breadcrumb: { + level: "base", + name: "Villages", + link: "/villages", + }, + }, + }, + { + path: ":id", + component: VillageDetail, + meta: { + layout: "default", + breadcrumb: { + level: "detail", + name: "Villages", + link: "/villages", + target: "id", + }, + }, + }, + ], + }, { path: "/transactions", component: ChildRouteWrapper, diff --git a/src/frontend/src/assets/locales/ar.json b/src/frontend/src/assets/locales/ar.json index 3897e791f..696342e9b 100644 --- a/src/frontend/src/assets/locales/ar.json +++ b/src/frontend/src/assets/locales/ar.json @@ -40,6 +40,7 @@ "Tariffs": "التعريفات", "Tickets": "التذاكر", "Transactions": "المعاملات", + "Villages": "القرى", "Viber Messaging": "مراسلة فايبر", "WaveMoney": "ويف موني", "Wavecom Payment Provider": "مزود الدفع ويفكوم", diff --git a/src/frontend/src/assets/locales/bu.json b/src/frontend/src/assets/locales/bu.json index e7167e71a..ccb79548f 100644 --- a/src/frontend/src/assets/locales/bu.json +++ b/src/frontend/src/assets/locales/bu.json @@ -40,6 +40,7 @@ "Tariffs": "Jှ+နး်ထားများ", "Tickets": "ကွနပ်လိနး်များ", "Transactions": "ေငေွပးေငယွ ူ", + "Villages": "ေကျးရွာများ", "Viber Messaging": "Viber Messaging", "WaveMoney": "Wave Money", "Wavecom Payment Provider": "Wavecom Payment Provider", diff --git a/src/frontend/src/assets/locales/en.json b/src/frontend/src/assets/locales/en.json index 4920e897e..bf3387aa6 100644 --- a/src/frontend/src/assets/locales/en.json +++ b/src/frontend/src/assets/locales/en.json @@ -40,6 +40,7 @@ "Tariffs": "Tariffs", "Tickets": "Tickets", "Transactions": "Transactions", + "Villages": "Villages", "Viber Messaging": "Viber Messaging", "WaveMoney": "Wave Money", "Wavecom Payment Provider": "Wavecom Payment Provider", diff --git a/src/frontend/src/assets/locales/fr.json b/src/frontend/src/assets/locales/fr.json index db9b9dfec..b5b38d821 100644 --- a/src/frontend/src/assets/locales/fr.json +++ b/src/frontend/src/assets/locales/fr.json @@ -40,6 +40,7 @@ "Tariffs": "Tariffs", "Tickets": "Tickets", "Transactions": "Transactions", + "Villages": "Villages", "Viber Messaging": "Viber Messaging", "WaveMoney": "Wave Money", "Wavecom Payment Provider": "Wavecom Payment Provider", diff --git a/src/frontend/src/modules/Village/VillageDetail.vue b/src/frontend/src/modules/Village/VillageDetail.vue new file mode 100644 index 000000000..34a48d62e --- /dev/null +++ b/src/frontend/src/modules/Village/VillageDetail.vue @@ -0,0 +1,229 @@ + + + + + + + + + {{ $tc("words.name") }} + + + {{ errors.first("village-detail-form.name") }} + + + + + + + {{ $tc("words.country") }} + + + {{ country.name || country.country_name }} + + + + {{ errors.first("village-detail-form.country") }} + + + + + + + {{ $tc("words.miniGrid") }} + + + {{ miniGrid.name }} + + + + {{ errors.first("village-detail-form.mini_grid") }} + + + + + + + {{ $tc("words.location") }} + + + + + + + + + {{ $tc("words.save") }} + + + {{ $tc("words.close") }} + + + + + + + + + + + diff --git a/src/frontend/src/modules/Village/Villages.vue b/src/frontend/src/modules/Village/Villages.vue new file mode 100644 index 000000000..b207aa2bf --- /dev/null +++ b/src/frontend/src/modules/Village/Villages.vue @@ -0,0 +1,102 @@ + + + + + + {{ $tc("words.id") }} + {{ $tc("words.name") }} + {{ $tc("words.country") }} + {{ $tc("words.miniGrid") }} + {{ $tc("words.location") }} + {{ $tc("phrases.lastUpdate") }} + + + {{ village.id }} + {{ village.name }} + {{ getCountryName(village.country_id) }} + {{ getMiniGridName(village.mini_grid_id) }} + {{ village.location?.points || "-" }} + {{ timeForTimeZone(village.updated_at) }} + + + + + + + + + diff --git a/src/frontend/src/repositories/CityRepository.js b/src/frontend/src/repositories/CityRepository.js index fac27a0fa..3f9b8f8ef 100644 --- a/src/frontend/src/repositories/CityRepository.js +++ b/src/frontend/src/repositories/CityRepository.js @@ -6,7 +6,14 @@ export default { list() { return Client.get(`${resource}`) }, + detail(cityId, withRelation = false) { + const query = withRelation ? "?relation=1" : "" + return Client.get(`${resource}/${cityId}${query}`) + }, create(city) { return Client.post(`${resource}`, city) }, + update(cityId, city) { + return Client.put(`${resource}/${cityId}`, city) + }, } diff --git a/src/frontend/src/services/CityService.js b/src/frontend/src/services/CityService.js index 14d224269..40d7ffed3 100644 --- a/src/frontend/src/services/CityService.js +++ b/src/frontend/src/services/CityService.js @@ -116,4 +116,33 @@ export class CityService { return new ErrorHandler(errorMessage, "http") } } + + async getCity(cityId, withRelation = false) { + try { + const { data, status, error } = await this.repository.detail( + cityId, + withRelation, + ) + if (status !== 200) return new ErrorHandler(error, "http", status) + this.city = data.data + return this.city + } catch (e) { + const errorMessage = e.response.data.message + return new ErrorHandler(errorMessage, "http") + } + } + + async updateCity(cityId, cityData) { + try { + const params = convertObjectKeysToSnakeCase(cityData) + const { data, status, error } = await this.repository.update(cityId, params) + if (status !== 200 && status !== 201) + return new ErrorHandler(error, "http", status) + this.city = data.data + return this.city + } catch (e) { + const errorMessage = e.response.data.message + return new ErrorHandler(errorMessage, "http") + } + } }