Skip to content

Commit

Permalink
Added book and chapter overview for tN
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinpaul committed Jan 12, 2024
1 parent 5c16b23 commit 03ee336
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function classNames(...classes) {
function TabSelector({ currentTab, setCurrentTab, tabData }) {
return (
<div className="w-full px-2 sm:px-0 pb-2">
<Tab.Group manual selectedIndex={currentTab} onChange={setCurrentTab}>
<Tab.Group manual defaultIndex={2} selectedIndex={currentTab} onChange={setCurrentTab}>
<Tab.List className="flex space-x-1 rounded-xl bg-gray-200 p-1">
{tabData.map((data) => (
<Tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import packageInfo from '../../../../../package.json';
import TabSelector from './TabSelector';

const tnTabHeads = [
{ id: 1, title: 'verse' },
{ id: 2, title: 'chapter Overview' },
{ id: 3, title: 'book Overview' },
{ id: 1, title: 'Book Overview' },
{ id: 2, title: 'Chapter Overview' },
{ id: 3, title: 'Verse Note' },
];

export default function TranslationHelpsCard({
Expand All @@ -38,7 +38,7 @@ export default function TranslationHelpsCard({
const [offlineMarkdown, setOfflineMarkdown] = useState('');
const [resetTrigger, setResetTrigger] = useState(false);

const [currentTnTab, setCurrentTnTab] = useState(0);
const [currentTnTab, setCurrentTnTab] = useState(2);

const [currentChapterVerse, setCurrentChapterVerse] = useState({ verse, chapter });

Expand All @@ -59,7 +59,7 @@ export default function TranslationHelpsCard({
useEffect(() => {
if (currentTnTab === 1) {
setCurrentChapterVerse({ chapter, verse: 'intro' });
} else if (currentTnTab === 2) {
} else if (currentTnTab === 0) {
setCurrentChapterVerse({ verse: 'intro', chapter: 'front' });
} else {
setCurrentChapterVerse({ verse, chapter });
Expand Down Expand Up @@ -124,7 +124,7 @@ export default function TranslationHelpsCard({
return {
Book, Chapter, Verse, ID, [noteName]: file.split('\t')[indexOfNote],
};
}).filter((data) => data.Chapter === chapter && data.Verse === verse);
}).filter((data) => data.Chapter === currentChapterVerse.chapter && data.Verse === currentChapterVerse.verse);
setOfflineItemsDisable(false);
setOfflineItems(json);
}
Expand Down Expand Up @@ -246,13 +246,21 @@ export default function TranslationHelpsCard({
items = !offlineItemsDisable && offlineResource?.offline ? offlineItems : items;
markdown = offlineResource?.offline ? offlineMarkdown : markdown;

console.log({ currentTnTab });
if (resourceId === 'tn' && items) {
if (items[0]?.Note) {
items[0].Note = (items[0].Note).replace(/(<br>|\\n)/gm, '\n');
}
if (items[0]?.OccurrenceNote) {
items[0].OccurrenceNote = (items[0].OccurrenceNote).replace(/(<br>|\\n)/gm, '\n');
}
}

return (
(markdown || items) ? (
<>
{resourceId === 'tn' && (<TabSelector currentTab={currentTnTab} setCurrentTab={setCurrentTnTab} tabData={tnTabHeads} />)}
<>
{resourceId === 'tn' && (<TabSelector currentTab={currentTnTab} setCurrentTab={setCurrentTnTab} tabData={tnTabHeads} />)}
{(markdown || items) ? (
<ReferenceCard
resourceId={resourceId}
items={items}
filters={['OccurrenceNote']}
markdown={markdown}
Expand All @@ -266,8 +274,9 @@ export default function TranslationHelpsCard({
setResetTrigger={setResetTrigger}
resetTrigger={resetTrigger}
/>
</>
) : <LoadingScreen />
)
: <LoadingScreen />}
</>

);
}
Expand Down

0 comments on commit 03ee336

Please sign in to comment.