Skip to content

Commit

Permalink
Support chat link
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Jan 8, 2024
1 parent 1834c3d commit 519a2da
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 37 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VITE_API_URL=/api
VITE_CHANNEL_LINK=
VITE_BOT_APP_URL=

10 changes: 5 additions & 5 deletions src/screens/deck-form/deck-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useMount } from "../../lib/react/use-mount.ts";
import { useBackButton } from "../../lib/telegram/use-back-button.tsx";
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
import { assert } from "../../lib/typescript/assert.ts";
import { SettingsRow } from "../user-settings/settings-row.tsx";
import { CardRow } from "../../ui/card-row.tsx";
import { Button } from "../../ui/button.tsx";
import { HintTransparent } from "../../ui/hint-transparent.tsx";
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
Expand Down Expand Up @@ -90,23 +90,23 @@ export const DeckForm = observer(() => {
</Label>

{deckFormStore.form.cards.length > 0 && (
<SettingsRow
<CardRow
onClick={() => {
deckFormStore.goToCardList();
}}
>
<span>{t("cards")}</span>
<span>{deckFormStore.form.cards.length}</span>
</SettingsRow>
</CardRow>
)}

<SettingsRow>
<CardRow>
<span>{t("speaking_cards")}</span>
<RadioSwitcher
isOn={deckFormStore.isSpeakingCardEnabled}
onToggle={deckFormStore.toggleIsSpeakingCardEnabled}
/>
</SettingsRow>
</CardRow>
{deckFormStore.isSpeakingCardEnabled ? (
<div
className={css({
Expand Down
2 changes: 1 addition & 1 deletion src/screens/deck-form/store/deck-form-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const mapUpsertDeckRequestToResponse = (
back: card.back,
};
}),
}
},
});

const mocks = vi.hoisted(() => {
Expand Down
7 changes: 2 additions & 5 deletions src/screens/deck-list/main-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { screenStore } from "../../store/screen-store.ts";
import { Button } from "../../ui/button.tsx";
import { DeckLoading } from "./deck-loading.tsx";
import WebApp from "@twa-dev/sdk";
import { assert } from "../../lib/typescript/assert.ts";
import { ListHeader } from "../../ui/list-header.tsx";
import { range } from "../../lib/array/range.ts";
import { reset } from "../../ui/reset.ts";
import { ViewMoreDecksToggle } from "./view-more-decks-toggle.tsx";
import { t } from "../../translations/t.ts";
import { links } from "../shared/links.ts";

export const MainScreen = observer(() => {
useMount(() => {
Expand Down Expand Up @@ -181,10 +181,7 @@ export const MainScreen = observer(() => {
<Button
icon={"mdi-call-made"}
onClick={() => {
const channelLink = import.meta.env.VITE_CHANNEL_LINK;
assert(channelLink, "Channel link env variable is empty");

WebApp.openTelegramLink(channelLink);
WebApp.openTelegramLink(links.botChannel);
}}
>
{t("telegram_channel")}
Expand Down
10 changes: 5 additions & 5 deletions src/screens/folder-form/folder-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.ts
import { useMount } from "../../lib/react/use-mount.ts";
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
import { assert } from "../../lib/typescript/assert.ts";
import { SettingsRow } from "../user-settings/settings-row.tsx";
import { CardRow } from "../../ui/card-row.tsx";
import { reset } from "../../ui/reset.ts";
import { css, cx } from "@emotion/css";
import { theme } from "../../ui/theme.tsx";
Expand Down Expand Up @@ -57,7 +57,7 @@ export const FolderForm = observer(() => {
<Label text={t("decks")} isPlain>
{folderForm.decks.value.map((deck, i) => {
return (
<SettingsRow key={i}>
<CardRow key={i}>
<span>{deck.name}</span>
<button
className={cx(reset.button, css({ padding: 8, fontSize: 16 }))}
Expand All @@ -73,7 +73,7 @@ export const FolderForm = observer(() => {
)}
/>
</button>
</SettingsRow>
</CardRow>
);
})}
</Label>
Expand All @@ -85,7 +85,7 @@ export const FolderForm = observer(() => {
) : null}
{folderStore.decksMineFiltered.map((deck) => {
return (
<SettingsRow key={deck.id}>
<CardRow key={deck.id}>
<span>{deck.name}</span>
<button
className={cx(reset.button, css({ padding: 8, fontSize: 16 }))}
Expand All @@ -104,7 +104,7 @@ export const FolderForm = observer(() => {
)}
/>
</button>
</SettingsRow>
</CardRow>
);
})}
</Label>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/folder-review/folder-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ButtonSideAligned } from "../../ui/button-side-aligned.tsx";
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
import { t } from "../../translations/t.ts";
import { useReviewStore } from "../deck-review/store/review-store-context.tsx";
import { SettingsRow } from "../user-settings/settings-row.tsx";
import { CardRow } from "../../ui/card-row.tsx";
import { ListHeader } from "../../ui/list-header.tsx";
import { assert } from "../../lib/typescript/assert.ts";
import { userStore } from "../../store/user-store.ts";
Expand Down Expand Up @@ -187,14 +187,14 @@ export const FolderPreview = observer(() => {
<ListHeader text={t("decks")} />
{folder.decks.map((deck, i) => {
return (
<SettingsRow
<CardRow
key={i}
onClick={() => {
deckListStore.goDeckById(deck.id);
}}
>
{deck.name}
</SettingsRow>
</CardRow>
);
})}
{folder.cardsToReview.length === 0 && (
Expand Down
14 changes: 7 additions & 7 deletions src/screens/share-deck/share-deck-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { screenStore } from "../../store/screen-store.ts";
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
import { t } from "../../translations/t.ts";
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
import { SettingsRow } from "../user-settings/settings-row.tsx";
import { CardRow } from "../../ui/card-row.tsx";
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
import { HintTransparent } from "../../ui/hint-transparent.tsx";
import { Label } from "../../ui/label.tsx";
Expand Down Expand Up @@ -36,25 +36,25 @@ export const ShareDeckSettings = observer(() => {

return (
<Screen title={t("share_deck_settings")}>
<SettingsRow>
<CardRow>
<span>{t("share_one_time_access_link")}</span>
<RadioSwitcher
isOn={store.form.isOneTime.value}
onToggle={store.form.isOneTime.toggle}
/>
</SettingsRow>
</CardRow>
<HintTransparent>
{t("share_one_time_access_link_description")}
</HintTransparent>
{store.form.isOneTime.value && (
<>
<SettingsRow>
<CardRow>
<span>{t("share_access_duration")}</span>
<RadioSwitcher
isOn={store.form.isAccessDuration.value}
onToggle={store.form.isAccessDuration.toggle}
/>
</SettingsRow>
</CardRow>
</>
)}
{store.form.isOneTime.value && store.form.isAccessDuration.value && (
Expand All @@ -64,13 +64,13 @@ export const ShareDeckSettings = observer(() => {
</Label>
)}

<SettingsRow
<CardRow
onClick={() => {
store.isDeckAccessesOpen.setTrue();
}}
>
{t("share_one_time_links_usage")}
</SettingsRow>
</CardRow>
</Screen>
);
});
4 changes: 4 additions & 0 deletions src/screens/shared/links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const links = {
botChannel: "https://t.me/memo_card_bot_channel",
supportChat: "https://t.me/memocard_support",
};
2 changes: 1 addition & 1 deletion src/screens/shared/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Screen = observer((props: Props) => {
})}
>
<div>
<h3 className={css({ textAlign: "center"})}>{title}</h3>
<h3 className={css({ textAlign: "center" })}>{title}</h3>
{subtitle}
</div>
{children}
Expand Down
30 changes: 23 additions & 7 deletions src/screens/user-settings/user-settings-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useMount } from "../../lib/react/use-mount.ts";
import { generateTimeRange } from "./generate-time-range.tsx";
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
import { useTelegramProgress } from "../../lib/telegram/use-telegram-progress.tsx";
import { SettingsRow } from "./settings-row.tsx";
import { CardRow } from "../../ui/card-row.tsx";
import { RadioSwitcher } from "../../ui/radio-switcher.tsx";
import { theme } from "../../ui/theme.tsx";
import { Select } from "../../ui/select.tsx";
Expand All @@ -16,6 +16,8 @@ import { screenStore } from "../../store/screen-store.ts";
import { HintTransparent } from "../../ui/hint-transparent.tsx";
import { t } from "../../translations/t.ts";
import { Screen } from "../shared/screen.tsx";
import WebApp from "@twa-dev/sdk";
import { links } from "../shared/links.ts";

export const timeRanges = generateTimeRange();

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

return (
<Screen title={t("settings")}>
<SettingsRow>
<CardRow>
<span>{t("settings_review_notifications")}</span>
<span
className={css({
Expand All @@ -58,9 +60,9 @@ export const UserSettingsMain = observer(() => {
onToggle={isRemindNotifyEnabled.toggle}
/>
</span>
</SettingsRow>
</CardRow>
{isRemindNotifyEnabled.value && (
<SettingsRow>
<CardRow>
<span>{t("settings_time")}</span>
<div className={css({ color: theme.linkColor })}>
<Select
Expand All @@ -74,14 +76,14 @@ export const UserSettingsMain = observer(() => {
}))}
/>
</div>
</SettingsRow>
</CardRow>
)}

<HintTransparent>
{t("settings_review_notifications_hint")}
</HintTransparent>

<SettingsRow>
<CardRow>
<span>{t("speaking_cards")}</span>
<span
className={css({
Expand All @@ -94,9 +96,23 @@ export const UserSettingsMain = observer(() => {
onToggle={isSpeakingCardsEnabled.toggle}
/>
</span>
</SettingsRow>
</CardRow>

<HintTransparent>{t("card_speak_description")}</HintTransparent>

<CardRow
onClick={() => {
WebApp.openTelegramLink(links.supportChat);
}}
>
<span
className={css({
color: theme.linkColor,
})}
>
Contact support
</span>
</CardRow>
</Screen>
);
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { observer } from "mobx-react-lite";
import React, { ReactNode } from "react";
import { css } from "@emotion/css";
import { theme } from "../../ui/theme.tsx";
import { theme } from "./theme.tsx";

type Props = {
children: ReactNode;
onClick?: () => void;
};

export const SettingsRow = observer((props: Props) => {
export const CardRow = observer((props: Props) => {
return (
<label
onClick={props.onClick}
Expand Down

0 comments on commit 519a2da

Please sign in to comment.