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