forked from cerc-io/snowballtools-base
Merge pull request #143 from snowball-tools/template-card-redirect-bug
Template card redirect bug
This commit is contained in:
commit
ff9b08e91d
@ -18,14 +18,14 @@ export default [
|
|||||||
name: 'Kotlin',
|
name: 'Kotlin',
|
||||||
icon: 'kotlin',
|
icon: 'kotlin',
|
||||||
repoFullName: '',
|
repoFullName: '',
|
||||||
isComingSoon: false,
|
isComingSoon: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4',
|
id: '4',
|
||||||
name: 'React Native',
|
name: 'React Native',
|
||||||
icon: 'react-native',
|
icon: 'react-native',
|
||||||
repoFullName: '',
|
repoFullName: '',
|
||||||
isComingSoon: false,
|
isComingSoon: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '5',
|
id: '5',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import React, { ComponentPropsWithoutRef, useCallback } from 'react';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
import {
|
import {
|
||||||
ArrowRightCircleIcon,
|
ArrowRightCircleIcon,
|
||||||
@ -6,8 +7,7 @@ import {
|
|||||||
TemplateIconType,
|
TemplateIconType,
|
||||||
} from 'components/shared/CustomIcon';
|
} from 'components/shared/CustomIcon';
|
||||||
import { Tag } from 'components/shared/Tag';
|
import { Tag } from 'components/shared/Tag';
|
||||||
import React, { ComponentPropsWithoutRef, useCallback } from 'react';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useToast } from 'components/shared/Toast';
|
import { useToast } from 'components/shared/Toast';
|
||||||
import { cn } from 'utils/classnames';
|
import { cn } from 'utils/classnames';
|
||||||
|
|
||||||
@ -24,9 +24,13 @@ export interface TemplateCardProps extends ComponentPropsWithoutRef<'div'> {
|
|||||||
isGitAuth: boolean;
|
isGitAuth: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TemplateCard = ({ template, isGitAuth }: TemplateCardProps) => {
|
export const TemplateCard: React.FC<TemplateCardProps> = ({
|
||||||
|
template,
|
||||||
|
isGitAuth,
|
||||||
|
}: TemplateCardProps) => {
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { orgSlug } = useParams();
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
if (template?.isComingSoon) {
|
if (template?.isComingSoon) {
|
||||||
@ -38,7 +42,9 @@ export const TemplateCard = ({ template, isGitAuth }: TemplateCardProps) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isGitAuth) {
|
if (isGitAuth) {
|
||||||
return navigate(`/template?templateId=${template.id}`);
|
return navigate(
|
||||||
|
`/${orgSlug}/projects/create/template?templateId=${template.id}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return toast({
|
return toast({
|
||||||
id: 'connect-git-account',
|
id: 'connect-git-account',
|
||||||
@ -46,7 +52,7 @@ export const TemplateCard = ({ template, isGitAuth }: TemplateCardProps) => {
|
|||||||
variant: 'error',
|
variant: 'error',
|
||||||
onDismiss: dismiss,
|
onDismiss: dismiss,
|
||||||
});
|
});
|
||||||
}, [isGitAuth, navigate, template, toast]);
|
}, [orgSlug, dismiss, isGitAuth, navigate, template, toast]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
Loading…
Reference in New Issue
Block a user