Skip to content

Commit 519a2da

Browse files
committed
Support chat link
1 parent 1834c3d commit 519a2da

File tree

11 files changed

+53
-37
lines changed

11 files changed

+53
-37
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
VITE_API_URL=/api
2-
VITE_CHANNEL_LINK=
32
VITE_BOT_APP_URL=
43

src/screens/deck-form/deck-form.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useMount } from "../../lib/react/use-mount.ts";
1010
import { useBackButton } from "../../lib/telegram/use-back-button.tsx";
1111
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
1212
import { assert } from "../../lib/typescript/assert.ts";
13-
import { SettingsRow } from "../user-settings/settings-row.tsx";
13+
import { CardRow } from "../../ui/card-row.tsx";
1414
import { Button } from "../../ui/button.tsx";
1515
import { HintTransparent } from "../../ui/hint-transparent.tsx";
1616
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
@@ -90,23 +90,23 @@ export const DeckForm = observer(() => {
9090
</Label>
9191

9292
{deckFormStore.form.cards.length > 0 && (
93-
<SettingsRow
93+
<CardRow
9494
onClick={() => {
9595
deckFormStore.goToCardList();
9696
}}
9797
>
9898
<span>{t("cards")}</span>
9999
<span>{deckFormStore.form.cards.length}</span>
100-
</SettingsRow>
100+
</CardRow>
101101
)}
102102

103-
<SettingsRow>
103+
<CardRow>
104104
<span>{t("speaking_cards")}</span>
105105
<RadioSwitcher
106106
isOn={deckFormStore.isSpeakingCardEnabled}
107107
onToggle={deckFormStore.toggleIsSpeakingCardEnabled}
108108
/>
109-
</SettingsRow>
109+
</CardRow>
110110
{deckFormStore.isSpeakingCardEnabled ? (
111111
<div
112112
className={css({

src/screens/deck-form/store/deck-form-store.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const mapUpsertDeckRequestToResponse = (
3838
back: card.back,
3939
};
4040
}),
41-
}
41+
},
4242
});
4343

4444
const mocks = vi.hoisted(() => {

src/screens/deck-list/main-screen.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { screenStore } from "../../store/screen-store.ts";
1111
import { Button } from "../../ui/button.tsx";
1212
import { DeckLoading } from "./deck-loading.tsx";
1313
import WebApp from "@twa-dev/sdk";
14-
import { assert } from "../../lib/typescript/assert.ts";
1514
import { ListHeader } from "../../ui/list-header.tsx";
1615
import { range } from "../../lib/array/range.ts";
1716
import { reset } from "../../ui/reset.ts";
1817
import { ViewMoreDecksToggle } from "./view-more-decks-toggle.tsx";
1918
import { t } from "../../translations/t.ts";
19+
import { links } from "../shared/links.ts";
2020

2121
export const MainScreen = observer(() => {
2222
useMount(() => {
@@ -181,10 +181,7 @@ export const MainScreen = observer(() => {
181181
<Button
182182
icon={"mdi-call-made"}
183183
onClick={() => {
184-
const channelLink = import.meta.env.VITE_CHANNEL_LINK;
185-
assert(channelLink, "Channel link env variable is empty");
186-
187-
WebApp.openTelegramLink(channelLink);
184+
WebApp.openTelegramLink(links.botChannel);
188185
}}
189186
>
190187
{t("telegram_channel")}

src/screens/folder-form/folder-form.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.ts
1010
import { useMount } from "../../lib/react/use-mount.ts";
1111
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
1212
import { assert } from "../../lib/typescript/assert.ts";
13-
import { SettingsRow } from "../user-settings/settings-row.tsx";
13+
import { CardRow } from "../../ui/card-row.tsx";
1414
import { reset } from "../../ui/reset.ts";
1515
import { css, cx } from "@emotion/css";
1616
import { theme } from "../../ui/theme.tsx";
@@ -57,7 +57,7 @@ export const FolderForm = observer(() => {
5757
<Label text={t("decks")} isPlain>
5858
{folderForm.decks.value.map((deck, i) => {
5959
return (
60-
<SettingsRow key={i}>
60+
<CardRow key={i}>
6161
<span>{deck.name}</span>
6262
<button
6363
className={cx(reset.button, css({ padding: 8, fontSize: 16 }))}
@@ -73,7 +73,7 @@ export const FolderForm = observer(() => {
7373
)}
7474
/>
7575
</button>
76-
</SettingsRow>
76+
</CardRow>
7777
);
7878
})}
7979
</Label>
@@ -85,7 +85,7 @@ export const FolderForm = observer(() => {
8585
) : null}
8686
{folderStore.decksMineFiltered.map((deck) => {
8787
return (
88-
<SettingsRow key={deck.id}>
88+
<CardRow key={deck.id}>
8989
<span>{deck.name}</span>
9090
<button
9191
className={cx(reset.button, css({ padding: 8, fontSize: 16 }))}
@@ -104,7 +104,7 @@ export const FolderForm = observer(() => {
104104
)}
105105
/>
106106
</button>
107-
</SettingsRow>
107+
</CardRow>
108108
);
109109
})}
110110
</Label>

src/screens/folder-review/folder-preview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ButtonSideAligned } from "../../ui/button-side-aligned.tsx";
1212
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
1313
import { t } from "../../translations/t.ts";
1414
import { useReviewStore } from "../deck-review/store/review-store-context.tsx";
15-
import { SettingsRow } from "../user-settings/settings-row.tsx";
15+
import { CardRow } from "../../ui/card-row.tsx";
1616
import { ListHeader } from "../../ui/list-header.tsx";
1717
import { assert } from "../../lib/typescript/assert.ts";
1818
import { userStore } from "../../store/user-store.ts";
@@ -187,14 +187,14 @@ export const FolderPreview = observer(() => {
187187
<ListHeader text={t("decks")} />
188188
{folder.decks.map((deck, i) => {
189189
return (
190-
<SettingsRow
190+
<CardRow
191191
key={i}
192192
onClick={() => {
193193
deckListStore.goDeckById(deck.id);
194194
}}
195195
>
196196
{deck.name}
197-
</SettingsRow>
197+
</CardRow>
198198
);
199199
})}
200200
{folder.cardsToReview.length === 0 && (

src/screens/share-deck/share-deck-settings.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { screenStore } from "../../store/screen-store.ts";
44
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
55
import { t } from "../../translations/t.ts";
66
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
7-
import { SettingsRow } from "../user-settings/settings-row.tsx";
7+
import { CardRow } from "../../ui/card-row.tsx";
88
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
99
import { HintTransparent } from "../../ui/hint-transparent.tsx";
1010
import { Label } from "../../ui/label.tsx";
@@ -36,25 +36,25 @@ export const ShareDeckSettings = observer(() => {
3636

3737
return (
3838
<Screen title={t("share_deck_settings")}>
39-
<SettingsRow>
39+
<CardRow>
4040
<span>{t("share_one_time_access_link")}</span>
4141
<RadioSwitcher
4242
isOn={store.form.isOneTime.value}
4343
onToggle={store.form.isOneTime.toggle}
4444
/>
45-
</SettingsRow>
45+
</CardRow>
4646
<HintTransparent>
4747
{t("share_one_time_access_link_description")}
4848
</HintTransparent>
4949
{store.form.isOneTime.value && (
5050
<>
51-
<SettingsRow>
51+
<CardRow>
5252
<span>{t("share_access_duration")}</span>
5353
<RadioSwitcher
5454
isOn={store.form.isAccessDuration.value}
5555
onToggle={store.form.isAccessDuration.toggle}
5656
/>
57-
</SettingsRow>
57+
</CardRow>
5858
</>
5959
)}
6060
{store.form.isOneTime.value && store.form.isAccessDuration.value && (
@@ -64,13 +64,13 @@ export const ShareDeckSettings = observer(() => {
6464
</Label>
6565
)}
6666

67-
<SettingsRow
67+
<CardRow
6868
onClick={() => {
6969
store.isDeckAccessesOpen.setTrue();
7070
}}
7171
>
7272
{t("share_one_time_links_usage")}
73-
</SettingsRow>
73+
</CardRow>
7474
</Screen>
7575
);
7676
});

src/screens/shared/links.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const links = {
2+
botChannel: "https://t.me/memo_card_bot_channel",
3+
supportChat: "https://t.me/memocard_support",
4+
};

src/screens/shared/screen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Screen = observer((props: Props) => {
2121
})}
2222
>
2323
<div>
24-
<h3 className={css({ textAlign: "center"})}>{title}</h3>
24+
<h3 className={css({ textAlign: "center" })}>{title}</h3>
2525
{subtitle}
2626
</div>
2727
{children}

src/screens/user-settings/user-settings-main.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useMount } from "../../lib/react/use-mount.ts";
66
import { generateTimeRange } from "./generate-time-range.tsx";
77
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
88
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
9-
import { SettingsRow } from "./settings-row.tsx";
9+
import { CardRow } from "../../ui/card-row.tsx";
1010
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
1111
import { theme } from "../../ui/theme.tsx";
1212
import { Select } from "../../ui/select.tsx";
@@ -16,6 +16,8 @@ import { screenStore } from "../../store/screen-store.ts";
1616
import { HintTransparent } from "../../ui/hint-transparent.tsx";
1717
import { t } from "../../translations/t.ts";
1818
import { Screen } from "../shared/screen.tsx";
19+
import WebApp from "@twa-dev/sdk";
20+
import { links } from "../shared/links.ts";
1921

2022
export const timeRanges = generateTimeRange();
2123

@@ -45,7 +47,7 @@ export const UserSettingsMain = observer(() => {
4547

4648
return (
4749
<Screen title={t("settings")}>
48-
<SettingsRow>
50+
<CardRow>
4951
<span>{t("settings_review_notifications")}</span>
5052
<span
5153
className={css({
@@ -58,9 +60,9 @@ export const UserSettingsMain = observer(() => {
5860
onToggle={isRemindNotifyEnabled.toggle}
5961
/>
6062
</span>
61-
</SettingsRow>
63+
</CardRow>
6264
{isRemindNotifyEnabled.value && (
63-
<SettingsRow>
65+
<CardRow>
6466
<span>{t("settings_time")}</span>
6567
<div className={css({ color: theme.linkColor })}>
6668
<Select
@@ -74,14 +76,14 @@ export const UserSettingsMain = observer(() => {
7476
}))}
7577
/>
7678
</div>
77-
</SettingsRow>
79+
</CardRow>
7880
)}
7981

8082
<HintTransparent>
8183
{t("settings_review_notifications_hint")}
8284
</HintTransparent>
8385

84-
<SettingsRow>
86+
<CardRow>
8587
<span>{t("speaking_cards")}</span>
8688
<span
8789
className={css({
@@ -94,9 +96,23 @@ export const UserSettingsMain = observer(() => {
9496
onToggle={isSpeakingCardsEnabled.toggle}
9597
/>
9698
</span>
97-
</SettingsRow>
99+
</CardRow>
98100

99101
<HintTransparent>{t("card_speak_description")}</HintTransparent>
102+
103+
<CardRow
104+
onClick={() => {
105+
WebApp.openTelegramLink(links.supportChat);
106+
}}
107+
>
108+
<span
109+
className={css({
110+
color: theme.linkColor,
111+
})}
112+
>
113+
Contact support
114+
</span>
115+
</CardRow>
100116
</Screen>
101117
);
102118
});

src/screens/user-settings/settings-row.tsx renamed to src/ui/card-row.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { observer } from "mobx-react-lite";
22
import React, { ReactNode } from "react";
33
import { css } from "@emotion/css";
4-
import { theme } from "../../ui/theme.tsx";
4+
import { theme } from "./theme.tsx";
55

66
type Props = {
77
children: ReactNode;
88
onClick?: () => void;
99
};
1010

11-
export const SettingsRow = observer((props: Props) => {
11+
export const CardRow = observer((props: Props) => {
1212
return (
1313
<label
1414
onClick={props.onClick}

0 commit comments

Comments
 (0)