forked from Gila-part4/Gila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.ts
74 lines (63 loc) · 2.01 KB
/
type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { z } from 'zod';
import {
Activity,
ActivityRequest,
Answer,
User as DbUser,
Favorite,
Question,
} from '@prisma/client';
import { LoginSchema, RegisterSchema } from '@/schema';
export type ActionType<T> = {
success: boolean;
message: string;
data?: T;
};
export type RegisterSchemaType = z.infer<typeof RegisterSchema>;
export type LoginSchemaType = z.infer<typeof LoginSchema>;
// User
export type User = Pick<DbUser, 'id' | 'nickname' | 'email' | 'image' | 'createdAt' | 'tags'>;
// ActivityRequest
export type RequestWithActivity = ActivityRequest & { activity: Activity };
export type RequestWithReqUserAndActivity = ActivityRequest & {
requestUser: User;
activity: Activity;
};
export type RequestWithReqUser = ActivityRequest & {
requestUser: User;
};
// Activity
export type ActivityWithFavoCount = Activity & { _count: { favorites: number } };
export type ActivityWithUserAndFavoCount = Activity & { user: User; _count: { favorites: number } };
export type ActivityWithUser = Activity & { user: User };
export type ActivityWithUserAndFavorite = ActivityWithFavoCount & {
isFavorite: boolean;
};
export type ActivityWithRequest = ActivityWithUserAndFavorite & {
activityRequests: ActivityRequest[];
};
export type ActivityWithUserAndRequest = ActivityWithUser & { activityRequests: ActivityRequest[] };
export type ActivityWithUserandReqUser = ActivityWithUser & {
activityRequests: RequestWithReqUser[];
};
export type ActivityWithFavoriteAndCount = Activity & {
isFavorite: boolean;
} & {
_count: { favorites: number };
};
// Answer
export type AnswerWithUser = Answer & { user: User };
// Favorite
export type FavoriteWithActivity = Favorite & { activity: Activity };
// Question
export type QuestionWithUserAndAnswers = Question & {
user: User;
answers: (Answer & { user: User })[];
_count: {
answers: number;
};
answerCursorId: string | null;
};
// Sort
export type Sort = 'recent' | 'mostFavorite' | 'mostViewed' | 'tag';
export type QuestionSort = 'recent' | 'answerLen';