[WEB-1319] chore: handled redirection when user is not logged in (#4497)

* chore: handled redirection when user is not logged in

* dev: handle url redirection in space app

* dev: remove user from redis on successful code matching
This commit is contained in:
guru_sainath 2024-05-17 14:27:49 +05:30 committed by GitHub
parent c2e293cf3b
commit 2988d5e429
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 119 additions and 175 deletions

View file

@ -2,11 +2,24 @@
import { useState, useEffect } from "react";
import { observer } from "mobx-react-lite";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { Tooltip } from "@plane/ui";
// helpers
import { queryParamGenerator } from "@/helpers/query-param-generator";
// hooks
import { useIssueDetails, useUser } from "@/hooks/store";
export const IssueVotes: React.FC = observer((props: any) => {
const router = useRouter();
const pathName = usePathname();
const searchParams = useSearchParams();
// query params
const peekId = searchParams.get("peekId") || undefined;
const board = searchParams.get("board") || undefined;
const state = searchParams.get("state") || undefined;
const priority = searchParams.get("priority") || undefined;
const labels = searchParams.get("labels") || undefined;
const { workspaceSlug, projectId } = props;
// states
const [isSubmitting, setIsSubmitting] = useState(false);
@ -49,6 +62,9 @@ export const IssueVotes: React.FC = observer((props: any) => {
const VOTES_LIMIT = 1000;
// derived values
const { queryParam } = queryParamGenerator({ peekId, board, state, priority, labels });
return (
<div className="flex items-center gap-2">
{/* upvote button 👇 */}
@ -74,7 +90,7 @@ export const IssueVotes: React.FC = observer((props: any) => {
disabled={isSubmitting}
onClick={(e) => {
if (user) handleVote(e, 1);
// userStore.requiredLogin(() => {});
else router.push(`/?next_path=${pathName}?${queryParam}`);
}}
className={`flex items-center justify-center gap-x-1 overflow-hidden rounded border px-2 focus:outline-none ${
isUpVotedByUser ? "border-custom-primary-200 text-custom-primary-200" : "border-custom-border-300"
@ -108,7 +124,7 @@ export const IssueVotes: React.FC = observer((props: any) => {
disabled={isSubmitting}
onClick={(e) => {
if (user) handleVote(e, -1);
// userStore.requiredLogin(() => {});
else router.push(`/?next_path=${pathName}?${queryParam}`);
}}
className={`flex items-center justify-center gap-x-1 overflow-hidden rounded border px-2 focus:outline-none ${
isDownVotedByUser ? "border-red-600 text-red-600" : "border-custom-border-300"