Skip to content

Commit

Permalink
fix: fixing some code
Browse files Browse the repository at this point in the history
  • Loading branch information
ionivetech committed Jul 31, 2024
1 parent 620d63b commit 2fb48cb
Show file tree
Hide file tree
Showing 22 changed files with 2,022 additions and 1,895 deletions.
2 changes: 1 addition & 1 deletion app/components/hadith/Card.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
// Interface
import type { IHadithItems } from 'models/IHadith';
import type { IHadithItems } from '@models/IHadith';
// Props
withDefaults(
Expand Down
2 changes: 1 addition & 1 deletion app/components/hadith/HistoryList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { IHadithHistory } from 'models/IHadith'
import type { IHadithHistory } from '@models/IHadith';
// Props
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/header/DetailSurah.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
// Interfaces
import type { ISurah } from 'models/ISurah'
import type { ISurah } from '@models/ISurah';
// Store
const alQuranStore = useAlQuranStore()
Expand Down
2 changes: 1 addition & 1 deletion app/components/modal/Locations.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ILocations } from '~/app/models/ILocation'
import type { ILocations } from '@models/ILocation';
// Show modal
const showModal = defineModel<boolean>()
Expand Down
2 changes: 1 addition & 1 deletion app/components/prayer/List.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
// Interfaces
import type { IPrayer } from '~/app/models/IPrayer'
import type { IPrayer } from '@models/IPrayer';
// Props
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/quran/FavoriteList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
// Interfaces
import type { ISurah } from 'models/ISurah'
import type { ISurah } from '@models/ISurah';
// Props
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/quran/SurahCard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
// Models
import type { ISurah } from 'models/ISurah'
import type { ISurah } from '@models/ISurah';
// Props
const props = defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/quran/VerseList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
// Interfaces
import type { IVerse } from 'models/ISurah'
import type { IVerse } from '@models/ISurah';
// Props
const props = withDefaults(
Expand Down
4 changes: 2 additions & 2 deletions app/components/schedule/Month.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts" setup>
// Interfaces
import type { ISchedule } from '~/app/models/IPrayerTime'
import type { ISchedule } from '@models/IPrayerTime';
defineProps<{
dataSchedule: ISchedule[]
dataSchedule: ISchedule[] | undefined
loading: boolean
}>()
Expand Down
2 changes: 1 addition & 1 deletion app/components/schedule/Today.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
// Variables
import type { IPrayerTime, ISchedule } from '~/app/models/IPrayerTime'
import type { IPrayerTime, ISchedule } from '@models/IPrayerTime';
// Props
defineProps<{
Expand Down
18 changes: 8 additions & 10 deletions app/components/slide/Surah.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
// Interfaces
import type { ISurah } from 'models/ISurah'
import type { ISurah } from '@models/ISurah';
const nuxtApp = useNuxtApp()
Expand All @@ -9,7 +9,7 @@ const showSlideOver = defineModel<boolean>()
// Props
defineProps<{
detailSurah: ISurah | null
detailSurah: ISurah | undefined
}>()
// Emits
Expand All @@ -24,14 +24,12 @@ const router = useRouter()
const search = ref<string>('')
// Get list surah
const { data: surah, pending: pendingFetch } = useAsyncData<ISurah[]>(
'surah',
() => $fetch(ALQURAN_API),
{
getCachedData: (key) => nuxtApp.static.data[key] ?? nuxtApp.payload.data[key],
transform: (data: any) => data.data,
},
)
const { data: surah, pending: pendingFetch } = useLazyFetch<ISurah[]>(ALQURAN_API, {
key: 'surah',
server: false,
getCachedData: (key) => nuxtApp.isHydrating ? nuxtApp.payload.data[key] : nuxtApp.static.data[key],
transform: (data: any) => data.data,
})
// List surah
const surahList = computed((): ISurah[] => {
Expand Down
43 changes: 43 additions & 0 deletions app/models/dto/dataLocation.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
interface LocalityInfo {
administrative: Administrative[];
informative: Informative[];
}

interface Administrative {
name: string;
description: string;
isoName: string;
order: number;
adminLevel: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}

interface Informative {
name: string;
description: string;
isoName?: string;
order: number;
isoCode?: string;
wikidataId?: string;
geonameId?: number;
}

export interface LocationData {
latitude: number;
lookupSource: string;
longitude: number;
localityLanguageRequested: string;
continent: string;
continentCode: string;
countryName: string;
countryCode: string;
principalSubdivision: string;
principalSubdivisionCode: string;
city: string;
locality: string;
postcode: string;
plusCode: string;
localityInfo: LocalityInfo;
}
35 changes: 18 additions & 17 deletions app/pages/al-quran/[id].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
// Interfaces
import type { IBeforeNextSurah, ISurah, IVerse } from 'models/ISurah';
import type { IBeforeNextSurah, ISurah, IVerse } from '@models/ISurah';
interface ITafsir {
ayat: number
teks: string
Expand Down Expand Up @@ -43,7 +43,7 @@ useInfiniteScrolling(
)
// Get detail surah
const { data: dataDetail } = useAsyncData<ISurah>(
const { data: detailSurah, status: statusDetailSurah } = useAsyncData<ISurah>(
'surahDetail',
() => $fetch(`${ALQURAN_API}/${route.params.id}`),
{
Expand Down Expand Up @@ -77,13 +77,13 @@ const setDataChunks = (data: IVerse[]) => {
verseChunk.value.push(chunk)
}
verseList.value = verseChunk.value[0]
verseList.value = verseChunk.value[0] ?? []
finishSetDataChunk.value = true
}
// Open modal tafsir
const handleOpenModalTafsir = (index: number) => {
if (dataTafsir.value) {
if (dataTafsir.value && dataTafsir.value[index]) {
tafsirSelected.value = dataTafsir.value[index]
showModalTafsir.value = true
}
Expand All @@ -105,13 +105,13 @@ const goToSurah = (surah: IBeforeNextSurah) => router.push(`/al-quran/${surah.no
onMounted(() => {
setTimeout(() => {
if (dataDetail.value) setDataChunks(dataDetail.value.ayat!)
if (detailSurah.value) setDataChunks(detailSurah.value.ayat!)
}, 500)
})
useSeoMeta({
title: () => `Surah ${dataDetail.value?.namaLatin} | Islam App`,
description: () => `Detail surah ${dataDetail.value?.namaLatin}`,
title: () => `Surah ${detailSurah.value?.namaLatin} | Islam App`,
description: () => `Detail surah ${detailSurah.value?.namaLatin}`,
})
</script>

Expand All @@ -120,7 +120,7 @@ useSeoMeta({
<div class="relative">
<!-- Header detail surah for show surah name & list surah -->
<HeaderDetailSurah
v-if="route.name === 'al-quran-id' && dataDetail"
v-if="route.name === 'al-quran-id' && detailSurah"
@show-detail="showModalDetail = true"
@show-list="showListSurah = true"
/>
Expand All @@ -141,8 +141,8 @@ useSeoMeta({
<QuranVerseList
v-for="(verse, index) in verseList"
:key="`verse-${verse.nomorAyat}`"
:surah-name="dataDetail?.namaLatin"
:surah-number="dataDetail?.nomor"
:surah-name="detailSurah?.namaLatin"
:surah-number="detailSurah?.nomor"
:verse="verse"
:index="index"
@open-tafsir="handleOpenModalTafsir"
Expand All @@ -152,14 +152,14 @@ useSeoMeta({

<!-- Button prev & next surah -->
<div
v-if="dataDetail"
v-if="detailSurah"
class="mt-12 flex items-center justify-center space-x-3 md:mt-20"
>
<!-- Previous surah -->
<button
v-if="dataDetail.suratSebelumnya"
v-if="detailSurah.suratSebelumnya"
class="btn-prev-next-surah"
@click="goToSurah(dataDetail.suratSebelumnya as IBeforeNextSurah)"
@click="goToSurah(detailSurah.suratSebelumnya as IBeforeNextSurah)"
>
<Icon
name="heroicons:chevron-left-solid"
Expand All @@ -180,9 +180,9 @@ useSeoMeta({

<!-- Next surah -->
<button
v-if="dataDetail.suratSelanjutnya"
v-if="detailSurah.suratSelanjutnya"
class="btn-prev-next-surah"
@click="goToSurah(dataDetail.suratSelanjutnya as IBeforeNextSurah)"
@click="goToSurah(detailSurah.suratSelanjutnya as IBeforeNextSurah)"
>
<span class="hidden sm:block">Surah berikutnya</span>
<span class="block sm:hidden">Berikutnya</span>
Expand All @@ -198,15 +198,16 @@ useSeoMeta({

<!-- List Surah -->
<SlideSurah
v-if="statusDetailSurah === 'success'"
v-model="showListSurah"
:detail-surah="dataDetail"
:detail-surah="detailSurah"
@close-slide="showListSurah = false"
/>

<!-- Modal Detail -->
<ModalDetailSurah
v-model="showModalDetail"
:description="dataDetail?.deskripsi"
:description="detailSurah?.deskripsi"
@close-modal="showModalDetail = false"
/>

Expand Down
34 changes: 13 additions & 21 deletions app/pages/al-quran/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
// Interfaces
import type { ISurah } from 'models/ISurah'
import type { ISurah } from '@models/ISurah';
const nuxtApp = useNuxtApp()
Expand All @@ -11,10 +11,10 @@ const masterSurah = ref<ISurah[]>([])
const surahFavorites = ref<ISurah[]>([])
// Get list surah
const { data: dataSurah, pending: pendingFetch } = useLazyFetch<ISurah[]>(ALQURAN_API, {
const { data: dataSurah, status: statusDataSurah } = useLazyFetch<ISurah[]>(ALQURAN_API, {
key: 'surah',
server: false,
getCachedData: (key) => nuxtApp.static.data[key] ?? nuxtApp.payload.data[key],
getCachedData: (key) => nuxtApp.isHydrating ? nuxtApp.payload.data[key] : nuxtApp.static.data[key],
transform: (data: any) => data.data,
})
Expand All @@ -27,30 +27,22 @@ const surahList = computed((): ISurah[] => {
)
})
// Set data list surah & favorite
const setDataSurahAndFavorites = () => {
surahFavorites.value = useLocalStorage('surah-favorite', []).value
if (dataSurah.value && dataSurah.value.length > 0) {
const favorites = surahFavorites.value.map((surah) => surah.namaLatin.toLowerCase())
const favoritesFromLocalStorage = useLocalStorage('surah-favorite', []).value
const favorites = favoritesFromLocalStorage.map((surah: ISurah) => surah.namaLatin.toLowerCase())
const dataList = dataSurah.value?.map((surah: ISurah) => {
const isFavorite = favorites.includes(surah.namaLatin.toLowerCase())
surah.isFavorite = !!isFavorite
return surah
})
if (surahFavorites.value.length > 0) {
for (const surah of dataList) {
surah.isFavorite = favorites.includes(surah.namaLatin.toLowerCase())
}
}
const dataList = dataSurah.value?.map((surah) => {
const isFavorite = favorites.includes(surah.namaLatin.toLowerCase())
return { ...surah, isFavorite }
})
masterSurah.value = dataList
isLoading.value = false
}
masterSurah.value = dataList ?? []
surahFavorites.value = favoritesFromLocalStorage
isLoading.value = false
}
watchEffect(() => {
if (!pendingFetch.value) setDataSurahAndFavorites()
if (statusDataSurah.value === 'success') setDataSurahAndFavorites()
})
// Meta
Expand Down
Loading

0 comments on commit 2fb48cb

Please sign in to comment.