gitscope
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/users/dialogs/settings/user-info/qrcode.tsx · v0.3.0-alpha9
Source
1 857e289 Mrdn 2y ago
2 6955aba Mrdn 2y ago import {
3 6955aba Mrdn 2y ago useUserSubscriptionRevokeCmd,
4 6955aba Mrdn 2y ago UserType
5 6955aba Mrdn 2y ago } from '@marzneshin/features/users';
6 857e289 Mrdn 2y ago import QRCode from "react-qr-code";
7 857e289 Mrdn 2y ago import { QrCodeIcon } from "lucide-react";
8 857e289 Mrdn 2y ago import { FC } from 'react'
9 6955aba Mrdn 2y ago import {
10 6955aba Mrdn 2y ago Button,
11 6955aba Mrdn 2y ago Card,
12 6955aba Mrdn 2y ago CardContent,
13 6955aba Mrdn 2y ago CardHeader,
14 6955aba Mrdn 2y ago CardTitle
15 6955aba Mrdn 2y ago } from '@marzneshin/components';
16 857e289 Mrdn 2y ago import { useTranslation } from 'react-i18next';
17 857e289 Mrdn 2y ago import { SubscriptionLinkButton } from './subcription-link-button';
18 912d3dc Mrdn 2y ago import { getSubscriptionLink } from '@marzneshin/utils';
19 857e289 Mrdn 2y ago
20 857e289 Mrdn 2y ago interface QRCodeProps {
21 857e289 Mrdn 2y ago entity: UserType
22 857e289 Mrdn 2y ago }
23 857e289 Mrdn 2y ago
24 857e289 Mrdn 2y ago export const QRCodeSection: FC<QRCodeProps> = (
25 857e289 Mrdn 2y ago { entity }
26 857e289 Mrdn 2y ago ) => {
27 912d3dc Mrdn 2y ago const subscribeQrLink = getSubscriptionLink(entity.subscription_url);
28 6955aba Mrdn 2y ago const { mutate: revokeSubscription } = useUserSubscriptionRevokeCmd()
29 857e289 Mrdn 2y ago const { t } = useTranslation()
30 857e289 Mrdn 2y ago return (
31 857e289 Mrdn 2y ago <Card>
32 6955aba Mrdn 2y ago <CardHeader className="flex flex-row justify-between items-center w-full">
33 857e289 Mrdn 2y ago <CardTitle className="flex flex-row gap-4 justify-start">
34 857e289 Mrdn 2y ago <QrCodeIcon />
35 857e289 Mrdn 2y ago {t('subscription')}
36 857e289 Mrdn 2y ago </CardTitle>
37 6955aba Mrdn 2y ago <Button className="w-[9rem]" onClick={() => revokeSubscription(entity)}>
38 6955aba Mrdn 2y ago {t('page.users.revoke_subscription')}
39 6955aba Mrdn 2y ago </Button>
40 857e289 Mrdn 2y ago </CardHeader>
41 857e289 Mrdn 2y ago <CardContent className='flex flex-col justify-center items-center py-10 w-full h-full'>
42 857e289 Mrdn 2y ago <div className="flex flex-col gap-3 justify-center items-center w-1/2 h-1/2">
43 857e289 Mrdn 2y ago <QRCode
44 857e289 Mrdn 2y ago size={150}
45 857e289 Mrdn 2y ago className="w-full h-full"
46 857e289 Mrdn 2y ago value={subscribeQrLink}
47 857e289 Mrdn 2y ago />
48 857e289 Mrdn 2y ago <SubscriptionLinkButton subscriptionLink={subscribeQrLink} />
49 857e289 Mrdn 2y ago </div>
50 857e289 Mrdn 2y ago </CardContent>
51 857e289 Mrdn 2y ago </Card>
52 857e289 Mrdn 2y ago );
53 857e289 Mrdn 2y ago }