mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
feat: impl menu item feature locks for non-pro users
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Flex, Box, Text } from "rebass";
|
import { Flex, Box, Text } from "rebass";
|
||||||
|
import { useStore as useUserStore } from "../../stores/user-store";
|
||||||
|
|
||||||
function Menu(props) {
|
function Menu(props) {
|
||||||
|
const isPremium = useUserStore((store) => store.isPremium);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
id={props.id}
|
id={props.id}
|
||||||
@@ -38,12 +41,16 @@ function Menu(props) {
|
|||||||
if (props.closeMenu) {
|
if (props.closeMenu) {
|
||||||
props.closeMenu();
|
props.closeMenu();
|
||||||
}
|
}
|
||||||
if (item.onClick) {
|
const onlyPro = item.onlyPro && !isPremium;
|
||||||
|
if (onlyPro && item.onClick) {
|
||||||
item.onClick(props.data);
|
item.onClick(props.data);
|
||||||
|
} else {
|
||||||
|
// TODO show the buy dialog
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
flexDirection="row"
|
flexDirection="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
|
justifyContent="space-between"
|
||||||
py={"8px"}
|
py={"8px"}
|
||||||
px={3}
|
px={3}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -61,6 +68,17 @@ function Menu(props) {
|
|||||||
{item.title}
|
{item.title}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
{item.onlyPro && !isPremium && (
|
||||||
|
<Text
|
||||||
|
fontSize="menu"
|
||||||
|
bg="primary"
|
||||||
|
color="static"
|
||||||
|
px={1}
|
||||||
|
sx={{ borderRadius: "default" }}
|
||||||
|
>
|
||||||
|
Pro
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ function menuItems(note, context) {
|
|||||||
{
|
{
|
||||||
title: note.pinned ? "Unpin" : "Pin",
|
title: note.pinned ? "Unpin" : "Pin",
|
||||||
onClick: () => store.pin(note),
|
onClick: () => store.pin(note),
|
||||||
|
onlyPro: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: note.favorite ? "Unfavorite" : "Favorite",
|
title: note.favorite ? "Unfavorite" : "Favorite",
|
||||||
onClick: () => store.favorite(note),
|
onClick: () => store.favorite(note),
|
||||||
|
onlyPro: true,
|
||||||
},
|
},
|
||||||
{ title: "Edit", onClick: () => editorStore.openSession(note) },
|
{ title: "Edit", onClick: () => editorStore.openSession(note) },
|
||||||
{
|
{
|
||||||
@@ -43,6 +45,7 @@ function menuItems(note, context) {
|
|||||||
unlock(note.id);
|
unlock(note.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onlyPro: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
visible: context ? (context.type === "topic" ? true : false) : false,
|
visible: context ? (context.type === "topic" ? true : false) : false,
|
||||||
|
|||||||
Reference in New Issue
Block a user