|
|
@ -1,9 +1,14 @@
|
|
|
|
// Import { useState } from 'react';
|
|
|
|
// Import { useState } from 'react';
|
|
|
|
// import { setTimeout } from 'timers';
|
|
|
|
// import { setTimeout } from 'timers';
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { DocumentDuplicateIcon } from '@heroicons/react/20/solid';
|
|
|
|
import { DocumentDuplicateIcon } from '@heroicons/react/20/solid';
|
|
|
|
|
|
|
|
import { BookmarkSquareIcon, CheckIcon } from '@heroicons/react/24/outline';
|
|
|
|
import { Button, TextInput, useToast } from '@tih/ui';
|
|
|
|
import { Button, TextInput, useToast } from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
|
|
|
|
|
|
|
|
|
|
|
|
import { copyProfileLink, getProfileLink } from '~/utils/offers/link';
|
|
|
|
import { copyProfileLink, getProfileLink } from '~/utils/offers/link';
|
|
|
|
|
|
|
|
import { trpc } from '~/utils/trpc';
|
|
|
|
|
|
|
|
|
|
|
|
type OfferProfileSaveProps = Readonly<{
|
|
|
|
type OfferProfileSaveProps = Readonly<{
|
|
|
|
profileId: string;
|
|
|
|
profileId: string;
|
|
|
@ -15,16 +20,39 @@ export default function OffersProfileSave({
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
}: OfferProfileSaveProps) {
|
|
|
|
}: OfferProfileSaveProps) {
|
|
|
|
const { showToast } = useToast();
|
|
|
|
const { showToast } = useToast();
|
|
|
|
// Const [isSaving, setSaving] = useState(false);
|
|
|
|
const { event: gaEvent } = useGoogleAnalytics();
|
|
|
|
// const [isSaved, setSaved] = useState(false);
|
|
|
|
const [isSaved, setSaved] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const saveMutation = trpc.useMutation(
|
|
|
|
|
|
|
|
['offers.user.profile.addToUserProfile'],
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
onError: () => {
|
|
|
|
|
|
|
|
showToast({
|
|
|
|
|
|
|
|
title: `Failed to saved to dashboard!`,
|
|
|
|
|
|
|
|
variant: 'failure',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
|
|
showToast({
|
|
|
|
|
|
|
|
title: `Saved to your repository!`,
|
|
|
|
|
|
|
|
variant: 'success',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// Const saveProfile = () => {
|
|
|
|
const handleSave = () => {
|
|
|
|
// setSaving(true);
|
|
|
|
saveMutation.mutate({
|
|
|
|
// setTimeout(() => {
|
|
|
|
profileId,
|
|
|
|
// setSaving(false);
|
|
|
|
token: token as string,
|
|
|
|
// setSaved(true);
|
|
|
|
});
|
|
|
|
// }, 5);
|
|
|
|
setSaved(true);
|
|
|
|
// };
|
|
|
|
gaEvent({
|
|
|
|
|
|
|
|
action: 'offers.profile_submission_save_to_profile',
|
|
|
|
|
|
|
|
category: 'engagement',
|
|
|
|
|
|
|
|
label: 'Save to profile in profile submission',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="flex w-full justify-center">
|
|
|
|
<div className="flex w-full justify-center">
|
|
|
@ -57,24 +85,29 @@ export default function OffersProfileSave({
|
|
|
|
title: `Profile edit link copied to clipboard!`,
|
|
|
|
title: `Profile edit link copied to clipboard!`,
|
|
|
|
variant: 'success',
|
|
|
|
variant: 'success',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gaEvent({
|
|
|
|
|
|
|
|
action: 'offers.profile_submission_copy_edit_profile_link',
|
|
|
|
|
|
|
|
category: 'engagement',
|
|
|
|
|
|
|
|
label: 'Copy Edit Profile Link in Profile Submission',
|
|
|
|
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</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 user account. It will still only be editable by
|
|
|
|
profile under your account's respository. It will still only be
|
|
|
|
you.
|
|
|
|
editable by you.
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<div className="mb-20">
|
|
|
|
<div className="mb-20">
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
disabled={isSaved}
|
|
|
|
disabled={isSaved}
|
|
|
|
icon={isSaved ? CheckIcon : BookmarkSquareIcon}
|
|
|
|
icon={isSaved ? CheckIcon : BookmarkSquareIcon}
|
|
|
|
isLoading={isSaving}
|
|
|
|
isLoading={saveMutation.isLoading}
|
|
|
|
label={isSaved ? 'Saved to user profile' : 'Save to user profile'}
|
|
|
|
label={isSaved ? 'Saved to user profile' : 'Save to user profile'}
|
|
|
|
variant="primary"
|
|
|
|
variant="primary"
|
|
|
|
onClick={saveProfile}
|
|
|
|
onClick={handleSave}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div> */}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|