Skip to content

feat: allow/deny lists without verification #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/links/link-sheet/allow-list-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function AllowListSection({
plan,
}: LinkUpgradeOptions) => void;
}) {
const { emailAuthenticated, allowList } = data;
const { emailProtected, allowList } = data;

// Initialize enabled state based on whether allowList is not null and not empty
const [enabled, setEnabled] = useState<boolean>(
Expand All @@ -39,12 +39,12 @@ export default function AllowListSection({
useEffect(() => {
// Update the allowList in the data state when their inputs change
const newAllowList = sanitizeAllowDenyList(allowListInput);
setEnabled((prevEnabled) => prevEnabled && emailAuthenticated);
setEnabled((prevEnabled) => prevEnabled && emailProtected);
setData((prevData) => ({
...prevData,
allowList: emailAuthenticated && enabled ? newAllowList : [],
allowList: emailProtected && enabled ? newAllowList : [],
}));
}, [allowListInput, enabled, emailAuthenticated, setData]);
}, [allowListInput, emailProtected, enabled, setData]);

const handleEnableAllowList = () => {
const updatedEnabled = !enabled;
Expand Down
8 changes: 4 additions & 4 deletions components/links/link-sheet/deny-list-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function DenyListSection({
plan,
}: LinkUpgradeOptions) => void;
}) {
const { emailAuthenticated, denyList } = data;
const { emailProtected, denyList } = data;
// Initialize enabled state based on whether denyList is not null and not empty
const [enabled, setEnabled] = useState<boolean>(
!!denyList && denyList.length > 0,
Expand All @@ -38,12 +38,12 @@ export default function DenyListSection({
useEffect(() => {
// Update the denyList in the data state when their inputs change
const newDenyList = sanitizeAllowDenyList(denyListInput);
setEnabled((prevEnabled) => prevEnabled && emailAuthenticated);
setEnabled((prevEnabled) => prevEnabled && emailProtected);
setData((prevData) => ({
...prevData,
denyList: emailAuthenticated && enabled ? newDenyList : [],
denyList: emailProtected && enabled ? newDenyList : [],
}));
}, [denyListInput, enabled, emailAuthenticated, setData]);
}, [denyListInput, enabled, emailProtected, setData]);

const handleEnableDenyList = () => {
const updatedEnabled = !enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export default function EmailAuthenticationSection({
...data,
emailProtected: updatedEmailAuthentication ? true : emailProtected,
emailAuthenticated: updatedEmailAuthentication,
allowList: updatedEmailAuthentication ? data.allowList : [],
denyList: updatedEmailAuthentication ? data.denyList : [],
});
setEnabled(updatedEmailAuthentication);
};
Expand Down
2 changes: 2 additions & 0 deletions components/links/link-sheet/email-protection-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default function EmailProtectionSection({
emailProtected: updatedEmailProtection,
emailAuthenticated: !updatedEmailProtection && false,
enableAgreement: !updatedEmailProtection && false,
allowList: updatedEmailProtection ? data.allowList : [],
denyList: updatedEmailProtection ? data.denyList : [],
});
setEnabled(updatedEmailProtection);
};
Expand Down