2022-08-31 06:33:37 +05:00
|
|
|
/*
|
|
|
|
|
This file is part of the Notesnook project (https://notesnook.com/)
|
|
|
|
|
|
2023-01-16 13:44:52 +05:00
|
|
|
Copyright (C) 2023 Streetwriters (Private) Limited
|
2022-08-31 06:33:37 +05:00
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2022-08-30 16:13:11 +05:00
|
|
|
|
2022-08-26 16:19:39 +05:00
|
|
|
import dayjs from "dayjs";
|
2022-08-29 16:19:17 +05:00
|
|
|
import React from "react";
|
2022-08-26 16:19:39 +05:00
|
|
|
import { View } from "react-native";
|
|
|
|
|
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
|
|
|
|
import { TimeSince } from "../../components/ui/time-since";
|
|
|
|
|
import Heading from "../../components/ui/typography/heading";
|
|
|
|
|
import Paragraph from "../../components/ui/typography/paragraph";
|
2023-08-01 12:07:21 +05:00
|
|
|
import { useThemeColors } from "@notesnook/theme";
|
2022-08-29 16:19:17 +05:00
|
|
|
import { useUserStore } from "../../stores/use-user-store";
|
2022-08-26 16:19:39 +05:00
|
|
|
import { SUBSCRIPTION_STATUS_STRINGS } from "../../utils/constants";
|
|
|
|
|
import { SIZE } from "../../utils/size";
|
|
|
|
|
import { SectionItem } from "./section-item";
|
|
|
|
|
export const getTimeLeft = (t2) => {
|
|
|
|
|
let daysRemaining = dayjs(t2).diff(dayjs(), "days");
|
2021-11-24 09:57:23 +05:00
|
|
|
return {
|
2022-08-26 16:19:39 +05:00
|
|
|
time: dayjs(t2).diff(dayjs(), daysRemaining === 0 ? "hours" : "days"),
|
2021-11-24 09:57:23 +05:00
|
|
|
isHour: daysRemaining === 0
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-07 04:20:13 +05:00
|
|
|
const SettingsUserSection = ({ item }) => {
|
2023-08-01 12:07:21 +05:00
|
|
|
const { colors } = useThemeColors();
|
2022-08-26 16:19:39 +05:00
|
|
|
const user = useUserStore((state) => state.user);
|
|
|
|
|
const lastSynced = useUserStore((state) => state.lastSynced);
|
2022-04-07 04:20:13 +05:00
|
|
|
|
2021-11-24 09:57:23 +05:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{user ? (
|
|
|
|
|
<>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12,
|
2022-04-07 04:20:13 +05:00
|
|
|
marginTop: 15
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-24 09:57:23 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
alignSelf: "center",
|
|
|
|
|
width: "100%",
|
2021-11-24 09:57:23 +05:00
|
|
|
paddingVertical: 12,
|
2023-08-01 12:07:21 +05:00
|
|
|
backgroundColor: colors.primary.background,
|
2021-11-24 09:57:23 +05:00
|
|
|
borderRadius: 5
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-24 09:57:23 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
justifyContent: "space-between",
|
|
|
|
|
flexDirection: "row",
|
2022-04-07 04:20:13 +05:00
|
|
|
paddingBottom: 4
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-24 09:57:23 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
flexDirection: "row",
|
|
|
|
|
width: "100%",
|
|
|
|
|
justifyContent: "space-between"
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-24 09:57:23 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
flexDirection: "row"
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-04-07 04:20:13 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
alignItems: "center"
|
2022-04-07 04:20:13 +05:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2023-08-01 12:07:21 +05:00
|
|
|
backgroundColor: colors.primary.shade,
|
2022-04-07 04:20:13 +05:00
|
|
|
borderRadius: 100,
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
2022-08-26 16:19:39 +05:00
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center"
|
2022-04-07 04:20:13 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-08-26 16:19:39 +05:00
|
|
|
<Icon
|
|
|
|
|
size={SIZE.xl}
|
2023-08-01 12:07:21 +05:00
|
|
|
color={colors.primary.accent}
|
2022-08-26 16:19:39 +05:00
|
|
|
name="account-outline"
|
|
|
|
|
/>
|
2022-04-07 04:20:13 +05:00
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2022-04-08 02:54:45 +05:00
|
|
|
marginLeft: 10,
|
|
|
|
|
flexGrow: 1
|
2022-04-07 04:20:13 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2023-08-01 12:07:21 +05:00
|
|
|
<Heading color={colors.primary.accent} size={SIZE.xs}>
|
2022-08-26 16:19:39 +05:00
|
|
|
{SUBSCRIPTION_STATUS_STRINGS[
|
|
|
|
|
user.subscription?.type
|
2022-09-21 20:13:00 +05:00
|
|
|
]?.toUpperCase() || "Basic"}
|
2022-04-07 04:20:13 +05:00
|
|
|
</Heading>
|
|
|
|
|
|
2023-08-01 12:07:21 +05:00
|
|
|
<Paragraph color={colors.primary.heading} size={SIZE.sm}>
|
2022-04-07 04:20:13 +05:00
|
|
|
{user?.email}
|
|
|
|
|
</Paragraph>
|
2023-08-01 12:07:21 +05:00
|
|
|
<Paragraph color={colors.secondary.paragraph} size={SIZE.xs}>
|
2022-08-26 16:19:39 +05:00
|
|
|
Last synced{" "}
|
2022-04-07 04:20:13 +05:00
|
|
|
<TimeSince
|
2023-08-01 12:07:21 +05:00
|
|
|
style={{ fontSize: SIZE.xs, color: colors.secondary.paragraph }}
|
2022-04-07 04:20:13 +05:00
|
|
|
time={lastSynced}
|
|
|
|
|
/>
|
|
|
|
|
</Paragraph>
|
|
|
|
|
</View>
|
2021-11-24 09:57:23 +05:00
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
|
2022-08-26 16:19:39 +05:00
|
|
|
{item.sections.map((item) => (
|
2022-04-07 04:20:13 +05:00
|
|
|
<SectionItem key={item.name} item={item} />
|
|
|
|
|
))}
|
2021-11-24 09:57:23 +05:00
|
|
|
</>
|
|
|
|
|
) : null}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SettingsUserSection;
|