Skip to content
Open
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
3 changes: 3 additions & 0 deletions apps/web/src/assets/icon/icon-thumb-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 80 additions & 12 deletions apps/web/src/components/review/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,55 @@ import {
generateShadowCSS,
} from '@review-canvas/theme';

// import ThumbUpIcon from '@/assets/icon/icon-thumb-up.svg';
import { Star } from '@/components/review/star.tsx';
import { useReviewItemStyle } from '@/contexts/style/review-item.ts';
import useMessageToShop from '@/hooks/use-message-to-shop.ts';
import type { ReplyItem } from '@/services/api-types/review';
import type { ReviewItemProps } from '@/services/api-types/review';
import { useReviewService } from '@/services/review.tsx';
import { useConnectedShop } from '@/state/shop.ts';
import { MESSAGE_TYPES } from '@/utils/message';

import Reply from './reply';

interface ReviewItemProps {
id: number;
rate: number;
content: string;
reviewerID: string;
reviewer: string;
replies: ReplyItem[];
}
import { useEffect, useState } from 'react';

export default function ReviewItem(props: ReviewItemProps) {
const style = useReviewItemStyle();
const { userID } = useConnectedShop();
const reviewService = useReviewService();
const message = useMessageToShop();
const [count, setCount] = useState(0);

useEffect(() => {
async function fetchData() {
return reviewService.userReviewLike(props.id);
}
void fetchData().then((response) => {
setCount(response.data.count);
});
}, [props.id, reviewService]);

const edit = () => {
message(MESSAGE_TYPES.OPEN_MODAL, {
type: 'edit_review',
url: `/reviews/${props.id}/edit`,
});
};

const deleteReview = () => {
message(MESSAGE_TYPES.OPEN_SELECTING_MODAL, {
type: 'delete',
url: `/reviews/${props.id}/delete`,
});
};

const showReviewDetail = () => {
message(MESSAGE_TYPES.OPEN_MODAL, {
type: 'detail',
url: `/reviews/${props.id}`,
});
};

const createLike = () => {};

return (
<li
css={[
Expand All @@ -63,6 +68,7 @@ export default function ReviewItem(props: ReviewItemProps) {
generateFontCSS(style.font),
generateShadowCSS(style.shadow, style.shadowColor),
css`
border-color: ${style.borderColor};
background-color: ${style.backgroundColor};
display: flex;
flex-direction: column;
Expand All @@ -88,6 +94,68 @@ export default function ReviewItem(props: ReviewItemProps) {
작성자 <span>{props.reviewer}</span>
</div>
<p className="text-left">{props.content}</p>
{/*{style.reviewLike.buttonType !== 'NONE' ? (*/}
{/* <button*/}
{/* onClick={(evt) => {*/}
{/* evt.stopPropagation();*/}
{/* if (userID === props.reviewerID) {*/}
{/* return;*/}
{/* }*/}
{/* }}*/}
{/* css={[*/}
{/* generateBorderRadiusCSS(style.reviewLike.buttonRound),*/}
{/* css`*/}
{/* border-width: 1px;*/}
{/* padding: 2px 6px;*/}
{/* margin-top: 15px;*/}
{/* margin-bottom: 10px;*/}
{/* border-color: ${style.reviewLike.buttonBorderColor};*/}
{/* color: ${style.reviewLike.textColor};*/}
{/* transition:*/}
{/* background-color 0.5s ease,*/}
{/* color 0.5s ease;*/}
{/* display: flex;*/}

{/* &:hover {*/}
{/* background-color: ${style.reviewLike.textColor};*/}
{/* color: white;*/}
{/* }*/}
{/* `,*/}
{/* ]}*/}
{/* >*/}
{/* <ThumbUpIcon />*/}
{/* {style.reviewLike.buttonType === 'THUMB_UP_WITH_TEXT' ? <div className="ml-1">도움돼요!</div> : null}*/}
{/* <div className="ml-1">0</div>*/}
{/* </button>*/}
{/*) : null}*/}
<button
css={[
generateBorderRadiusCSS(style.reviewLike.buttonRound),
css`
border-width: 1px;
padding: 2px 6px;
margin-top: 15px;
margin-bottom: 10px;
border-color: ${style.reviewLike.buttonBorderColor};
color: ${style.reviewLike.textColor};
transition:
background-color 0.5s ease,
color 0.5s ease;
display: flex;

&:hover {
background-color: ${style.reviewLike.textColor};
color: white;
}
`,
]}
onClick={createLike}
type="button"
>
{/*<ThumbUpIcon />*/}
<div className="ml-1">도움돼요!</div>
<div className="ml-1">{count}</div>
</button>
{userID === props.reviewerID ? (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- This is intentional
<div
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/review/reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Reply(props: ReplyItem) {
generateFontCSS(style.font),
generateShadowCSS(style.shadow, style.shadowColor),
css`
background-color: ${style.backgroundColor};
background-color: ${style.replyBackgroundColor};
display: flex;
flex-direction: column;
gap: 8px;
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/contexts/style/review-item.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, useContext } from 'react';

import type { Border, BorderRadius, Font, Margin, Padding, Shadow } from '@review-canvas/theme';
import type { Border, BorderRadius, Font, Margin, Padding, Shadow, ReviewLikeButtonProps } from '@review-canvas/theme';

export interface ReviewItemStyle {
margin: Margin;
Expand All @@ -12,6 +12,8 @@ export interface ReviewItemStyle {
shadow: Shadow;
shadowColor: string;
backgroundColor: string;
replyBackgroundColor: string;
reviewLike: ReviewLikeButtonProps;
}

const ReviewItemStyleContext = createContext<ReviewItemStyle | null>(null);
Expand Down
9 changes: 6 additions & 3 deletions apps/web/src/models/design-property.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {ReviewLikeButtonProps} from "@review-canvas/theme";

export type Shadow = 'NONE' | 'SMALL' | 'MEDIUM' | 'LARGE';
export type FocusAreaLayout = 'BEST_REVIEW_TOP' | 'BEST_REVIEW_BOTTOM' | 'BEST_REVIEW_LEFT' | 'BEST_REVIEW_RIGHT';
export type ReviewAreaLayout = 'REVIEW_TOP' | 'REVIEW_BOTTOM' | 'REVIEW_LEFT' | 'REVIEW_RIGHT';
Expand All @@ -6,6 +8,7 @@ export type AlignmentPosition = 'LEFT' | 'CENTER' | 'RIGHT';
export type DetailViewType = 'SPREAD' | 'MODAL';
export type PagingType = 'PAGE_NUMBER' | 'SEE_MORE_SCROLL';
export type FilterType = 'LIST' | 'DROPDOWN';
export type ReviewLikeButtonType = 'NONE' | 'THUMB_UP_WITH_TEXT' | 'THUMB_UP';

export interface Margin {
left: string;
Expand Down Expand Up @@ -43,11 +46,11 @@ export interface Round {
}

export interface ReviewLike {
buttonType: string;
iconColor: string;
textColor: string;
buttonBorderColor: string;
buttonRound: Round;
buttonType: ReviewLikeButtonType;
iconColor: string;
textColor: string;
}

export interface ReviewLayout {
Expand Down
22 changes: 22 additions & 0 deletions apps/web/src/services/api-types/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export interface RetrieveReviewListResponse {
content: ReviewItem[];
};
}

export interface UserReviewLikeResponse {
success: boolean;
data: {
count: number;
};
}

export interface RetrieveReplyListResponse {
success: boolean;
data: ReplyItem[];
Expand All @@ -45,6 +53,15 @@ export interface ReplyItem {
nickname: string;
}

export interface ReviewItemProps {
id: number;
rate: number;
content: string;
reviewerID: string;
reviewer: string;
replies: ReplyItem[];
}

export type ReviewListSort = 'LATEST' | 'HIGH_SCORE' | 'LOW_SCORE';
export type ReviewListFilter = 'ALL' | 'IMAGE_VIDEO' | 'GENERAL';

Expand All @@ -57,6 +74,11 @@ export interface RetrieveReviewListRequest {
filter?: ReviewListFilter;
}

export interface CreateUserReviewLike {
mallId: string;
memberId: string;
}

export interface RetrieveReviewItemResponse {
success: boolean;
data: ReviewItem;
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/services/design-property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class DesignPropertyService {
shadow: reviewDesignView.shadow,
shadowColor: 'rgba(0, 0, 0, 0.3)',
backgroundColor: reviewDesignView.reviewBackgroundColor,
replyBackgroundColor: reviewDesignView.replyBackgroundColor,
reviewLike: {
buttonBorderColor: reviewDesignView.reviewLike.buttonBorderColor,
buttonRound: reviewDesignView.reviewLike.buttonRound,
buttonType: reviewDesignView.reviewLike.buttonType,
iconColor: reviewDesignView.reviewLike.iconColor,
textColor: reviewDesignView.reviewLike.textColor,
},
};
}
}
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/services/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import type * as TYPE from '@/services/api-types/review.tsx';
import API from '@/utils/api.ts';

class ReviewService {
async userReviewLike(reviewId: number): Promise<TYPE.UserReviewLikeResponse> {
const response = await API.get<TYPE.UserReviewLikeResponse>(`/api/v1/reviews/${reviewId}/like/count`);
return response.data;
}

async list({
mallId,
productNo,
Expand Down