Skip to content

Commit

Permalink
fix: bugs in menu books and url read
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus64 committed Dec 21, 2023
1 parent 2756d51 commit ead9640
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
15 changes: 9 additions & 6 deletions src/components/StudyChapter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
}
onMount(async () => {
info = await getData()
chapters = info.num_chapters
})
Expand All @@ -79,17 +80,19 @@
}
chapters = bookInfo.chapters
const p = $page.url
loading = true
const resp = await fetch(
`https://bible-api.deno.dev/api/${versionRead === '' ? 'rv1960' : versionRead}/book/${searchName(
`https://bible-api.deno.dev/api/read/${versionRead === '' ? 'rv1960' : versionRead}/book/${searchName(
book
)}/${chapter}`
)
if (!resp.ok) {
loading = false
hasError = true
const errorJson = await resp.json()
error =
'No se encontro el capitulo, intentelo mas tarde o revise que sea correcta su busqueda'
Expand Down Expand Up @@ -118,7 +121,7 @@
localStorage.setItem(
'bookmark',
JSON.stringify({
versionRead,
version: versionRead,
chapter,
book
})
Expand Down Expand Up @@ -297,7 +300,7 @@
<section class="flex flex-col justify-between gap-4 sm:flex-row sm:items-center sm:gap-12">
<div class="flex items-center gap-3">
<div use:clickOutside on:click_outside={() => (selectversionRead = false)}>
<h4>versionRead</h4>
<h4>versión</h4>
<Button
disabled={loading}
color="green"
Expand Down Expand Up @@ -344,7 +347,7 @@
</Button>

{#if selectBook}
<dialog class="max-lg:max-w-[50rem] max-lg:top-[80%] max-h-[30rem] flex flex-wrap books-dialog p-4 overflow-auto rounded-lg bg-gray-100 dark:text-white gap-3 dark:bg-[#283248]" >
<dialog class="max-lg:max-w-[50rem] max-lg:top-[80%] max-h-[30rem] flex flex-wrap books-dialog p-4 overflow-auto rounded-lg bg-gray-100 dark:text-white gap-3 dark:bg-[#283248]" >
{#each books as b}
<button
class="select-none p-2 transition-shadow bg-[#a8cae8] hover:bg-[#7faddb] hover:shadow- rounded-sm dark:bg-[#4366b2] dark:hover:bg-blue-600"
Expand Down Expand Up @@ -384,7 +387,7 @@
${chapters <= 12 ? 'top-[29%] left-min' : ''}
${chapters <= 20 && chapters > 10 ? 'top-[34%] left-med' : ''}
${chapters < 50 && chapters > 20 ? 'top-[35%] left-med' : 'top-[40%]'}
${chapters > 50 ? 'top-[51%] left-med' : 'top-[40%]'}
${chapters > 50 ? 'top-[51%] left-med' : 'top-[40%] left-med'}
${chapters >= 20 ? 'max-lg:top-[51%]' : 'max-lg:top-[40%]'}
`
} >
Expand Down
6 changes: 5 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ export const versions = [
{
url: 'dhh',
name: 'Dios Habla Hoy'
}
},
{
url: 'pdt',
name: 'Palabra de Dios para todos'
},
]

export const API_BASE_URL = 'https://bible-api.deno.dev'
Expand Down
2 changes: 1 addition & 1 deletion src/routes/read/[version]/[book]/[chapter]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

<StudyChapter
book={data.params.book}
version={data.params.version}
versionRead={data.params.version}
chapter={Number(data.params.chapter)}
/>
6 changes: 3 additions & 3 deletions src/state/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export function searchBible({ version, testament }) {
let url

if (!testament) {
url = new URL(`https://bible-api.deno.dev/api/${version}/search`)
url = new URL(`https://bible-api.deno.dev/api/read/${version}/search`)
url.searchParams.set('q', search)
} else {
url = new URL(`https://bible-api.deno.dev/api/${version}/search`)
url = new URL(`https://bible-api.deno.dev/api/read/${version}/search`)
url.searchParams.set('testament', testament)
url.searchParams.set('q', search)
}
Expand All @@ -103,7 +103,7 @@ export function searchBible({ version, testament }) {
return Promise.reject('No hay nada que buscar')
}

const url = new URL(`https://bible-api.deno.dev/api/${version}/search`)
const url = new URL(`https://bible-api.deno.dev/api/read/${version}/search`)
url.searchParams.set('q', search)
if (testament) {
url.searchParams.set('testament', testament)
Expand Down

1 comment on commit ead9640

@vercel
Copy link

@vercel vercel bot commented on ead9640 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bible-app-ubqz – ./

bible-app-ubqz-git-main-atticus64.vercel.app
bible-app-ubqz-atticus64.vercel.app
bible-study.vercel.app

Please sign in to comment.