Skip to content
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

feat: 프로필 링크 복사 구현 #365

Merged
merged 3 commits into from
Mar 12, 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
4 changes: 2 additions & 2 deletions src/__test__/customRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RenderOptions, render } from "@testing-library/react";
import { PropsWithChildren } from "react";

import { OduckApiContext } from "@/contexts/OduckApiContext";
import { ToastContextProvider } from "@/contexts/ToastContext";
import { theme } from "@/styles/theme";

export default function customRender(
Expand All @@ -23,8 +24,7 @@ export function RenderWithProviders(
<OduckApiContext.Provider value={oduck}>
<QueryClientProvider client={testClient}>
<ThemeProvider theme={theme}>
{children}
{/* </IconContext.Provider> */}
<ToastContextProvider>{children}</ToastContextProvider>
</ThemeProvider>
</QueryClientProvider>
</OduckApiContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState } from "react";
import { useNavigate } from "react-router-dom";

import BackdropPortal from "@/components/Backdrop/BackdropPortal";
import useToast from "@/components/Toast/useToast";

import DropDownModal from "../DropDownModal";
import useDropDownModal from "../DropDownModal/useDropDownModal";
Expand All @@ -16,16 +17,27 @@ import {

interface ProfileSetupButtonProps {
isMine: boolean;
userName: string;
}

export default function ProfileSetupButton({
isMine,
userName,
}: ProfileSetupButtonProps) {
const { isDropDownModalOpen, handleDropDownModalToggle } = useDropDownModal();
const [isReportModalOpen, setIsReportModalOpen] = useState(false);
const handleReportModalToggle = () => setIsReportModalOpen((prev) => !prev);
const navigate = useNavigate();
const toast = useToast();
const handleLinkToEditClick = () => navigate("/profile/edit");
const handleProfileLinkCopyClick = () => {
window.navigator.clipboard //
.writeText(`https://oduck.io/users/${userName}`)
.then(
() => toast.success({ message: "링크가 복사되었어요." }),
() => toast.error({ message: "링크 복사에 실패했어요." }),
);
};
const handleReportClick = () => {
handleDropDownModalToggle();
handleReportModalToggle();
Expand Down Expand Up @@ -60,6 +72,7 @@ export default function ProfileSetupButton({
size="lg"
variant="solid"
color="neutral"
onClick={handleProfileLinkCopyClick}
>
프로필 링크 복사
</DropDownModal.Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ describe("ProfileSetupButton", () => {
customRender(
<MemoryRouter>
<ProfileImageSection>
<ProfileImageSection.ProfileSetupButton isMine={true} />
<ProfileImageSection.ProfileSetupButton
isMine={true}
userName="testUser"
/>
</ProfileImageSection>
</MemoryRouter>,
);
Expand All @@ -38,7 +41,10 @@ describe("ProfileSetupButton", () => {
path="/"
element={
<ProfileImageSection>
<ProfileImageSection.ProfileSetupButton isMine={true} />
<ProfileImageSection.ProfileSetupButton
isMine={true}
userName="testUser"
/>
</ProfileImageSection>
}
/>
Expand All @@ -61,7 +67,10 @@ describe("ProfileSetupButton", () => {
customRender(
<MemoryRouter>
<ProfileImageSection>
<ProfileImageSection.ProfileSetupButton isMine={false} />
<ProfileImageSection.ProfileSetupButton
isMine={false}
userName="testUser"
/>
</ProfileImageSection>
</MemoryRouter>,
);
Expand Down
5 changes: 4 additions & 1 deletion src/features/users/routes/Profile/AboutMe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export default function AboutMe({
<>
<ProfileImageSection>
<ProfileImageSection.Art src={backgroundImage} userName={name} />
<ProfileImageSection.ProfileSetupButton isMine={isMine} />
<ProfileImageSection.ProfileSetupButton
isMine={isMine}
userName={name}
/>
<ProfileImageSection.ProfileAvatar>
<ProfileAvatar.Avatar src={thumbnail} userName={name} size="xl" />
</ProfileImageSection.ProfileAvatar>
Expand Down
Loading