-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,66 @@ | ||
import { ApolloQueryResult, gql } from "@apollo/client"; | ||
import apolloClient from "./apolloClient"; | ||
import { query, resolved } from "src/gqty-client"; | ||
|
||
interface GitaVerseIds { | ||
gita_verses: { chapter_number: number; verse_number: number }[]; | ||
} | ||
|
||
export async function getVerseId(): Promise<GitaVerseIds> { | ||
const { data }: ApolloQueryResult<GitaVerseIds> = await apolloClient.query({ | ||
query: gql` | ||
query MyQuery { | ||
gita_verses { | ||
chapter_number | ||
verse_number | ||
} | ||
} | ||
`, | ||
}); | ||
|
||
return data; | ||
} | ||
export const getVerseId = () => | ||
resolved(() => | ||
query.gita_verses().map((gitaVerse) => ({ | ||
chapter_number: gitaVerse.chapter_number!, | ||
verse_number: gitaVerse.verse_number!, | ||
})) | ||
); | ||
|
||
export async function getVerseData( | ||
export const getVerseData = ( | ||
chapterNumber, | ||
verseNumber, | ||
commentariesAuthor = "Swami Sivananda", | ||
translationsAuthor = "Swami Sivananda" | ||
): Promise<GitaVerse> { | ||
// todo: add translation to the query and pass transation data to Translation and Commentary component | ||
const { data }: ApolloQueryResult<Verse> = await apolloClient.query({ | ||
query: gql` | ||
query MyQuery { | ||
gita_verses(where: {chapter_number: {_eq: ${chapterNumber}}, verse_number: {_eq: ${verseNumber}}}) { | ||
chapter_number | ||
id | ||
text | ||
transliteration | ||
verse_number | ||
word_meanings | ||
gita_chapter { | ||
verses_count | ||
} | ||
gita_commentaries(where: {author_name: {_eq: "${commentariesAuthor}"}}) { | ||
description | ||
} | ||
gita_translations(where: {author_name: {_eq: "${translationsAuthor}"}}) { | ||
description | ||
} | ||
} | ||
} | ||
`, | ||
}); | ||
) => | ||
resolved(() => { | ||
const [gitaVerse] = query.gita_verses({ | ||
where: { | ||
chapter_number: { | ||
_eq: chapterNumber, | ||
}, | ||
verse_number: { | ||
_eq: verseNumber, | ||
}, | ||
}, | ||
}); | ||
|
||
return data.gita_verses[0]; | ||
} | ||
if (!gitaVerse) { | ||
return null; | ||
} | ||
|
||
return { | ||
chapter_number: gitaVerse.chapter_number!, | ||
id: gitaVerse.id!, | ||
text: gitaVerse.text!, | ||
transliteration: gitaVerse.transliteration!, | ||
verse_number: gitaVerse.verse_number!, | ||
word_meanings: gitaVerse.word_meanings!, | ||
gita_chapter: { | ||
verses_count: gitaVerse.gita_chapter?.verses_count || 0, | ||
}, | ||
gita_commentaries: gitaVerse | ||
.gita_commentaries({ | ||
where: { | ||
author_name: { | ||
_eq: commentariesAuthor, | ||
}, | ||
}, | ||
}) | ||
.map(({ description }) => ({ description: description! })), | ||
gita_translations: gitaVerse | ||
.gita_translations({ | ||
where: { | ||
author_name: { | ||
_eq: translationsAuthor, | ||
}, | ||
}, | ||
}) | ||
.map(({ description }) => ({ description: description! })), | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import { gql } from "@apollo/client"; | ||
import apolloClient from "./apolloClient"; | ||
import { mutation, resolved } from "src/gqty-client"; | ||
|
||
export const subscribeUser = async ( | ||
name: string, | ||
email: string | ||
): Promise<void> => { | ||
await apolloClient.mutate({ | ||
mutation: gql` | ||
mutation MyMutation { | ||
insert_newsletter_subscriptions_one( | ||
object: { | ||
user_name: "${name}" | ||
user_email: "${email}" | ||
} | ||
) { | ||
user_name | ||
user_email | ||
} | ||
} | ||
`, | ||
}); | ||
export const subscribeUser = async (name: string, email: string) => { | ||
return resolved(() => | ||
mutation.insert_newsletter_subscriptions_one({ | ||
object: { | ||
user_name: name, | ||
user_email: email, | ||
}, | ||
}) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,25 +15,6 @@ | |
"@jridgewell/gen-mapping" "^0.3.0" | ||
"@jridgewell/trace-mapping" "^0.3.9" | ||
|
||
"@apollo/client@^3.5.5": | ||
version "3.7.17" | ||
resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.7.17.tgz#1d2538729fd8ef138aa301a7cf62704474e57b72" | ||
integrity sha512-0EErSHEtKPNl5wgWikHJbKFAzJ/k11O0WO2QyqZSHpdxdAnw7UWHY4YiLbHCFG7lhrD+NTQ3Z/H9Jn4rcikoJA== | ||
dependencies: | ||
"@graphql-typed-document-node/core" "^3.1.1" | ||
"@wry/context" "^0.7.0" | ||
"@wry/equality" "^0.5.0" | ||
"@wry/trie" "^0.4.0" | ||
graphql-tag "^2.12.6" | ||
hoist-non-react-statics "^3.3.2" | ||
optimism "^0.16.2" | ||
prop-types "^15.7.2" | ||
response-iterator "^0.2.6" | ||
symbol-observable "^4.0.0" | ||
ts-invariant "^0.10.3" | ||
tslib "^2.3.0" | ||
zen-observable-ts "^1.2.5" | ||
|
||
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.22.5": | ||
version "7.22.5" | ||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.5.tgz#234d98e1551960604f1246e6475891a570ad5658" | ||
|
@@ -272,11 +253,6 @@ | |
resolved "https://registry.yarnpkg.com/@gqty/utils/-/utils-1.0.0.tgz#5f954c95721244aa1e59534695a1c1e8d3877225" | ||
integrity sha512-QJMlzts//d0H5mlekOZgx1a4KsTYXfxmRhhx8g/8mvzdaNVPxhFzCsv3+ljTOzbW3A08qy4jXQPWAMoTefSJDQ== | ||
|
||
"@graphql-typed-document-node/core@^3.1.1": | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" | ||
integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== | ||
|
||
"@headlessui/react@^1.4.1": | ||
version "1.7.15" | ||
resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.15.tgz#53ef6ae132af81b8f188414767b6e79ebf8dc73f" | ||
|
@@ -947,34 +923,6 @@ | |
resolved "https://registry.yarnpkg.com/@vercel/node-bridge/-/node-bridge-2.2.2.tgz#f63466ab6a2588afdc6262c2d060289bfe8baa6b" | ||
integrity sha512-haGBC8noyA5BfjCRXRH+VIkHCDVW5iD5UX24P2nOdilwUxI4qWsattS/co8QBGq64XsNLRAMdM5pQUE3zxkF9Q== | ||
|
||
"@wry/context@^0.7.0": | ||
version "0.7.3" | ||
resolved "https://registry.yarnpkg.com/@wry/context/-/context-0.7.3.tgz#240f6dfd4db5ef54f81f6597f6714e58d4f476a1" | ||
integrity sha512-Nl8WTesHp89RF803Se9X3IiHjdmLBrIvPMaJkl+rKVJAYyPsz1TEUbu89943HpvujtSJgDUx9W4vZw3K1Mr3sA== | ||
dependencies: | ||
tslib "^2.3.0" | ||
|
||
"@wry/equality@^0.5.0": | ||
version "0.5.6" | ||
resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.5.6.tgz#cd4a533c72c3752993ab8cbf682d3d20e3cb601e" | ||
integrity sha512-D46sfMTngaYlrH+OspKf8mIJETntFnf6Hsjb0V41jAXJ7Bx2kB8Rv8RCUujuVWYttFtHkUNp7g+FwxNQAr6mXA== | ||
dependencies: | ||
tslib "^2.3.0" | ||
|
||
"@wry/trie@^0.3.0": | ||
version "0.3.2" | ||
resolved "https://registry.yarnpkg.com/@wry/trie/-/trie-0.3.2.tgz#a06f235dc184bd26396ba456711f69f8c35097e6" | ||
integrity sha512-yRTyhWSls2OY/pYLfwff867r8ekooZ4UI+/gxot5Wj8EFwSf2rG+n+Mo/6LoLQm1TKA4GRj2+LCpbfS937dClQ== | ||
dependencies: | ||
tslib "^2.3.0" | ||
|
||
"@wry/trie@^0.4.0": | ||
version "0.4.3" | ||
resolved "https://registry.yarnpkg.com/@wry/trie/-/trie-0.4.3.tgz#077d52c22365871bf3ffcbab8e95cb8bc5689af4" | ||
integrity sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w== | ||
dependencies: | ||
tslib "^2.3.0" | ||
|
||
acorn-jsx@^5.3.2: | ||
version "5.3.2" | ||
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" | ||
|
@@ -2496,13 +2444,6 @@ graphemer@^1.4.0: | |
resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" | ||
integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== | ||
|
||
graphql-tag@^2.12.6: | ||
version "2.12.6" | ||
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" | ||
integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg== | ||
dependencies: | ||
tslib "^2.1.0" | ||
|
||
graphql@^16.0.1: | ||
version "16.7.1" | ||
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.7.1.tgz#11475b74a7bff2aefd4691df52a0eca0abd9b642" | ||
|
@@ -3465,14 +3406,6 @@ open@^9.1.0: | |
is-inside-container "^1.0.0" | ||
is-wsl "^2.2.0" | ||
|
||
optimism@^0.16.2: | ||
version "0.16.2" | ||
resolved "https://registry.yarnpkg.com/optimism/-/optimism-0.16.2.tgz#519b0c78b3b30954baed0defe5143de7776bf081" | ||
integrity sha512-zWNbgWj+3vLEjZNIh/okkY2EUfX+vB9TJopzIZwT1xxaMqC5hRLLraePod4c5n4He08xuXNH+zhKFFCu390wiQ== | ||
dependencies: | ||
"@wry/context" "^0.7.0" | ||
"@wry/trie" "^0.3.0" | ||
|
||
optionator@^0.9.3: | ||
version "0.9.3" | ||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" | ||
|
@@ -3957,11 +3890,6 @@ resolve@^2.0.0-next.4: | |
path-parse "^1.0.7" | ||
supports-preserve-symlinks-flag "^1.0.0" | ||
|
||
response-iterator@^0.2.6: | ||
version "0.2.6" | ||
resolved "https://registry.yarnpkg.com/response-iterator/-/response-iterator-0.2.6.tgz#249005fb14d2e4eeb478a3f735a28fd8b4c9f3da" | ||
integrity sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw== | ||
|
||
reusify@^1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" | ||
|
@@ -4306,11 +4234,6 @@ svgo@^2.8.0: | |
picocolors "^1.0.0" | ||
stable "^0.1.8" | ||
|
||
symbol-observable@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-4.0.0.tgz#5b425f192279e87f2f9b937ac8540d1984b39205" | ||
integrity sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ== | ||
|
||
synckit@^0.8.5: | ||
version "0.8.5" | ||
resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.5.tgz#b7f4358f9bb559437f9f167eb6bc46b3c9818fa3" | ||
|
@@ -4443,13 +4366,6 @@ tr46@~0.0.3: | |
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" | ||
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== | ||
|
||
ts-invariant@^0.10.3: | ||
version "0.10.3" | ||
resolved "https://registry.yarnpkg.com/ts-invariant/-/ts-invariant-0.10.3.tgz#3e048ff96e91459ffca01304dbc7f61c1f642f6c" | ||
integrity sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ== | ||
dependencies: | ||
tslib "^2.1.0" | ||
|
||
tsconfig-paths@^3.14.1: | ||
version "3.14.2" | ||
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" | ||
|
@@ -4465,7 +4381,7 @@ tslib@^1.8.1: | |
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" | ||
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== | ||
|
||
tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.0: | ||
tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.0: | ||
version "2.6.0" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" | ||
integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== | ||
|
@@ -4751,18 +4667,6 @@ yocto-queue@^0.1.0: | |
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" | ||
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== | ||
|
||
zen-observable-ts@^1.2.5: | ||
version "1.2.5" | ||
resolved "https://registry.yarnpkg.com/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz#6c6d9ea3d3a842812c6e9519209365a122ba8b58" | ||
integrity sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg== | ||
dependencies: | ||
zen-observable "0.8.15" | ||
|
||
[email protected]: | ||
version "0.8.15" | ||
resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15" | ||
integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== | ||
|
||
[email protected]: | ||
version "3.21.4" | ||
resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db" | ||
|