[offers][fix] fix toggle save

pull/471/head
Zhang Ziqing 3 years ago
parent 203043da3e
commit 0e38b64ef0

@ -7,7 +7,7 @@ const navigation: ProductNavigationItems = [
const navigationAuthenticated: ProductNavigationItems = [ const navigationAuthenticated: ProductNavigationItems = [
{ href: '/offers/submit', name: 'Analyze your offers' }, { href: '/offers/submit', name: 'Analyze your offers' },
{ href: '/offers/dashboard', name: 'Your repository' }, { href: '/offers/dashboard', name: 'Your dashboard' },
{ href: '/offers/features', name: 'Features' }, { href: '/offers/features', name: 'Features' },
]; ];

@ -34,7 +34,7 @@ export default function OffersProfileSave({
}, },
onSuccess: () => { onSuccess: () => {
showToast({ showToast({
title: `Saved to your repository!`, title: `Saved to your dashboard!`,
variant: 'success', variant: 'success',
}); });
}, },
@ -95,8 +95,8 @@ export default function OffersProfileSave({
</div> </div>
<p className="mb-5 text-slate-900"> <p className="mb-5 text-slate-900">
If you do not want to keep the edit link, you can opt to save this If you do not want to keep the edit link, you can opt to save this
profile under your account's respository. It will still only be profile under your account's dashboard. It will still only be editable
editable by you. by you.
</p> </p>
<div className="mb-20"> <div className="mb-20">
<Button <Button

@ -41,7 +41,7 @@ export default function ProfileHeader({
setSelectedTab, setSelectedTab,
}: ProfileHeaderProps) { }: ProfileHeaderProps) {
const [isDialogOpen, setIsDialogOpen] = useState(false); const [isDialogOpen, setIsDialogOpen] = useState(false);
// Const [saved, setSaved] = useState(isSaved); const [saved, setSaved] = useState(isSaved);
const router = useRouter(); const router = useRouter();
const trpcContext = trpc.useContext(); const trpcContext = trpc.useContext();
const { offerProfileId = '', token = '' } = router.query; const { offerProfileId = '', token = '' } = router.query;
@ -60,7 +60,7 @@ export default function ProfileHeader({
}); });
}, },
onSuccess: () => { onSuccess: () => {
// SetSaved(true); setSaved(true);
showToast({ showToast({
title: `Saved to dashboard!`, title: `Saved to dashboard!`,
variant: 'success', variant: 'success',
@ -79,7 +79,7 @@ export default function ProfileHeader({
}); });
}, },
onSuccess: () => { onSuccess: () => {
// SetSaved(false); setSaved(false);
showToast({ showToast({
title: `Removed from dashboard!`, title: `Removed from dashboard!`,
variant: 'success', variant: 'success',
@ -90,7 +90,7 @@ export default function ProfileHeader({
); );
const toggleSaved = () => { const toggleSaved = () => {
if (isSaved) { if (saved) {
unsaveMutation.mutate({ profileId: offerProfileId as string }); unsaveMutation.mutate({ profileId: offerProfileId as string });
} else { } else {
saveMutation.mutate({ saveMutation.mutate({
@ -111,10 +111,10 @@ export default function ProfileHeader({
disabled={ disabled={
isLoading || saveMutation.isLoading || unsaveMutation.isLoading isLoading || saveMutation.isLoading || unsaveMutation.isLoading
} }
icon={isSaved ? BookmarkIconSolid : BookmarkIconOutline} icon={saved ? BookmarkIconSolid : BookmarkIconOutline}
isLabelHidden={true} isLabelHidden={true}
isLoading={saveMutation.isLoading || unsaveMutation.isLoading} isLoading={saveMutation.isLoading || unsaveMutation.isLoading}
label={isSaved ? 'Remove from account' : 'Save to your account'} label={saved ? 'Remove from account' : 'Save to your account'}
size="md" size="md"
variant="tertiary" variant="tertiary"
onClick={toggleSaved} onClick={toggleSaved}

@ -71,11 +71,11 @@ export default function ProfilesDashboard() {
{!userProfilesQuery.isLoading && ( {!userProfilesQuery.isLoading && (
<div className="mt-8 overflow-y-auto"> <div className="mt-8 overflow-y-auto">
<h1 className="mx-auto mb-4 w-3/4 text-start text-4xl font-bold text-slate-900"> <h1 className="mx-auto mb-4 w-3/4 text-start text-4xl font-bold text-slate-900">
Your repository Your dashboard
</h1> </h1>
<p className="mx-auto w-3/4 text-start text-xl text-slate-900"> <p className="mx-auto w-3/4 text-start text-xl text-slate-900">
Save your offer profiles to respository to easily access and edit Save your offer profiles to dashboard to easily access and edit them
them later. later.
</p> </p>
<div className="justfy-center mt-8 flex w-screen"> <div className="justfy-center mt-8 flex w-screen">
<ul className="mx-auto w-3/4 space-y-3" role="list"> <ul className="mx-auto w-3/4 space-y-3" role="list">

Loading…
Cancel
Save