-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
54 changed files
with
980 additions
and
50 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
core/src/main/kotlin/me/madhead/tyzenhaus/core/service/TransactionsSearchService.kt
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.madhead.tyzenhaus.core.service | ||
|
||
import me.madhead.tyzenhaus.entity.transaction.Transaction | ||
import me.madhead.tyzenhaus.repository.TransactionRepository | ||
|
||
data class TransactionsSearchParams( | ||
val title: String? = null, | ||
) | ||
|
||
class TransactionsSearchService( | ||
private val transactionRepository: TransactionRepository, | ||
) { | ||
fun search(group: Long, searchParams: TransactionsSearchParams): List<Transaction> { | ||
return transactionRepository.search(group) | ||
} | ||
} |
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 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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+121 KB
mini-app/.yarn/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-6c4df4839e.zip
Binary file not shown.
Binary file added
BIN
+13.6 KB
mini-app/.yarn/cache/@nodelib-fs.scandir-npm-2.1.5-89c67370dd-a970d595bd.zip
Binary file not shown.
Binary file added
BIN
+8.5 KB
mini-app/.yarn/cache/@nodelib-fs.stat-npm-2.0.5-01f4dd3030-012480b5ca.zip
Binary file not shown.
Binary file added
BIN
+15.2 KB
mini-app/.yarn/cache/@nodelib-fs.walk-npm-1.2.8-b4a89da548-190c643f15.zip
Binary file not shown.
Binary file added
BIN
+19.3 KB
mini-app/.yarn/cache/copy-webpack-plugin-npm-11.0.0-9a07415855-df4f8743f0.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+24.7 KB
mini-app/.yarn/cache/html-parse-stringify-npm-3.0.1-5762cd4b01-334fdebd4b.zip
Binary file not shown.
Binary file added
BIN
+29.7 KB
mini-app/.yarn/cache/i18next-browser-languagedetector-npm-7.1.0-1a79fe5d7c-36981b9a99.zip
Binary file not shown.
Binary file added
BIN
+35.2 KB
mini-app/.yarn/cache/i18next-http-backend-npm-2.2.2-a3b91fce41-b098cf89e6.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.01 KB
mini-app/.yarn/cache/normalize.css-npm-8.0.1-6124fb39b6-4698cae88e.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.58 KB
mini-app/.yarn/cache/queue-microtask-npm-1.2.3-fcc98e4e2d-b676f8c040.zip
Binary file not shown.
Binary file added
BIN
+108 KB
mini-app/.yarn/cache/react-i18next-npm-13.3.1-2ad8c538c6-71a9ae4968.zip
Binary file not shown.
Binary file added
BIN
+9.46 KB
mini-app/.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+3.54 KB
mini-app/.yarn/cache/run-parallel-npm-1.2.0-3f47ff2034-cb4f97ad25.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.39 KB
mini-app/.yarn/cache/void-elements-npm-3.1.0-4f43780839-0390f81810.zip
Binary file not shown.
Binary file added
BIN
+5.56 KB
mini-app/.yarn/cache/webidl-conversions-npm-3.0.1-60310f6a2b-c92a0a6ab9.zip
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
|
@@ -5,14 +5,20 @@ | |
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@twa-dev/sdk": "^6.9.0", | ||
"i18next": "^23.6.0", | ||
"i18next-browser-languagedetector": "^7.1.0", | ||
"i18next-http-backend": "^2.2.2", | ||
"normalize.css": "^8.0.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
"react-dom": "^18.2.0", | ||
"react-i18next": "^13.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "18.18.2", | ||
"@types/react": "^18.2.28", | ||
"@types/react-dom": "^18.2.13", | ||
"@types/webpack": "^5.28.3", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"css-loader": "^6.8.1", | ||
"html-webpack-plugin": "^5.5.3", | ||
"less": "^4.2.0", | ||
|
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import WebApp from "@twa-dev/sdk"; | ||
import { ReactNode, useEffect, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import Error from "./error/Error"; | ||
|
||
type AppWrapperProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
export default function AppWrapper(props: AppWrapperProps) { | ||
const { platform } = WebApp; | ||
const { t } = useTranslation(); | ||
|
||
if (platform === "unknown") { | ||
return <Error error={t("errors.outsideOfTelegram")} />; | ||
} else { | ||
return AuthWrapper(props); | ||
} | ||
} | ||
|
||
type AuthWrapperProps = AppWrapperProps; | ||
|
||
function AuthWrapper({ children }: AuthWrapperProps) { | ||
const [ok, setOk] = useState<boolean | null>(null); | ||
|
||
useEffect(() => { | ||
async function authenticate() { | ||
let response = await fetch("/app/api/auth/validation", { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${WebApp.initDataUnsafe.start_param}`, | ||
}, | ||
body: WebApp.initData, | ||
}); | ||
|
||
setOk(response.ok); | ||
} | ||
|
||
authenticate(); | ||
}, [ | ||
WebApp, | ||
WebApp.initData, | ||
WebApp.initDataUnsafe, | ||
WebApp.initDataUnsafe.start_param, | ||
]); | ||
|
||
const { t } = useTranslation(); | ||
|
||
if (ok === null) { | ||
return null; | ||
} else if (ok === false) { | ||
return <Error error={t("errors.unauthorized")} />; | ||
} else { | ||
return children; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#error { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
color: red; | ||
font-size: large; | ||
text-align: center; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "./Error.less"; | ||
|
||
type ErrorProps = { | ||
error: string; | ||
}; | ||
|
||
function Error({ error }: ErrorProps) { | ||
return <div id="error">{error}</div>; | ||
} | ||
|
||
export default Error; |
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,29 +1,89 @@ | ||
import { useEffect, useState } from "react"; | ||
import "./HistoryApp.less"; | ||
|
||
import WebApp from "@twa-dev/sdk"; | ||
import { useEffect, useState } from "react"; | ||
import AppWrapper from "../common/AppWrapper"; | ||
|
||
type Member = { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
username: string; | ||
}; | ||
type Currency = string; | ||
type Transaction = { | ||
id: number; | ||
payer: number; | ||
recipients: Set<number>; | ||
// amount: BigDecimal, | ||
currency: string; | ||
title: string; | ||
// @Serializable(InstantSerializer::class) | ||
// val timestamp: Instant = Instant.now(), | ||
}; | ||
|
||
function HistoryApp() { | ||
console.log(WebApp.initData); | ||
console.log(WebApp.initDataUnsafe); | ||
const [members, setMembers] = useState<Member[]>([]); | ||
const [currencies, setCurrencies] = useState<Currency[]>([]); | ||
const [transactions, setTransactions] = useState<Transaction[]>([]); | ||
|
||
useEffect(() => { | ||
async function loadMembers() { | ||
let response = await fetch("/app/api/group/members", { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${WebApp.initDataUnsafe.start_param}`, | ||
}, | ||
}); | ||
|
||
setMembers((await response.json()).members); | ||
} | ||
|
||
const [data, setData] = useState(null); | ||
loadMembers(); | ||
}, []); | ||
useEffect(() => { | ||
async function loadCurrencies() { | ||
let response = await fetch("/app/api/group/currencies", { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${WebApp.initDataUnsafe.start_param}`, | ||
}, | ||
}); | ||
|
||
setCurrencies(await response.json()); | ||
} | ||
|
||
loadCurrencies(); | ||
}, []); | ||
useEffect(() => { | ||
async function fetchData() { | ||
const data = await fetch("/app/api/test"); | ||
const json = await data.json(); | ||
setData(json); | ||
async function loadTransactions() { | ||
let response = await fetch("/app/api/group/transactions", { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${WebApp.initDataUnsafe.start_param}`, | ||
}, | ||
}); | ||
|
||
setTransactions(await response.json()); | ||
} | ||
|
||
fetchData(); | ||
loadTransactions(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<AppWrapper> | ||
<h1>History</h1> | ||
Init Data: {WebApp.initData} | ||
</div> | ||
{transactions.map((transaction) => ( | ||
<Transaction {...transaction} /> | ||
))} | ||
</AppWrapper> | ||
); | ||
} | ||
|
||
function Transaction(transaction: Transaction) { | ||
return <div className="transaction"> | ||
{transaction.title} | ||
</div>; | ||
} | ||
|
||
export default HistoryApp; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import url(https://fonts.googleapis.com/css2?family=Roboto); | ||
@import "~normalize.css/normalize.css"; | ||
|
||
body { | ||
font-family: "Roboto", sans-serif; | ||
background-color: var(--tg-theme-bg-color); | ||
} | ||
|
||
#root { | ||
min-height: 100vh; | ||
box-sizing: border-box; | ||
padding: 24px; | ||
display: flex; | ||
flex-direction: column; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"errors": { | ||
"outsideOfTelegram": "This app must be executed inside a Telegram client", | ||
"unauthorized": "You are not authorized to use this app" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import i18next from "i18next"; | ||
import { initReactI18next } from "react-i18next"; | ||
import HttpBackend from "i18next-http-backend"; | ||
import LanguageDetector from "i18next-browser-languagedetector"; | ||
import WebApp from "@twa-dev/sdk"; | ||
|
||
document.documentElement.lang = WebApp.initDataUnsafe.user?.language_code || "en"; | ||
|
||
const httpBackend = new HttpBackend(null, { | ||
loadPath: "/app/i18n/{{lng}}.json", | ||
}); | ||
|
||
const languageDetector = new LanguageDetector(null, { | ||
order: ["htmlTag"], | ||
}); | ||
|
||
i18next.use(httpBackend).use(languageDetector).use(initReactI18next).init({ | ||
fallbackLng: "en", | ||
}); | ||
|
||
export default i18next; |
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"errors": { | ||
"outsideOfTelegram": "Это приложение нужно запускать внутри Telegram клиента" | ||
} | ||
} |
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
Oops, something went wrong.