review list
This commit is contained in:
@@ -18,6 +18,7 @@ import { useGetProfile } from "../../../(Profile)/profile/hooks/userProfileData"
|
||||
import { NegativePointEnum, PositivePointEnum } from "../enum/ReviewPoints";
|
||||
import { useCreateReview, useGetFoodReviews } from "../hooks/useFoodData";
|
||||
import { CreateReviewType } from "../types/ReviewTypes";
|
||||
import { isReviewApproved } from "../../about/types/Types";
|
||||
|
||||
type Props = {
|
||||
foodId: string;
|
||||
@@ -53,7 +54,7 @@ function FoodReviewsSection({ foodId }: Props) {
|
||||
const [negativePoints, setNegativePoints] = useState<string[]>([]);
|
||||
const [formKey, setFormKey] = useState(0);
|
||||
|
||||
const reviews = (reviewsData?.data || []).filter((review) => review.isApproved);
|
||||
const reviews = (reviewsData?.data || []).filter(isReviewApproved);
|
||||
const sortedReviews = [...reviews].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
||||
|
||||
const getTranslationKey = (point: string, isPositive: boolean): string => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useQueryState } from 'next-usequerystate';
|
||||
import Image from 'next/image';
|
||||
import React from 'react'
|
||||
import { useGetAbout, useGetReviews, useGetSchedules } from './hooks/useAboutData';
|
||||
import { isReviewApproved } from './types/Types';
|
||||
import AboutSkeleton from './components/AboutSkeleton';
|
||||
import { glassSurfaceCard, glassSurfaceCardFlat, glassSurfaceFlat } from '@/lib/styles/glassSurface';
|
||||
|
||||
@@ -223,7 +224,7 @@ function AboutPage() {
|
||||
};
|
||||
|
||||
const secondTab = () => {
|
||||
const reviews = (reviewsData?.data || []).filter(review => review.isApproved);
|
||||
const reviews = (reviewsData?.data || []).filter(isReviewApproved);
|
||||
|
||||
const sortedReviews = [...reviews].sort((a, b) => {
|
||||
if (sorting === '0') {
|
||||
|
||||
@@ -55,65 +55,81 @@ export interface Restaurant {
|
||||
|
||||
export interface ReviewFood {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
restaurant: string;
|
||||
category: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
deletedAt?: string | null;
|
||||
restaurant?: string;
|
||||
category?: string;
|
||||
title: string;
|
||||
desc: string | null;
|
||||
content: string | null;
|
||||
price: number;
|
||||
points: number | null;
|
||||
order: number | null;
|
||||
prepareTime: number | null;
|
||||
sat: boolean;
|
||||
sun: boolean;
|
||||
mon: boolean;
|
||||
breakfast: boolean;
|
||||
noon: boolean;
|
||||
dinner: boolean;
|
||||
stock: number;
|
||||
stockDefault: number;
|
||||
isActive: boolean;
|
||||
images: string[];
|
||||
inPlaceServe: boolean;
|
||||
pickupServe: boolean;
|
||||
rate: number;
|
||||
discount: number;
|
||||
isSpecialOffer: boolean;
|
||||
desc?: string | null;
|
||||
content?: string[] | string | null;
|
||||
price?: number;
|
||||
points?: number | null;
|
||||
order?: number | null;
|
||||
prepareTime?: number | null;
|
||||
weekDays?: number[];
|
||||
mealTypes?: string[];
|
||||
sat?: boolean;
|
||||
sun?: boolean;
|
||||
mon?: boolean;
|
||||
breakfast?: boolean;
|
||||
noon?: boolean;
|
||||
dinner?: boolean;
|
||||
stock?: number;
|
||||
stockDefault?: number;
|
||||
isActive?: boolean;
|
||||
images?: string[];
|
||||
inPlaceServe?: boolean;
|
||||
pickupServe?: boolean;
|
||||
rate?: number;
|
||||
score?: number;
|
||||
discount?: number;
|
||||
isSpecialOffer?: boolean;
|
||||
}
|
||||
|
||||
export interface ReviewUser {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
deletedAt?: string | null;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
birthDate: string;
|
||||
marriageDate: string;
|
||||
referrer: string | null;
|
||||
isActive: boolean;
|
||||
gender: boolean;
|
||||
wallet: number;
|
||||
points: number;
|
||||
phone: string;
|
||||
birthDate?: string;
|
||||
marriageDate?: string;
|
||||
referrer?: string | null;
|
||||
isActive?: boolean;
|
||||
gender?: boolean;
|
||||
wallet?: number;
|
||||
points?: number;
|
||||
phone?: string;
|
||||
avatarUrl?: string | null;
|
||||
}
|
||||
|
||||
export type ReviewStatus = "approved" | "pending" | "rejected";
|
||||
|
||||
export interface Review {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
order: string;
|
||||
isBuyer?: boolean;
|
||||
order?: string;
|
||||
food: ReviewFood;
|
||||
user: ReviewUser;
|
||||
comment: string;
|
||||
rating: number;
|
||||
positivePoints: string[];
|
||||
negativePoints: string[];
|
||||
isApproved: boolean;
|
||||
status?: ReviewStatus;
|
||||
/** @deprecated use status */
|
||||
isApproved?: boolean;
|
||||
}
|
||||
|
||||
export function isReviewApproved(review: Review): boolean {
|
||||
if (review.status) {
|
||||
return review.status === "approved";
|
||||
}
|
||||
return review.isApproved === true;
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// export const API_BASE_URL = "https://dmenuplus-api-production.dev.danakcorp.com";
|
||||
export const API_BASE_URL = "http://192.168.1.107:2000";
|
||||
// export const API_BASE_URL = "https://dmenu-api.danakcorp.com";
|
||||
// export const API_BASE_URL = "http://192.168.1.107:2000";
|
||||
export const API_BASE_URL = "https://dmenu-api.danakcorp.com";
|
||||
process.env.NEXT_PUBLIC_API_URL ?? (process.env.NODE_ENV === "development" ? "http://192.168.99.131:2000" : "https://dmenu-api.danakcorp.com");
|
||||
export const TOKEN_NAME = "dmenu-t";
|
||||
export const REFRESH_TOKEN_NAME = "dmenu-rt";
|
||||
|
||||
Reference in New Issue
Block a user