Compare commits
100 Commits
develop/mo
...
9f7624fa56
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9f7624fa56 | ||
![]() |
346992d4ec | ||
![]() |
f23a6b7d9c | ||
![]() |
ebc8a81641 | ||
![]() |
f487427b2c | ||
![]() |
cc4d035f97 | ||
![]() |
84b223ff60 | ||
![]() |
fca048074e | ||
![]() |
bc35e25616 | ||
![]() |
15f8d2e6aa | ||
![]() |
592a099f7b | ||
![]() |
4c1b30e5c6 | ||
![]() |
c765bb49a4 | ||
![]() |
9aeb58379d | ||
![]() |
6419567005 | ||
![]() |
e2076fe67b | ||
![]() |
766720e075 | ||
![]() |
19af60c410 | ||
![]() |
ed95621b2f | ||
![]() |
2258fd8fb9 | ||
![]() |
0f674badd9 | ||
![]() |
bc731ea2b8 | ||
![]() |
c11dba6297 | ||
![]() |
b9fbe4e476 | ||
![]() |
0d844eed3f | ||
![]() |
2862cddb6b | ||
![]() |
55509b483c | ||
![]() |
3f2ac2a285 | ||
![]() |
1216de4ff9 | ||
![]() |
7966d8abf5 | ||
![]() |
e975aebfcd | ||
![]() |
7f6970b183 | ||
![]() |
e83854ed2a | ||
![]() |
6961f058df | ||
![]() |
b515337acc | ||
![]() |
c732d89c34 | ||
![]() |
2b71d06c8d | ||
![]() |
3ec9d87f8b | ||
![]() |
546fb72732 | ||
![]() |
4303704753 | ||
![]() |
4bb213ef0c | ||
![]() |
657c652657 | ||
![]() |
5be77aae23 | ||
![]() |
ffbe63e421 | ||
![]() |
ba1e718039 | ||
![]() |
8b32d153db | ||
![]() |
d3e554b218 | ||
![]() |
5b10977a64 | ||
![]() |
a40b0fa4b1 | ||
![]() |
a4692a7d1f | ||
![]() |
c3f680aa22 | ||
![]() |
5b680f2219 | ||
![]() |
d3d95469ea | ||
![]() |
04eaf91d60 | ||
![]() |
be571ba4db | ||
![]() |
a6d549b2e8 | ||
![]() |
beb1e0ae68 | ||
![]() |
b2adcff61b | ||
![]() |
8200e0d902 | ||
![]() |
731cb7500e | ||
![]() |
d6c87e33f0 | ||
![]() |
e4b6c5e92d | ||
![]() |
03782cde24 | ||
![]() |
7cc6d939f5 | ||
![]() |
3bcb40c5ef | ||
![]() |
43a285dd2c | ||
![]() |
09a8dc539e | ||
![]() |
8f75226763 | ||
![]() |
7cfbcc1573 | ||
![]() |
5234ac06cd | ||
![]() |
aec59fb328 | ||
![]() |
7f9b4c2224 | ||
![]() |
197b006df3 | ||
![]() |
3692b2204b | ||
![]() |
3217a8d594 | ||
![]() |
d453144500 | ||
![]() |
e8d12f34e8 | ||
![]() |
56d43062c9 | ||
![]() |
c2a02cff77 | ||
![]() |
d3ef280b20 | ||
![]() |
b2e9616178 | ||
![]() |
d909805283 | ||
![]() |
8c46a93e61 | ||
![]() |
82507b4b31 | ||
![]() |
85651ff204 | ||
![]() |
9caca30e1e | ||
![]() |
d76d43d17f | ||
![]() |
dff07ddcb0 | ||
![]() |
b78709db9b | ||
![]() |
df9992454b | ||
![]() |
22fb620eef | ||
![]() |
c0fad42f0a | ||
![]() |
c2c6181332 | ||
![]() |
99239c32a5 | ||
![]() |
ef0c0ab389 | ||
![]() |
7610d80005 | ||
![]() |
24920fb313 | ||
![]() |
a0a4ffcb4e | ||
![]() |
5480b62131 | ||
![]() |
fc6ed533e2 |
19
.gitconfig
Normal file
19
.gitconfig
Normal file
@@ -0,0 +1,19 @@
|
||||
[user]
|
||||
email = louiscklaw@users.noreply.github.com
|
||||
name = louiscklaw
|
||||
[http]
|
||||
version = HTTP/1.1
|
||||
postBuffer = 5368709120
|
||||
[init]
|
||||
defaultBranch = master
|
||||
[core]
|
||||
autocrlf = false
|
||||
[pull]
|
||||
ff = only
|
||||
rebase = true
|
||||
[lfs]
|
||||
allowincompletepush = true
|
||||
locksverify = true
|
||||
[credential]
|
||||
autoDetectTimeout = -1
|
||||
helper = cache --timeout=2592000
|
@@ -77,12 +77,12 @@ const Chat = () => {
|
||||
const [toastMessage, setToastMessage] = useState("");
|
||||
|
||||
// Refs
|
||||
const contentRef = useRef();
|
||||
const contentRef = useRef(null);
|
||||
const swiperRefs = useRef([]);
|
||||
const textareaRef = useRef();
|
||||
const sideRef = useRef();
|
||||
const sendRef = useRef();
|
||||
const replyToAnimationRef = useRef();
|
||||
const textareaRef = useRef(null);
|
||||
const sideRef = useRef(null);
|
||||
const sendRef = useRef(null);
|
||||
const replyToAnimationRef = useRef(null);
|
||||
|
||||
const actionSheetButtons = [
|
||||
{
|
||||
@@ -104,7 +104,7 @@ const Chat = () => {
|
||||
icon: alertOutline,
|
||||
handler: () =>
|
||||
toaster(
|
||||
"I haven't implemented unsend :) Simple store update though",
|
||||
"I haven't implemented unsend :) Simple store update though"
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -165,11 +165,11 @@ const Chat = () => {
|
||||
const chatMessageID = elementID.includes("chatText")
|
||||
? parseInt(elementID.replace("chatText_", ""))
|
||||
: elementID.includes("chatTime")
|
||||
? parseInt(elementID.replace("chatTime_", ""))
|
||||
: parseInt(elementID.replace("chatBubble_", ""));
|
||||
? parseInt(elementID.replace("chatTime_", ""))
|
||||
: parseInt(elementID.replace("chatBubble_", ""));
|
||||
|
||||
const chatMessage = chat.filter(
|
||||
(message) => parseInt(message.id) === parseInt(chatMessageID),
|
||||
(message) => parseInt(message.id) === parseInt(chatMessageID)
|
||||
)[0];
|
||||
|
||||
setActionMessage(chatMessage);
|
||||
@@ -278,7 +278,7 @@ const Chat = () => {
|
||||
replyToMessage,
|
||||
replyToMessage ? replyToMessage.id : false,
|
||||
image,
|
||||
imagePath,
|
||||
imagePath
|
||||
);
|
||||
setMessage("");
|
||||
|
||||
@@ -329,7 +329,7 @@ const Chat = () => {
|
||||
fill="clear"
|
||||
onClick={() =>
|
||||
toaster(
|
||||
"As this is a UI only, video calling wouldn't work here.",
|
||||
"As this is a UI only, video calling wouldn't work here."
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -352,7 +352,7 @@ const Chat = () => {
|
||||
{chat.map((message, index) => {
|
||||
const repliedMessage = chat.filter(
|
||||
(subMessage) =>
|
||||
parseInt(subMessage.id) === parseInt(message.replyID),
|
||||
parseInt(subMessage.id) === parseInt(message.replyID)
|
||||
)[0];
|
||||
|
||||
return (
|
||||
@@ -360,7 +360,9 @@ const Chat = () => {
|
||||
ref={(ref) => (swiperRefs.current[index] = ref)}
|
||||
id={`chatBubble_${message.id}`}
|
||||
key={index}
|
||||
className={`chat-bubble ${message.sent ? "bubble-sent" : "bubble-received"}`}
|
||||
className={`chat-bubble ${
|
||||
message.sent ? "bubble-sent" : "bubble-received"
|
||||
}`}
|
||||
{...longPressEvent}
|
||||
>
|
||||
<div id={`chatText_${message.id}`}>
|
||||
|
@@ -22,7 +22,7 @@ import { useRef } from "react";
|
||||
import ContactModal from "../components/ContactModal";
|
||||
|
||||
const Chats = () => {
|
||||
const pageRef = useRef();
|
||||
const pageRef = useRef(null);
|
||||
const contacts = ContactStore.useState(getContacts);
|
||||
const latestChats = ChatStore.useState(getChats);
|
||||
|
||||
@@ -43,7 +43,7 @@ const Chats = () => {
|
||||
contacts
|
||||
.filter((c) => c.id === chat.contact_id)[0]
|
||||
.name.toLowerCase()
|
||||
.includes(searchTermLower),
|
||||
.includes(searchTermLower)
|
||||
);
|
||||
setResults(newResults);
|
||||
} else {
|
||||
|
21
01_Requirements/REQ0119/index.md
Normal file
21
01_Requirements/REQ0119/index.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
tags: mobile
|
||||
---
|
||||
|
||||
# REQ0119-Demo2FaExample
|
||||
|
||||
## description
|
||||
|
||||
A demonstration of two-factor authentication implementation examples
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
// To be defined
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
-
|
21
01_Requirements/REQ0120/index.md
Normal file
21
01_Requirements/REQ0120/index.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
tags:
|
||||
---
|
||||
|
||||
# REQ0120-PlaceholderFeature
|
||||
|
||||
## description
|
||||
|
||||
T.B.A.
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
// To be defined
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
-
|
21
01_Requirements/REQ0121/index.md
Normal file
21
01_Requirements/REQ0121/index.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
tags:
|
||||
---
|
||||
|
||||
# REQ0121-UserProfileFeature
|
||||
|
||||
## description
|
||||
|
||||
T.B.A.
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
// To be defined
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
-
|
21
01_Requirements/REQ0122/index.md
Normal file
21
01_Requirements/REQ0122/index.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
tags:
|
||||
---
|
||||
|
||||
# REQ0122-NotificationSystem
|
||||
|
||||
## description
|
||||
|
||||
T.B.A.
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
// To be defined
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
-
|
21
01_Requirements/REQ0123/index.md
Normal file
21
01_Requirements/REQ0123/index.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
tags:
|
||||
---
|
||||
|
||||
# REQ0123-AnalyticsDashboard
|
||||
|
||||
## description
|
||||
|
||||
T.B.A.
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
// To be defined
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
-
|
22
01_Requirements/REQ0124/index.md
Normal file
22
01_Requirements/REQ0124/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0124-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0125/index.md
Normal file
22
01_Requirements/REQ0125/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0125-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0126/index.md
Normal file
22
01_Requirements/REQ0126/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0126-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0127/index.md
Normal file
22
01_Requirements/REQ0127/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0127-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0128/index.md
Normal file
22
01_Requirements/REQ0128/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0128-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0129/index.md
Normal file
22
01_Requirements/REQ0129/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0129-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0130/index.md
Normal file
22
01_Requirements/REQ0130/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: [placeholder-tag1, placeholder-tag2]
|
||||
---
|
||||
|
||||
# REQ0130-PlaceholderTitle
|
||||
|
||||
## description
|
||||
|
||||

|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
{
|
||||
placeholderField1: Type;
|
||||
placeholderField2: Type;
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQXXXX]]
|
22
01_Requirements/REQ0131/index.md
Normal file
22
01_Requirements/REQ0131/index.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0131-DemoInstagramClone
|
||||
|
||||
## description
|
||||
|
||||
<Party Page.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table users {
|
||||
id integer
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQ0110-PartyPage]]
|
23
01_Requirements/REQ0132/index.md
Normal file
23
01_Requirements/REQ0132/index.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0132-DemoKanbanBoard
|
||||
|
||||
## description
|
||||
|
||||
<Kanban Board.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table tasks {
|
||||
id integer
|
||||
status string
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQ0131-DemoInstagramClone]]
|
23
01_Requirements/REQ0133/index.md
Normal file
23
01_Requirements/REQ0133/index.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0133-DemoList
|
||||
|
||||
## description
|
||||
|
||||
<Demo List.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table lists {
|
||||
id integer
|
||||
name string
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQ0132-DemoKanbanBoard]]
|
23
01_Requirements/REQ0134/index.md
Normal file
23
01_Requirements/REQ0134/index.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0134-DemoOrderingApp
|
||||
|
||||
## description
|
||||
|
||||
<Ordering App.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table orders {
|
||||
id integer
|
||||
item string
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[]
|
24
01_Requirements/REQ0135/index.md
Normal file
24
01_Requirements/REQ0135/index.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0135-DemoPinterestFloatingTabBar
|
||||
|
||||
## description
|
||||
|
||||
<Pinterest Floating Tab Bar.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table floating_tab_bars {
|
||||
id integer
|
||||
position string
|
||||
items json
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQ0134-DemoList]]
|
24
01_Requirements/REQ0136/index.md
Normal file
24
01_Requirements/REQ0136/index.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
tags: requirements
|
||||
---
|
||||
|
||||
# REQ0136-DemoProfileExample
|
||||
|
||||
## description
|
||||
|
||||
<Profile Example.png>
|
||||
|
||||
## schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table profiles {
|
||||
id integer
|
||||
name string
|
||||
avatar_url string
|
||||
}
|
||||
```
|
||||
|
||||
## related
|
||||
|
||||
[[REQ0135-DemoPinterestFloatingTabBar]]
|
24
01_Requirements/REQ0137/index.md
Normal file
24
01_Requirements/REQ0137/index.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0137-DemoPullstateTutorial
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table pullstates {
|
||||
id integer
|
||||
state json
|
||||
timestamp datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0136-DemoProfileExample](#)
|
24
01_Requirements/REQ0138/index.md
Normal file
24
01_Requirements/REQ0138/index.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0138-DemoQrScanner
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table qr_scanners {
|
||||
id integer
|
||||
scan_data string
|
||||
scan_time datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0137-DemoPullstateTutorial](#)
|
24
01_Requirements/REQ0139/index.md
Normal file
24
01_Requirements/REQ0139/index.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0139-DemoQuizApp
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table quizzes {
|
||||
id integer
|
||||
questions json
|
||||
results json
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0138-DemoQrScanner](#)
|
25
01_Requirements/REQ0140/index.md
Normal file
25
01_Requirements/REQ0140/index.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0140-DemoQuoteApp
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table quotes {
|
||||
id integer
|
||||
content string
|
||||
author string
|
||||
category string
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0139-DemoQuizApp](#)
|
25
01_Requirements/REQ0141/index.md
Normal file
25
01_Requirements/REQ0141/index.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0141-DemoReactAddToCart
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table cart_items {
|
||||
id integer
|
||||
product_id integer
|
||||
quantity integer
|
||||
user_id integer
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0140-DemoQuoteApp](#)
|
25
01_Requirements/REQ0142/index.md
Normal file
25
01_Requirements/REQ0142/index.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0142-DemoReactCalculator
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table calculations {
|
||||
id integer
|
||||
expression string
|
||||
result float
|
||||
timestamp datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0141-DemoReactAddToCart](#)
|
25
01_Requirements/REQ0143/index.md
Normal file
25
01_Requirements/REQ0143/index.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0143-DemoReactDrawingCanvas
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table drawings {
|
||||
id integer
|
||||
canvas_data json
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0142-DemoReactCalculator](#)
|
25
01_Requirements/REQ0144/index.md
Normal file
25
01_Requirements/REQ0144/index.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0144-DemoReactHookFormExample
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table forms {
|
||||
id integer
|
||||
form_data json
|
||||
submitted_at datetime
|
||||
user_id integer
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0143-DemoReactDrawingCanvas](#)
|
26
01_Requirements/REQ0145/index.md
Normal file
26
01_Requirements/REQ0145/index.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0145-DemoReactItemList
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table items {
|
||||
id integer
|
||||
name string
|
||||
description text
|
||||
price decimal
|
||||
created_at datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0144-DemoReactHookFormExample](#)
|
26
01_Requirements/REQ0146/index.md
Normal file
26
01_Requirements/REQ0146/index.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0146-DemoReactLifecycles
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table components {
|
||||
id integer
|
||||
name string
|
||||
lifecycle_stage string
|
||||
mounted_at datetime
|
||||
updated_at datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0145-DemoReactItemList](#)
|
26
01_Requirements/REQ0147/index.md
Normal file
26
01_Requirements/REQ0147/index.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0147-DemoReactLogin
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table users {
|
||||
id integer
|
||||
username string
|
||||
password_hash string
|
||||
last_login_at datetime
|
||||
login_count integer
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0146-DemoReactLifecycles](#)
|
26
01_Requirements/REQ0148/index.md
Normal file
26
01_Requirements/REQ0148/index.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0148-DemoReactMarvelApp
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table characters {
|
||||
id integer
|
||||
name string
|
||||
description text
|
||||
thumbnail_url string
|
||||
comics_available integer
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0147-DemoReactLogin](#)
|
27
01_Requirements/REQ0149/index.md
Normal file
27
01_Requirements/REQ0149/index.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0149-DemoReactMovieAppWithAlgolia
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table movies {
|
||||
id integer
|
||||
title string
|
||||
year integer
|
||||
rating decimal
|
||||
search_index string
|
||||
last_updated datetime
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0148-DemoReactMarvelApp](#)
|
27
01_Requirements/REQ0150/index.md
Normal file
27
01_Requirements/REQ0150/index.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0150-DemoReactNotes
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table notes {
|
||||
id integer
|
||||
title string
|
||||
content text
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_pinned boolean
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0149-DemoReactMovieAppWithAlgolia](#)
|
27
01_Requirements/REQ0151/index.md
Normal file
27
01_Requirements/REQ0151/index.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0151-DemoReactOnboardingUi
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table onboarding_steps {
|
||||
id integer
|
||||
title string
|
||||
description text
|
||||
is_completed boolean
|
||||
order_number integer
|
||||
component_name string
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0150-DemoReactNotes](#)
|
26
01_Requirements/REQ0152/index.md
Normal file
26
01_Requirements/REQ0152/index.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0152-DemoReactOverlayHooks
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
|
||||
## Schema
|
||||
|
||||
```dbml
|
||||
// Add your DBML here
|
||||
Table overlays {
|
||||
id integer
|
||||
component_name string
|
||||
is_visible boolean
|
||||
z_index integer
|
||||
animation_type string
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [REQ0151-DemoReactOnboardingUi](#)
|
10
01_Requirements/REQ0153/index.md
Normal file
10
01_Requirements/REQ0153/index.md
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
tags: [requirements]
|
||||
---
|
||||
|
||||
# REQ0153-DemoReactPollApp
|
||||
|
||||
## Description
|
||||

|
||||
|
||||
## Schema
|
1
01_Requirements/REQ0154/index.md
Normal file
1
01_Requirements/REQ0154/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactProfileDashboardUi
|
1
01_Requirements/REQ0155/index.md
Normal file
1
01_Requirements/REQ0155/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactQuotes
|
1
01_Requirements/REQ0156/index.md
Normal file
1
01_Requirements/REQ0156/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactShop
|
1
01_Requirements/REQ0157/index.md
Normal file
1
01_Requirements/REQ0157/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactShopUi
|
1
01_Requirements/REQ0158/index.md
Normal file
1
01_Requirements/REQ0158/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactSwitchTabs
|
1
01_Requirements/REQ0159/index.md
Normal file
1
01_Requirements/REQ0159/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactTabsMenusCustom
|
1
01_Requirements/REQ0160/index.md
Normal file
1
01_Requirements/REQ0160/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactThemeSwitcher
|
1
01_Requirements/REQ0161/index.md
Normal file
1
01_Requirements/REQ0161/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoReactTravelApp
|
1
01_Requirements/REQ0162/index.md
Normal file
1
01_Requirements/REQ0162/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoRecipeApp
|
1
01_Requirements/REQ0163/index.md
Normal file
1
01_Requirements/REQ0163/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoRestaurantFinder
|
1
01_Requirements/REQ0164/index.md
Normal file
1
01_Requirements/REQ0164/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoScoreBoard
|
1
01_Requirements/REQ0165/index.md
Normal file
1
01_Requirements/REQ0165/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoShopAppUi
|
1
01_Requirements/REQ0166/index.md
Normal file
1
01_Requirements/REQ0166/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoSkeletonText
|
1
01_Requirements/REQ0167/index.md
Normal file
1
01_Requirements/REQ0167/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoSlidingProfile
|
1
01_Requirements/REQ0168/index.md
Normal file
1
01_Requirements/REQ0168/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoStickyBottomSheetExample
|
1
01_Requirements/REQ0169/index.md
Normal file
1
01_Requirements/REQ0169/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoStorageExample
|
1
01_Requirements/REQ0170/index.md
Normal file
1
01_Requirements/REQ0170/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# DemoWeatherAppUi
|
16
01_Requirements/REQ0180/index.md
Normal file
16
01_Requirements/REQ0180/index.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
tags: docker, ports
|
||||
---
|
||||
|
||||
# REQ0180 service port schedule
|
||||
|
||||
## Port Usage
|
||||
|
||||
| Service | Host **Port** | Container Port | Environment | Purpose | subdomain |
|
||||
| ----------- | ------------- | -------------- | ----------- | -------------------------------- | ------------------------ |
|
||||
| Frontend | 10001 | 8080 | All | Web application access | pa_admin.louislabs.com |
|
||||
| Mobile | 10004 | 3000 | All | Mobile application access | pa_mobile.louislabs.com |
|
||||
| CMS Backend | 10002 | 7272 | All | Main API access | pa_backend.louislabs.com |
|
||||
| CMS Backend | 10003 | 5555 | All | Additional service access | --- |
|
||||
| Postgres | - | 5432 | Production | Database access (container only) | --- |
|
||||
| Postgres | 5432 | 5432 | Development | Database access | --- |
|
@@ -105,3 +105,56 @@
|
||||
- [REQ0116: REQ0116/main-tab](./REQ0116/index.md)
|
||||
- [REQ0117: REQ0117/default-route](./REQ0117/index.md)
|
||||
- [REQ0118: REQ0118/Not-Implemented-page](./REQ0118/index.md)
|
||||
- [REQ0119: REQ0119-Demo2FaExample](./REQ0119/index.md)
|
||||
- [REQ0120: REQ0120-PlaceholderFeature](./REQ0120/index.md)
|
||||
- [REQ0121: REQ0121-UserProfileFeature](./REQ0121/index.md)
|
||||
- [REQ0122: REQ0122-NotificationSystem](./REQ0122/index.md)
|
||||
- [REQ0123: REQ0123-AnalyticsDashboard](./REQ0123/index.md)
|
||||
- [REQ0124: REQ0124-PlaceholderTitle](./REQ0124/index.md)
|
||||
- [REQ0125: REQ0125-PlaceholderTitle](./REQ0125/index.md)
|
||||
- [REQ0126: REQ0126-PlaceholderTitle](./REQ0126/index.md)
|
||||
- [REQ0127: REQ0127-PlaceholderTitle](./REQ0127/index.md)
|
||||
- [REQ0128: REQ0128-PlaceholderTitle](./REQ0128/index.md)
|
||||
- [REQ0129: REQ0129-PlaceholderTitle](./REQ0129/index.md)
|
||||
- [REQ0130: REQ0130-PlaceholderTitle](./REQ0130/index.md)
|
||||
- [REQ0131: REQ0131-DemoInstagramClone](./REQ0131/index.md)
|
||||
- [REQ0132: REQ0132-DemoKanbanBoard](./REQ0132/index.md)
|
||||
- [REQ0133: REQ0133-DemoList](./REQ0133/index.md)
|
||||
- [REQ0134: REQ0134-DemoOrderingApp](./REQ0134/index.md)
|
||||
- [REQ0135: REQ0135-DemoPinterestFloatingTabBar](./REQ0135/index.md)
|
||||
- [REQ0136: REQ0136-DemoProfileExample](./REQ0136/index.md)
|
||||
- [REQ0137: REQ0137-DemoPullstateTutorial](./REQ0137/index.md)
|
||||
- [REQ0138: REQ0138-DemoQrScanner](./REQ0138/index.md)
|
||||
- [REQ0139: REQ0139-DemoQuizApp](./REQ0139/index.md)
|
||||
- [REQ0140: REQ0140-DemoQuoteApp](./REQ0140/index.md)
|
||||
- [REQ0141: REQ0141-DemoReactAddToCart](./REQ0141/index.md)
|
||||
- [REQ0142: REQ0142-DemoReactCalculator](./REQ0142/index.md)
|
||||
- [REQ0143: REQ0143-DemoReactDrawingCanvas](./REQ0143/index.md)
|
||||
- [REQ0144: REQ0144-DemoReactHookFormExample](./REQ0144/index.md)
|
||||
- [REQ0145: REQ0145-DemoReactItemList](./REQ0145/index.md)
|
||||
- [REQ0146: REQ0146-DemoReactLifecycles](./REQ0146/index.md)
|
||||
- [REQ0147: REQ0147-DemoReactLogin](./REQ0147/index.md)
|
||||
- [REQ0148: REQ0148-DemoReactMarvelApp](./REQ0148/index.md)
|
||||
- [REQ0149: REQ0149-DemoReactMovieAppWithAlgolia](./REQ0149/index.md)
|
||||
- [REQ0150: REQ0150-DemoReactNotes](./REQ0150/index.md)
|
||||
- [REQ0151: REQ0151-DemoReactOnboardingUi](./REQ0151/index.md)
|
||||
- [REQ0152: REQ0152-DemoReactOverlayHooks](./REQ0152/index.md)
|
||||
- [REQ0153: REQ0153-DemoReactPollApp](./REQ0153/index.md)
|
||||
- [REQ0154: DemoReactProfileDashboardUi](./REQ0154/index.md)
|
||||
- [REQ0155: DemoReactQuotes](./REQ0155/index.md)
|
||||
- [REQ0156: DemoReactShop](./REQ0156/index.md)
|
||||
- [REQ0157: DemoReactShopUi](./REQ0157/index.md)
|
||||
- [REQ0158: DemoReactSwitchTabs](./REQ0158/index.md)
|
||||
- [REQ0159: DemoReactTabsMenusCustom](./REQ0159/index.md)
|
||||
- [REQ0160: DemoReactThemeSwitcher](./REQ0160/index.md)
|
||||
- [REQ0161: DemoReactTravelApp](./REQ0161/index.md)
|
||||
- [REQ0162: DemoRecipeApp](./REQ0162/index.md)
|
||||
- [REQ0163: DemoRestaurantFinder](./REQ0163/index.md)
|
||||
- [REQ0164: DemoScoreBoard](./REQ0164/index.md)
|
||||
- [REQ0165: DemoShopAppUi](./REQ0165/index.md)
|
||||
- [REQ0166: DemoSkeletonText](./REQ0166/index.md)
|
||||
- [REQ0167: DemoSlidingProfile](./REQ0167/index.md)
|
||||
- [REQ0168: DemoStickyBottomSheetExample](./REQ0168/index.md)
|
||||
- [REQ0169: DemoStorageExample](./REQ0169/index.md)
|
||||
- [REQ0170: DemoWeatherAppUi](./REQ0170/index.md)
|
||||
- [REQ0180: REQ0180 service port schedule](./REQ0180/index.md)
|
||||
|
@@ -28,7 +28,8 @@
|
||||
"db:generate": "prisma generate",
|
||||
"db:push": "prisma db push --force-reset",
|
||||
"db:push:w": "npx nodemon --delay 1 --watch prisma --ext \"ts,tsx,prisma\" --exec \"yarn db:push && yarn seed\"",
|
||||
"db:studio": "prisma studio"
|
||||
"db:studio": "prisma studio",
|
||||
"db:studio:w": "npx nodemon --delay 1 --watch prisma --ext \"prisma\" --exec \"yarn db:studio\""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
|
@@ -46,6 +46,9 @@ model Session {
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
name String?
|
||||
username String? @unique
|
||||
email String @unique
|
||||
@@ -54,8 +57,6 @@ model User {
|
||||
image String?
|
||||
bucketImage String?
|
||||
admin Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
info Json?
|
||||
@@ -70,6 +71,18 @@ model VerificationToken {
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
||||
model Student {
|
||||
id Int @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
email String @unique
|
||||
metadata Json @default("{}")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// frontend/src/_mock/_user.ts
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
// REQ0044/near_by_page
|
||||
@@ -99,6 +112,9 @@ model Member {
|
||||
music String[] @default([])
|
||||
pets String[] @default([])
|
||||
character String[] @default([])
|
||||
//
|
||||
avatar String @default("")
|
||||
sex String @default("")
|
||||
}
|
||||
|
||||
model Order {
|
||||
@@ -118,7 +134,7 @@ model Event {
|
||||
id Int @id @default(autoincrement())
|
||||
eventDate DateTime
|
||||
title String
|
||||
joinMembers Member[] // Assuming Member model exists
|
||||
joinMembers Json[] // Assuming Member model exists
|
||||
price Float
|
||||
currency String
|
||||
duration_m Int
|
||||
@@ -127,6 +143,8 @@ model Event {
|
||||
location String
|
||||
avatar String // Assuming avatar is stored as a file path or URL
|
||||
Order Order[]
|
||||
Member Member? @relation(fields: [memberId], references: [id])
|
||||
memberId Int?
|
||||
}
|
||||
|
||||
// cms_backend
|
||||
@@ -516,6 +534,7 @@ model UserCard {
|
||||
totalFollowing Float
|
||||
}
|
||||
|
||||
// `UserItem` obsoleted, use `UserMeta` instead
|
||||
model UserItem {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
@@ -537,6 +556,33 @@ model UserItem {
|
||||
//
|
||||
username String
|
||||
password String
|
||||
//
|
||||
isAdmin Boolean @default(false)
|
||||
}
|
||||
|
||||
model UserMeta {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
name String
|
||||
city String
|
||||
role String
|
||||
email String
|
||||
state String
|
||||
status String
|
||||
address String
|
||||
country String
|
||||
zipCode String
|
||||
company String
|
||||
avatarUrl String
|
||||
phoneNumber String
|
||||
isVerified Boolean
|
||||
//
|
||||
username String
|
||||
password String
|
||||
//
|
||||
isAdmin Boolean @default(false)
|
||||
}
|
||||
|
||||
model UserAccountBillingHistory {
|
||||
@@ -1078,3 +1124,96 @@ model Kanban {
|
||||
columns KanbanColumn[]
|
||||
tasks KanbanTask[]
|
||||
}
|
||||
|
||||
// mapped to IEventReview
|
||||
model EventReview {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
name String
|
||||
rating Float
|
||||
comment String
|
||||
helpful Float
|
||||
avatarUrl String
|
||||
postedAt DateTime @default(now()) // Assuming IDateValue maps to DateTime
|
||||
isPurchased Boolean
|
||||
attachments String[]
|
||||
//
|
||||
EventItem EventItem? @relation(fields: [eventItemId], references: [id])
|
||||
eventItemId String?
|
||||
}
|
||||
|
||||
// mapped to IEventItem
|
||||
model EventItem {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
//
|
||||
sku String
|
||||
name String
|
||||
code String
|
||||
price Float
|
||||
taxes Float
|
||||
tags String[]
|
||||
sizes String[]
|
||||
publish String
|
||||
gender String[]
|
||||
coverUrl String
|
||||
images String[]
|
||||
colors String[]
|
||||
quantity Int
|
||||
category String
|
||||
available Int
|
||||
totalSold Int
|
||||
description String
|
||||
totalRatings Float
|
||||
totalReviews Int
|
||||
inventoryType String
|
||||
subDescription String
|
||||
priceSale Float?
|
||||
newLabel Json
|
||||
saleLabel Json
|
||||
ratings Json[]
|
||||
//
|
||||
eventDate DateTime @default(now())
|
||||
joinMembers Json[]
|
||||
title String
|
||||
currency String
|
||||
duration_m Float
|
||||
ageBottom Float
|
||||
ageTop Float
|
||||
location String
|
||||
avatar String[]
|
||||
//
|
||||
reviews EventReview[]
|
||||
}
|
||||
|
||||
model AppLog {
|
||||
id String @id @default(uuid())
|
||||
timestamp DateTime @default(now())
|
||||
//
|
||||
level Int? @default(1)
|
||||
message String? @default("")
|
||||
//
|
||||
module String?
|
||||
userId String?
|
||||
metadata Json?
|
||||
|
||||
@@index([timestamp])
|
||||
@@index([level])
|
||||
@@index([module])
|
||||
}
|
||||
|
||||
model AccessLog {
|
||||
id String @id @default(uuid())
|
||||
timestamp DateTime @default(now())
|
||||
//
|
||||
userId String? @default("")
|
||||
message String? @default("")
|
||||
//
|
||||
metadata Json?
|
||||
|
||||
@@index([timestamp])
|
||||
@@index([userId])
|
||||
}
|
||||
|
@@ -25,6 +25,12 @@ import { FileStore } from './seeds/fileStore';
|
||||
import { userItemSeed } from './seeds/userItem';
|
||||
import { orderItemSeed } from './seeds/orderItem';
|
||||
import { invoiceItemSeed } from './seeds/invoiceItem';
|
||||
//
|
||||
import { EventItemSeed } from './seeds/eventItem';
|
||||
import { EventReviewSeed } from './seeds/eventReview';
|
||||
import { appLogSeed } from './seeds/AppLog';
|
||||
import { accessLogSeed } from './seeds/AccessLog';
|
||||
import { userMetaSeed } from './seeds/userMeta';
|
||||
|
||||
//
|
||||
// import { Blog } from './seeds/blog';
|
||||
@@ -41,11 +47,22 @@ import { invoiceItemSeed } from './seeds/invoiceItem';
|
||||
await ProductReview;
|
||||
await FileStore;
|
||||
await ProductItem;
|
||||
|
||||
await userItemSeed;
|
||||
await userMetaSeed;
|
||||
|
||||
await orderItemSeed;
|
||||
await invoiceItemSeed;
|
||||
//
|
||||
await EventReviewSeed;
|
||||
await EventItemSeed;
|
||||
//
|
||||
await appLogSeed;
|
||||
await accessLogSeed;
|
||||
|
||||
// await Blog;
|
||||
// await Mail;
|
||||
// await File;
|
||||
// await Chat;
|
||||
console.log('seed done');
|
||||
})();
|
||||
|
36
03_source/cms_backend/prisma/seeds/AccessLog.ts
Normal file
36
03_source/cms_backend/prisma/seeds/AccessLog.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { format, parseISO } from 'date-fns';
|
||||
|
||||
const L_ERROR = 0;
|
||||
const L_WARN = 1;
|
||||
const L_INFO = 2;
|
||||
const L_DEBUG = 3;
|
||||
const L_TRACE = 4;
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function accessLog() {
|
||||
await prisma.accessLog.upsert({
|
||||
where: { id: '0' },
|
||||
update: {},
|
||||
create: {
|
||||
userId: '0',
|
||||
message: 'helloworld',
|
||||
metadata: { hello: 'world' },
|
||||
},
|
||||
});
|
||||
|
||||
console.log('seed AccessLog done');
|
||||
}
|
||||
|
||||
const accessLogSeed = accessLog()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { accessLogSeed };
|
71
03_source/cms_backend/prisma/seeds/AppLog.ts
Normal file
71
03_source/cms_backend/prisma/seeds/AppLog.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { format, parseISO } from 'date-fns';
|
||||
|
||||
const L_ERROR = 0;
|
||||
const L_WARN = 1;
|
||||
const L_INFO = 2;
|
||||
const L_DEBUG = 3;
|
||||
const L_TRACE = 4;
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function appLog() {
|
||||
await prisma.appLog.upsert({
|
||||
where: { id: '0' },
|
||||
update: {},
|
||||
create: {
|
||||
message: 'helloworld',
|
||||
level: L_ERROR,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.appLog.upsert({
|
||||
where: { id: '1' },
|
||||
update: {},
|
||||
create: {
|
||||
message: 'warning message',
|
||||
level: L_WARN,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.appLog.upsert({
|
||||
where: { id: '2' },
|
||||
update: {},
|
||||
create: {
|
||||
message: 'info message',
|
||||
level: L_INFO,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.appLog.upsert({
|
||||
where: { id: '3' },
|
||||
update: {},
|
||||
create: {
|
||||
message: 'debug message',
|
||||
level: L_DEBUG,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.appLog.upsert({
|
||||
where: { id: '4' },
|
||||
update: {},
|
||||
create: {
|
||||
message: 'trace message',
|
||||
level: L_TRACE,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('seed AppLog done');
|
||||
}
|
||||
|
||||
const appLogSeed = appLog()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { appLogSeed };
|
@@ -2,12 +2,43 @@ import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function member() {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
[
|
||||
{
|
||||
email: 'tom@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1671656349322-41de944d259b`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'may@exampl.com',
|
||||
avatar: `https://images.unsplash.com/photo-1522075469751-3a6694fb2f61`,
|
||||
sex: 'F',
|
||||
},
|
||||
{
|
||||
email: 'june@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1723867331866-e112500178a4`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'april@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1682089894837-e01e5cb8e471`,
|
||||
sex: 'F',
|
||||
},
|
||||
{
|
||||
email: 'susan@exampl.com',
|
||||
avatar: `https://images.unsplash.com/photo-1485893086445-ed75865251e0`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'peter@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1722945763962-305a5a769cc8`,
|
||||
sex: 'F',
|
||||
},
|
||||
].forEach(async (m, i) => {
|
||||
const john = await prisma.member.upsert({
|
||||
where: { email: `member${i}@example.com` },
|
||||
where: { email: m.email },
|
||||
update: {},
|
||||
create: {
|
||||
email: `member${i}@example.com`,
|
||||
email: m.email,
|
||||
name: `member_${i}`,
|
||||
age: 20 + i,
|
||||
rank: i % 2 ? 'VIP' : 'NON_VIP',
|
||||
@@ -25,11 +56,42 @@ async function member() {
|
||||
self_introduction: 'Get me know me before you love me. Get me know me before you love me.',
|
||||
music: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
pets: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
character: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic']
|
||||
}
|
||||
character: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
avatar: m.avatar,
|
||||
sex: m.sex,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const john = await prisma.member.upsert({
|
||||
where: { email: `member${i}@example.com` },
|
||||
update: {},
|
||||
create: {
|
||||
email: `member${i}@example.com`,
|
||||
name: `member_${i}`,
|
||||
age: 20 + i,
|
||||
rank: i % 2 ? 'VIP' : 'NON_VIP',
|
||||
verified: i % 3 ? 'NOT_VERIFIED' : 'VERIFIED',
|
||||
hobbies: ['fishing', 'basketball', 'piano'],
|
||||
distance: `${40 + Math.random() * 40}km`,
|
||||
location_area: 'Sai Kung',
|
||||
greetings: 'Hi, I am ',
|
||||
gender: 'man',
|
||||
tall_cm: 172 + Math.random() * 10,
|
||||
weight_kg: 60 + Math.random() * 50,
|
||||
occupation: 'doctor',
|
||||
language: ['English', 'French', 'Chinese'],
|
||||
education: ['Degree of Computer'],
|
||||
self_introduction: 'Get me know me before you love me. Get me know me before you love me.',
|
||||
music: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
pets: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
character: ['Classic', 'Classic', 'Classic', 'Classic', 'Classic', 'Classic'],
|
||||
avatar: '',
|
||||
sex: i % 2 ? 'M' : 'F',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('seed member done');
|
||||
}
|
||||
|
||||
|
@@ -78,11 +78,12 @@ export const _mock = {
|
||||
avatar: (index: number) => `${CONFIG.basePath}/assets/images/avatar/avatar-${index + 1}.webp`,
|
||||
travel: (index: number) => `${CONFIG.basePath}/assets/images/travel/travel-${index + 1}.webp`,
|
||||
course: (index: number) => `${CONFIG.basePath}/assets/images/course/course-${index + 1}.webp`,
|
||||
company: (index: number) =>
|
||||
`${CONFIG.basePath}/assets/images/company/company-${index + 1}.webp`,
|
||||
product: (index: number) =>
|
||||
`${CONFIG.basePath}/assets/images/m-product/product-${index + 1}.webp`,
|
||||
portrait: (index: number) =>
|
||||
`${CONFIG.basePath}/assets/images/portrait/portrait-${index + 1}.webp`,
|
||||
company: (index: number) => `${CONFIG.basePath}/assets/images/company/company-${index + 1}.webp`,
|
||||
product: (index: number) => `${CONFIG.basePath}/assets/images/m-product/product-${index + 1}.webp`,
|
||||
portrait: (index: number) => `${CONFIG.basePath}/assets/images/portrait/portrait-${index + 1}.webp`,
|
||||
//
|
||||
event: (index: number) => `${CONFIG.basePath}/assets/images/m-product/product-${index + 1}.webp`,
|
||||
},
|
||||
//
|
||||
eventName: (index: number) => _eventNames[index],
|
||||
};
|
||||
|
277
03_source/cms_backend/prisma/seeds/eventItem.ts
Normal file
277
03_source/cms_backend/prisma/seeds/eventItem.ts
Normal file
@@ -0,0 +1,277 @@
|
||||
import { _mock } from './_mock';
|
||||
import { _tags } from './assets';
|
||||
|
||||
import { PrismaClient, EventReview } from '@prisma/client';
|
||||
import { _eventsReview } from './eventReview';
|
||||
import { CONFIG } from './global-config';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const COLORS = ['#FF4842', '#1890FF', '#FFC0CB', '#00AB55', '#FFC107', '#7F00FF', '#000000', '#FFFFFF'];
|
||||
|
||||
const DESCRIPTION = `
|
||||
<h6>Specifications</h6>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Category</td>
|
||||
<td>Mobile</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Manufacturer</td>
|
||||
<td>Apple</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Warranty</td>
|
||||
<td>12 Months</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Serial number</td>
|
||||
<td>358607726380311</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ships from</td>
|
||||
<td>United States</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h6>Event details</h6>
|
||||
<ul>
|
||||
<li>
|
||||
<p>The foam sockliner feels soft and comfortable</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Pull tab</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Not intended for use as Personal Protective Equipment</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Colour Shown: White/Black/Oxygen Purple/Action Grape</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Style: 921826-109</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Country/Region of Origin: China</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h6>Benefits</h6>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Mesh and synthetic materials on the upper keep the fluid look of the OG while adding comfort</p>
|
||||
and durability.
|
||||
</li>
|
||||
<li>
|
||||
<p>Originally designed for performance running, the full-length Max Air unit adds soft, comfortable cushio</p>
|
||||
ning underfoot.
|
||||
</li>
|
||||
<li>
|
||||
<p>The foam midsole feels springy and soft.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The rubber outsole adds traction and durability.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h6>Delivery and returns</h6>
|
||||
<p>Your order of $200 or more gets free standard delivery.</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Standard delivered 4-5 Business Days</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Express delivered 2-4 Business Days</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Orders are processed and delivered Monday-Friday (excluding public holidays)</p>
|
||||
|
||||
`;
|
||||
|
||||
const getColorSliceForIndex = (index: number) => {
|
||||
if (index === 0) return COLORS.slice(0, 2);
|
||||
if (index === 1) return COLORS.slice(1, 3);
|
||||
if (index === 2) return COLORS.slice(2, 4);
|
||||
if (index === 3) return COLORS.slice(3, 6);
|
||||
if (index === 4 || index === 16 || index === 19) return COLORS.slice(4, 6);
|
||||
if (index === 5 || index === 17) return COLORS.slice(5, 6);
|
||||
if (index === 6 || index === 18) return COLORS.slice(0, 2);
|
||||
if (index === 7) return COLORS.slice(4, 6);
|
||||
if (index === 8) return COLORS.slice(2, 4);
|
||||
if (index === 9 || index === 11) return COLORS.slice(2, 6);
|
||||
if (index === 10) return COLORS.slice(3, 6);
|
||||
if (index === 12) return COLORS.slice(2, 7);
|
||||
if (index === 13) return COLORS.slice(4, 7);
|
||||
if (index === 14) return COLORS.slice(0, 2);
|
||||
if (index === 15) return COLORS.slice(5, 8);
|
||||
return COLORS.slice(2, 6); // Default case
|
||||
};
|
||||
|
||||
const generateAttachments = () => Array.from({ length: 20 }, (_, index) => _mock.image.event(index));
|
||||
|
||||
const generateReviews = () => {
|
||||
const attachments = generateAttachments();
|
||||
};
|
||||
|
||||
const generateRatings = () =>
|
||||
Array.from({ length: 5 }, (_, index) => ({
|
||||
name: `${index + 1} Star`,
|
||||
starCount: _mock.number.nativeL(index),
|
||||
reviewCount: _mock.number.nativeL(index + 1),
|
||||
}));
|
||||
|
||||
const generateImages = () => Array.from({ length: 8 }, (_, index) => _mock.image.event(index));
|
||||
|
||||
const _events = () =>
|
||||
Array.from({ length: 2 }, (_, index) => {
|
||||
const reviews = generateReviews();
|
||||
const images = generateImages();
|
||||
const ratings = generateRatings();
|
||||
//
|
||||
const publish = index % 3 ? 'published' : 'draft';
|
||||
|
||||
const category = (index % 2 && 'Shose') || (index % 3 && 'Apparel') || 'Accessories';
|
||||
|
||||
const gender = (index % 2 && ['Men']) || (index % 3 && ['Women', 'Kids']) || ['Kids'];
|
||||
|
||||
const available = (index % 2 && 72) || (index % 3 && 10) || 0;
|
||||
|
||||
const inventoryType = (index % 2 && 'in stock') || (index % 3 && 'low stock') || 'out of stock';
|
||||
|
||||
const priceSale = index % 3 ? undefined : _mock.number.price(index);
|
||||
|
||||
return {
|
||||
id: _mock.id(index).toString(),
|
||||
sku: `WW75K521${index}YW/SV`,
|
||||
name: _mock.eventName(index),
|
||||
gender,
|
||||
images,
|
||||
reviews,
|
||||
publish,
|
||||
ratings,
|
||||
category,
|
||||
available,
|
||||
priceSale,
|
||||
taxes: 10,
|
||||
quantity: 80,
|
||||
inventoryType,
|
||||
tags: _tags.slice(0, 5),
|
||||
code: `38BEE27${index}`,
|
||||
description: DESCRIPTION,
|
||||
createdAt: _mock.time(index),
|
||||
price: _mock.number.price(index),
|
||||
coverUrl: _mock.image.event(index),
|
||||
colors: getColorSliceForIndex(index),
|
||||
totalRatings: _mock.number.rating(index),
|
||||
totalSold: _mock.number.nativeM(index + 1),
|
||||
totalReviews: _mock.number.nativeL(index + 1),
|
||||
newLabel: { enabled: [1, 2, 3].includes(index), content: 'NEW' },
|
||||
saleLabel: { enabled: [4, 5].includes(index), content: 'SALE' },
|
||||
sizes: ['6', '7', '8', '8.5', '9', '9.5', '10', '10.5', '11', '11.5', '12', '13'],
|
||||
subDescription: 'Featuring the original ripple design inspired by Japanese bullet trains, the Nike Air Max 97 lets you push your style full-speed ahead.',
|
||||
};
|
||||
});
|
||||
|
||||
const memberList = (num_of_member: number) =>
|
||||
_.shuffle([
|
||||
{
|
||||
email: 'tom@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1671656349322-41de944d259b`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'may@exampl.com',
|
||||
avatar: `https://images.unsplash.com/photo-1522075469751-3a6694fb2f61`,
|
||||
sex: 'F',
|
||||
},
|
||||
{
|
||||
email: 'june@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1723867331866-e112500178a4`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'april@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1682089894837-e01e5cb8e471`,
|
||||
sex: 'F',
|
||||
},
|
||||
{
|
||||
email: 'susan@exampl.com',
|
||||
avatar: `https://images.unsplash.com/photo-1485893086445-ed75865251e0`,
|
||||
sex: 'M',
|
||||
},
|
||||
{
|
||||
email: 'peter@exampl.com',
|
||||
avatar: `https://plus.unsplash.com/premium_photo-1722945763962-305a5a769cc8`,
|
||||
sex: 'F',
|
||||
},
|
||||
]).slice(0, num_of_member);
|
||||
|
||||
async function eventItem() {
|
||||
const temp_events = _events();
|
||||
|
||||
for (let i = 0; i < temp_events.length; i++) {
|
||||
const temp_pr = _eventsReview();
|
||||
|
||||
const temp = await prisma.eventItem.upsert({
|
||||
where: { id: temp_events[i].id.toString() },
|
||||
update: {},
|
||||
create: {
|
||||
id: temp_events[i].id,
|
||||
//
|
||||
name: temp_events[i].name,
|
||||
code: temp_events[i].code,
|
||||
price: temp_events[i].price,
|
||||
taxes: temp_events[i].taxes,
|
||||
tags: temp_events[i].tags,
|
||||
sizes: temp_events[i].sizes,
|
||||
publish: temp_events[i].publish,
|
||||
gender: temp_events[i].gender,
|
||||
coverUrl: temp_events[i].coverUrl,
|
||||
images: temp_events[i].images,
|
||||
colors: temp_events[i].colors,
|
||||
quantity: temp_events[i].quantity,
|
||||
category: temp_events[i].category,
|
||||
available: temp_events[i].available,
|
||||
totalSold: temp_events[i].totalSold,
|
||||
description: temp_events[i].description,
|
||||
totalRatings: temp_events[i].totalRatings,
|
||||
totalReviews: temp_events[i].totalReviews,
|
||||
inventoryType: temp_events[i].inventoryType,
|
||||
subDescription: temp_events[i].subDescription,
|
||||
priceSale: temp_events[i].priceSale,
|
||||
newLabel: temp_events[i].newLabel,
|
||||
saleLabel: temp_events[i].saleLabel,
|
||||
ratings: temp_events[i].ratings,
|
||||
// review: { create: temp_pr },
|
||||
reviews: { create: temp_pr },
|
||||
sku: temp_events[i].sku,
|
||||
//
|
||||
eventDate: new Date(_mock.time(i)),
|
||||
title: temp_events[i].name,
|
||||
currency: 'HKD',
|
||||
duration_m: 120,
|
||||
ageBottom: 18,
|
||||
ageTop: 60,
|
||||
location: 'Hong Kong',
|
||||
avatar: temp_events[i].images,
|
||||
//
|
||||
joinMembers: memberList(5 - i),
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log('seed eventItem done');
|
||||
}
|
||||
|
||||
const EventItem = eventItem()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { EventItem as EventItemSeed };
|
61
03_source/cms_backend/prisma/seeds/eventReview.ts
Normal file
61
03_source/cms_backend/prisma/seeds/eventReview.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { _mock } from './_mock';
|
||||
import { _tags } from './assets';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const generateAttachments = () => Array.from({ length: 20 }, (_, index) => _mock.image.event(index));
|
||||
|
||||
const generateReviews = () => {
|
||||
const attachments = generateAttachments();
|
||||
|
||||
return Array.from({ length: 8 }, (_, index) => ({
|
||||
// id: _mock.id(index),
|
||||
name: _mock.fullName(index),
|
||||
postedAt: _mock.time(index),
|
||||
comment: _mock.sentence(index),
|
||||
isPurchased: _mock.boolean(index),
|
||||
rating: _mock.number.rating(index),
|
||||
avatarUrl: _mock.image.avatar(index),
|
||||
helpful: _mock.number.nativeL(index),
|
||||
attachments: (index === 1 && attachments.slice(0, 1)) || (index === 3 && attachments.slice(2, 4)) || (index === 5 && attachments.slice(5, 8)) || [],
|
||||
}));
|
||||
};
|
||||
|
||||
export const _eventsReview = () => {
|
||||
return generateReviews();
|
||||
};
|
||||
|
||||
async function eventReview() {
|
||||
const temp_pr = _eventsReview();
|
||||
|
||||
for (let i = 0; i < temp_pr.length; i++) {
|
||||
const temp = await prisma.eventReview.upsert({
|
||||
where: { id: i.toString() },
|
||||
update: {},
|
||||
create: {
|
||||
name: temp_pr[i].name,
|
||||
rating: temp_pr[i].rating,
|
||||
comment: temp_pr[i].comment,
|
||||
helpful: temp_pr[i].helpful,
|
||||
avatarUrl: temp_pr[i].avatarUrl,
|
||||
isPurchased: temp_pr[i].isPurchased,
|
||||
attachments: temp_pr[i].attachments,
|
||||
postedAt: temp_pr[i].postedAt,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log('seed eventReview done');
|
||||
}
|
||||
|
||||
const EventReview = eventReview()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { EventReview as EventReviewSeed };
|
@@ -4,16 +4,7 @@ import { _tags } from './assets';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const COLORS = [
|
||||
'#FF4842',
|
||||
'#1890FF',
|
||||
'#FFC0CB',
|
||||
'#00AB55',
|
||||
'#FFC107',
|
||||
'#7F00FF',
|
||||
'#000000',
|
||||
'#FFFFFF'
|
||||
];
|
||||
const COLORS = ['#FF4842', '#1890FF', '#FFC0CB', '#00AB55', '#FFC107', '#7F00FF', '#000000', '#FFFFFF'];
|
||||
|
||||
const DESCRIPTION = `
|
||||
<h6>Specifications</h6>
|
||||
@@ -113,8 +104,7 @@ const getColorSliceForIndex = (index: number) => {
|
||||
return COLORS.slice(2, 6); // Default case
|
||||
};
|
||||
|
||||
const generateAttachments = () =>
|
||||
Array.from({ length: 20 }, (_, index) => _mock.image.product(index));
|
||||
const generateAttachments = () => Array.from({ length: 20 }, (_, index) => _mock.image.product(index));
|
||||
|
||||
const generateReviews = () => {
|
||||
const attachments = generateAttachments();
|
||||
@@ -128,11 +118,7 @@ const generateReviews = () => {
|
||||
rating: _mock.number.rating(index),
|
||||
avatarUrl: _mock.image.avatar(index),
|
||||
helpful: _mock.number.nativeL(index),
|
||||
attachments:
|
||||
(index === 1 && attachments.slice(0, 1)) ||
|
||||
(index === 3 && attachments.slice(2, 4)) ||
|
||||
(index === 5 && attachments.slice(5, 8)) ||
|
||||
[]
|
||||
attachments: (index === 1 && attachments.slice(0, 1)) || (index === 3 && attachments.slice(2, 4)) || (index === 5 && attachments.slice(5, 8)) || [],
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -140,7 +126,7 @@ const generateRatings = () =>
|
||||
Array.from({ length: 5 }, (_, index) => ({
|
||||
name: `${index + 1} Star`,
|
||||
starCount: _mock.number.nativeL(index),
|
||||
reviewCount: _mock.number.nativeL(index + 1)
|
||||
reviewCount: _mock.number.nativeL(index + 1),
|
||||
}));
|
||||
|
||||
const generateImages = () => Array.from({ length: 8 }, (_, index) => _mock.image.product(index));
|
||||
@@ -164,8 +150,8 @@ async function productReview() {
|
||||
avatarUrl: temp_pr[i].avatarUrl,
|
||||
isPurchased: temp_pr[i].isPurchased,
|
||||
attachments: temp_pr[i].attachments,
|
||||
postedAt: temp_pr[i].postedAt
|
||||
}
|
||||
postedAt: temp_pr[i].postedAt,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log('seed productReview done');
|
||||
|
@@ -8,8 +8,9 @@ async function superuser() {
|
||||
create: {
|
||||
email: 'admin1@123.com',
|
||||
name: 'Admin1',
|
||||
password: 'Aa12345678'
|
||||
}
|
||||
password: 'Aa12345678',
|
||||
admin: true,
|
||||
},
|
||||
});
|
||||
|
||||
// swagger test
|
||||
@@ -19,8 +20,9 @@ async function superuser() {
|
||||
create: {
|
||||
email: 'fake@example.com',
|
||||
name: 'swagger user',
|
||||
password: 'password1'
|
||||
}
|
||||
password: 'password1',
|
||||
admin: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('seed superuser done');
|
||||
|
@@ -9,16 +9,29 @@ async function user() {
|
||||
email: 'alice@prisma.io',
|
||||
name: 'Alice',
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
},
|
||||
});
|
||||
|
||||
const bob = await prisma.user.upsert({
|
||||
await prisma.user.upsert({
|
||||
where: { email: 'demo@minimals.cc' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'demo@minimals.cc',
|
||||
name: 'Demo',
|
||||
password: '@2Minimal',
|
||||
emailVerified: new Date(),
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.user.upsert({
|
||||
where: { email: 'bob@prisma.io' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'bob@prisma.io',
|
||||
name: 'Bob',
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
},
|
||||
});
|
||||
console.log('seed user done');
|
||||
|
@@ -39,10 +39,12 @@ async function userItem() {
|
||||
//
|
||||
username: 'admin@123.com',
|
||||
password: await generateHash('Aa1234567'),
|
||||
//
|
||||
isAdmin: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i = 1; i < 20; i++) {
|
||||
for (let i = 1; i < 3; i++) {
|
||||
const CJK_LOCALES = {
|
||||
en: enFaker,
|
||||
zh: zhFaker,
|
||||
@@ -77,6 +79,8 @@ async function userItem() {
|
||||
//
|
||||
username: randomFaker.internet.username(),
|
||||
password: await generateHash('Abc1234!'),
|
||||
//
|
||||
isAdmin: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
130
03_source/cms_backend/prisma/seeds/userMeta.ts
Normal file
130
03_source/cms_backend/prisma/seeds/userMeta.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { generateHash } from 'src/utils/hash';
|
||||
import { Config, names, uniqueNamesGenerator } from 'unique-names-generator';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
import { faker as enFaker } from '@faker-js/faker/locale/en_US';
|
||||
import { faker as zhFaker } from '@faker-js/faker/locale/zh_CN';
|
||||
import { faker as jaFaker } from '@faker-js/faker/locale/ja';
|
||||
import { faker as koFaker } from '@faker-js/faker/locale/ko';
|
||||
import { faker as twFaker } from '@faker-js/faker/locale/zh_TW';
|
||||
|
||||
const SEED_EMAIL_DOMAIN = 'seed.com';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function userMeta() {
|
||||
const config: Config = { dictionaries: [names] };
|
||||
const firstName = uniqueNamesGenerator(config);
|
||||
const lastName = uniqueNamesGenerator(config);
|
||||
const username = `${firstName.toLowerCase()}-${lastName.toLowerCase()}`;
|
||||
|
||||
const alice = await prisma.userMeta.upsert({
|
||||
where: { id: 'admin_uuid' },
|
||||
update: {},
|
||||
create: {
|
||||
name: `admin test`,
|
||||
city: '',
|
||||
role: '',
|
||||
email: `admin@123.com`,
|
||||
state: '',
|
||||
status: '',
|
||||
address: '',
|
||||
country: '',
|
||||
zipCode: '',
|
||||
company: '',
|
||||
avatarUrl: '',
|
||||
phoneNumber: '',
|
||||
isVerified: true,
|
||||
//
|
||||
username: 'admin@123.com',
|
||||
password: await generateHash('Aa1234567'),
|
||||
//
|
||||
isAdmin: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i = 1; i < 3; i++) {
|
||||
const CJK_LOCALES = {
|
||||
en: enFaker,
|
||||
zh: zhFaker,
|
||||
ja: jaFaker,
|
||||
ko: koFaker,
|
||||
tw: twFaker,
|
||||
};
|
||||
function getRandomCJKFaker() {
|
||||
const locales = Object.keys(CJK_LOCALES);
|
||||
const randomKey = locales[Math.floor(Math.random() * locales.length)] as keyof typeof CJK_LOCALES;
|
||||
return CJK_LOCALES[randomKey];
|
||||
}
|
||||
const randomFaker = getRandomCJKFaker();
|
||||
|
||||
await prisma.userMeta.upsert({
|
||||
where: { id: i.toString() },
|
||||
update: {},
|
||||
create: {
|
||||
name: randomFaker.person.fullName(),
|
||||
city: randomFaker.location.city(),
|
||||
role: ROLE[Math.floor(Math.random() * ROLE.length)],
|
||||
email: randomFaker.internet.email(),
|
||||
state: randomFaker.location.state(),
|
||||
status: STATUS[Math.floor(Math.random() * STATUS.length)],
|
||||
address: randomFaker.location.streetAddress(),
|
||||
country: randomFaker.location.country(),
|
||||
zipCode: randomFaker.location.zipCode(),
|
||||
company: randomFaker.company.name(),
|
||||
avatarUrl: randomFaker.image.avatar(),
|
||||
phoneNumber: randomFaker.phone.number(),
|
||||
isVerified: true,
|
||||
//
|
||||
username: randomFaker.internet.username(),
|
||||
password: await generateHash('Abc1234!'),
|
||||
//
|
||||
isAdmin: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('seed userMeta done');
|
||||
}
|
||||
|
||||
const userMetaSeed = userMeta()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export { userMetaSeed };
|
||||
|
||||
const ROLE = [
|
||||
`CEO`,
|
||||
`CTO`,
|
||||
`Project Coordinator`,
|
||||
`Team Leader`,
|
||||
`Software Developer`,
|
||||
`Marketing Strategist`,
|
||||
`Data Analyst`,
|
||||
`Product Owner`,
|
||||
`Graphic Designer`,
|
||||
`Operations Manager`,
|
||||
`Customer Support Specialist`,
|
||||
`Sales Manager`,
|
||||
`HR Recruiter`,
|
||||
`Business Consultant`,
|
||||
`Financial Planner`,
|
||||
`Network Engineer`,
|
||||
`Content Creator`,
|
||||
`Quality Assurance Tester`,
|
||||
`Public Relations Officer`,
|
||||
`IT Administrator`,
|
||||
`Compliance Officer`,
|
||||
`Event Planner`,
|
||||
`Legal Counsel`,
|
||||
`Training Coordinator`,
|
||||
];
|
||||
|
||||
const STATUS = ['active', 'pending', 'banned'];
|
@@ -4,7 +4,7 @@ import { _mock } from 'src/_mock';
|
||||
|
||||
export const JWT_SECRET = 'minimal-secret-key';
|
||||
|
||||
export const JWT_EXPIRES_IN = '3 days';
|
||||
export const JWT_EXPIRES_IN = '14 days';
|
||||
|
||||
export const _users = [
|
||||
{
|
||||
|
24
03_source/cms_backend/src/app/api/AccessLog/_GUIDELINES.md
Normal file
24
03_source/cms_backend/src/app/api/AccessLog/_GUIDELINES.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# GUIDELINE
|
||||
|
||||
- this is a AppLog api endpoint
|
||||
- this is a demo to handle AppLog record
|
||||
- use single file for single db table/collection only
|
||||
|
||||
## `route.ts`
|
||||
|
||||
`route.ts` - handle `GET`, `POST`, `PUT`, `DELETE`
|
||||
`detail/route.ts` - handle `GET` request of specific `AppLog` by id
|
||||
|
||||
## `test.http`
|
||||
|
||||
store test request
|
||||
|
||||
## `../../services/AppLog.service.ts`
|
||||
|
||||
AppLog schema CRUD handler
|
||||
|
||||
`listAppLogs` - list AppLog record
|
||||
`getAppLog` - get AppLog record by id
|
||||
`createNewAppLog` - create AppLog record
|
||||
`updateAppLog` - update AppLog record by id
|
||||
`deleteAppLog` - delete AppLog record by id
|
38
03_source/cms_backend/src/app/api/AccessLog/detail/route.ts
Normal file
38
03_source/cms_backend/src/app/api/AccessLog/detail/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// src/app/api/AccessLog/detail/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Get single AccessLog record detail
|
||||
//
|
||||
// RULES:
|
||||
// - Return complete AccessLog details
|
||||
//
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { AccessLogService } from '../../../../modules/AccessLog/AccessLog.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* GET - Get AccessLog details
|
||||
**************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: accessLogId must exist
|
||||
const accessLogId = searchParams.get('accessLogId');
|
||||
if (!accessLogId) return response({ message: 'accessLogId is required!' }, STATUS.BAD_REQUEST);
|
||||
|
||||
const accessLog = await AccessLogService.findById(accessLogId);
|
||||
|
||||
if (!accessLog) return response({ message: 'AccessLog not found!' }, STATUS.NOT_FOUND);
|
||||
|
||||
return response({ accessLog }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AccessLog - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/AppLog/detail?appLogId=e1bb8e4a-da37-4dbc-b8f2-9ad233a102ad
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/AppLog/detail?start=2025-01-01&end=2025-12-31
|
76
03_source/cms_backend/src/app/api/AccessLog/route.ts
Normal file
76
03_source/cms_backend/src/app/api/AccessLog/route.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listAccessLogs } from 'src/app/services/AccessLog.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
const result = await listAccessLogs();
|
||||
|
||||
return response(result, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AccessLog - Get all', error);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// ***************************************
|
||||
// * POST - create AccessLog
|
||||
// ***************************************
|
||||
// */
|
||||
// export async function POST(req: NextRequest) {
|
||||
// const { data } = await req.json();
|
||||
|
||||
// try {
|
||||
// const createResult = await AccessLogService.create(data);
|
||||
|
||||
// return response(createResult, STATUS.OK);
|
||||
// } catch (error) {
|
||||
// return handleError('AccessLog - Create', error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// ***************************************
|
||||
// * PUT - update AccessLog
|
||||
// ***************************************
|
||||
// */
|
||||
// export async function PUT(req: NextRequest) {
|
||||
// const { searchParams } = req.nextUrl;
|
||||
// const accessLogId = searchParams.get('accessLogId');
|
||||
|
||||
// const { data } = await req.json();
|
||||
|
||||
// try {
|
||||
// if (!accessLogId) throw new Error('accessLogId cannot be null');
|
||||
|
||||
// const updateResult = await AccessLogService.update(accessLogId, data);
|
||||
|
||||
// return response(updateResult, STATUS.OK);
|
||||
// } catch (error) {
|
||||
// return handleError('AccessLog - Update', error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// ***************************************
|
||||
// * DELETE - delete AccessLog
|
||||
// ***************************************
|
||||
// */
|
||||
// export async function DELETE(req: NextRequest) {
|
||||
// const { searchParams } = req.nextUrl;
|
||||
// const accessLogId = searchParams.get('accessLogId');
|
||||
|
||||
// try {
|
||||
// if (!accessLogId) throw new Error('accessLogId cannot be null');
|
||||
|
||||
// const deleteResult = await AccessLogService.delete(accessLogId);
|
||||
|
||||
// return response(deleteResult, STATUS.OK);
|
||||
// } catch (error) {
|
||||
// return handleError('AccessLog - Delete', error);
|
||||
// }
|
||||
// }
|
33
03_source/cms_backend/src/app/api/AccessLog/test.http
Normal file
33
03_source/cms_backend/src/app/api/AccessLog/test.http
Normal file
@@ -0,0 +1,33 @@
|
||||
###
|
||||
GET http://localhost:7272/api/AccessLog
|
||||
|
||||
###
|
||||
GET http://localhost:7272/api/AccessLog?accessLogId=51f2f5dd-78be-4069-ba29-09d2a5026191
|
||||
|
||||
###
|
||||
POST http://localhost:7272/api/AccessLog
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"userId": "user123",
|
||||
"ipAddress": "192.168.1.1",
|
||||
"userAgent": "Mozilla/5.0",
|
||||
"action": "LOGIN",
|
||||
"path": "/api/auth/login",
|
||||
"status": 200
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
PUT http://localhost:7272/api/AccessLog?accessLogId=51f2f5dd-78be-4069-ba29-09d2a5026191
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"status": 404
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
DELETE http://localhost:7272/api/AccessLog?accessLogId=51f2f5dd-78be-4069-ba29-09d2a5026191
|
24
03_source/cms_backend/src/app/api/AppLog/_GUIDELINES.md
Normal file
24
03_source/cms_backend/src/app/api/AppLog/_GUIDELINES.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# GUIDELINE
|
||||
|
||||
- this is a AppLog api endpoint
|
||||
- this is a demo to handle AppLog record
|
||||
- use single file for single db table/collection only
|
||||
|
||||
## `route.ts`
|
||||
|
||||
`route.ts` - handle `GET`, `POST`, `PUT`, `DELETE`
|
||||
`detail/route.ts` - handle `GET` request of specific `AppLog` by id
|
||||
|
||||
## `test.http`
|
||||
|
||||
store test request
|
||||
|
||||
## `../../services/AppLog.service.ts`
|
||||
|
||||
AppLog schema CRUD handler
|
||||
|
||||
`listAppLogs` - list AppLog record
|
||||
`getAppLog` - get AppLog record by id
|
||||
`createNewAppLog` - create AppLog record
|
||||
`updateAppLog` - update AppLog record by id
|
||||
`deleteAppLog` - delete AppLog record by id
|
39
03_source/cms_backend/src/app/api/AppLog/detail/route.ts
Normal file
39
03_source/cms_backend/src/app/api/AppLog/detail/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// src/app/api/AppLog/detail/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Get single AppLog record detail
|
||||
//
|
||||
// RULES:
|
||||
// - Return complete AppLog details
|
||||
//
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* GET - Get AppLog details
|
||||
**************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest) {
|
||||
// Original user details functionality
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: appLogId must exist
|
||||
const appLogId = searchParams.get('appLogId');
|
||||
if (!appLogId) return response({ message: 'appLogId is required!' }, STATUS.BAD_REQUEST);
|
||||
|
||||
const appLog = await prisma.appLog.findFirst({ where: { id: appLogId } });
|
||||
|
||||
if (!appLog) return response({ message: 'AppLog not found!' }, STATUS.NOT_FOUND);
|
||||
|
||||
return response({ appLog }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AppLog - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/AppLog/detail?appLogId=e1bb8e4a-da37-4dbc-b8f2-9ad233a102ad
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/AppLog/detail?start=2025-01-01&end=2025-12-31
|
81
03_source/cms_backend/src/app/api/AppLog/route.ts
Normal file
81
03_source/cms_backend/src/app/api/AppLog/route.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import type { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { listAppLogs, deleteAppLog, updateAppLog, createNewAppLog } from 'src/app/services/AppLog.service';
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
const result = await listAppLogs();
|
||||
|
||||
return response(result, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Post - Get latest', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* POST - create AppLog
|
||||
***************************************
|
||||
*/
|
||||
export async function POST(req: NextRequest) {
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
// TODO: obsolete createNewAppLog
|
||||
const createResult = await createNewAppLog(data);
|
||||
|
||||
return response(createResult, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AppLog - Create', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* PUT - update AppLog
|
||||
***************************************
|
||||
*/
|
||||
export async function PUT(req: NextRequest) {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const appLogId = searchParams.get('appLogId');
|
||||
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
if (!appLogId) throw new Error('appLogId cannot null');
|
||||
const id: number = parseInt(appLogId);
|
||||
|
||||
const updateResult = await updateAppLog(id, data);
|
||||
|
||||
return response(updateResult, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AppLog - Update', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* DELETE - update AppLog
|
||||
***************************************
|
||||
*/
|
||||
export async function DELETE(req: NextRequest) {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const appLogId = searchParams.get('appLogId');
|
||||
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
if (!appLogId) throw new Error('appLogId cannot null');
|
||||
const id: number = parseInt(appLogId);
|
||||
|
||||
const deleteResult = await deleteAppLog(id);
|
||||
|
||||
return response(deleteResult, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('AppLog - Update', error);
|
||||
}
|
||||
}
|
25
03_source/cms_backend/src/app/api/AppLog/test.http
Normal file
25
03_source/cms_backend/src/app/api/AppLog/test.http
Normal file
@@ -0,0 +1,25 @@
|
||||
###
|
||||
GET http://localhost:7272/api/AppLog
|
||||
|
||||
###
|
||||
GET http://localhost:7272/api/AppLog?appLogId=51f2f5dd-78be-4069-ba29-09d2a5026191
|
||||
|
||||
###
|
||||
POST http://localhost:7272/api/AppLog?appLogId=1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"data":{"hello": "test"}
|
||||
}
|
||||
|
||||
###
|
||||
PUT http://localhost:7272/api/AppLog?appLogId=1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"data": {"hello": "test"}
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
DELETE http://localhost:7272/api/AppLog?appLogId=1
|
@@ -1,13 +1,20 @@
|
||||
import type { User } from '@prisma/client';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { headers } from 'next/headers';
|
||||
|
||||
import { verify } from 'src/utils/jwt';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { _users, JWT_SECRET } from 'src/_mock/_auth';
|
||||
import { JWT_SECRET } from 'src/_mock/_auth';
|
||||
import { getUserById } from 'src/app/services/user.service';
|
||||
import { createAccessLog } from 'src/app/services/AccessLog.service';
|
||||
|
||||
import { flattenNextjsRequest } from '../sign-in/flattenNextjsRequest';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const runtime = 'edge';
|
||||
// export const runtime = 'edge';
|
||||
|
||||
/**
|
||||
* This API is used for demo purpose only
|
||||
@@ -17,25 +24,44 @@ export const runtime = 'edge';
|
||||
* You should not expose the JWT_SECRET in the client side
|
||||
*/
|
||||
|
||||
export async function GET() {
|
||||
const USER_TOKEN_CHECK_FAILED = 'user token check failed';
|
||||
const INVALID_AUTH_TOKEN = 'Invalid authorization token';
|
||||
const USER_ID_NOT_FOUND = 'userId not found';
|
||||
const USER_TOKEN_OK = 'user token check ok';
|
||||
const AUTHORIZATION_TOKEN_MISSING_OR_INVALID = 'Authorization token missing or invalid';
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||
|
||||
try {
|
||||
const headersList = headers();
|
||||
const authorization = headersList.get('authorization');
|
||||
|
||||
if (!authorization || !authorization.startsWith('Bearer ')) {
|
||||
return response({ message: 'Authorization token missing or invalid' }, STATUS.UNAUTHORIZED);
|
||||
return response({ message: AUTHORIZATION_TOKEN_MISSING_OR_INVALID }, STATUS.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
const accessToken = `${authorization}`.split(' ')[1];
|
||||
const data = await verify(accessToken, JWT_SECRET);
|
||||
console.log(data.userId);
|
||||
|
||||
const currentUser = _users.find((user) => user.id === data.userId);
|
||||
if (data.userId) {
|
||||
// TODO: remove me
|
||||
// const currentUser = _users.find((user) => user.id === data.userId);
|
||||
const currentUser: User | null = await getUserById(data.userId);
|
||||
|
||||
if (!currentUser) {
|
||||
return response({ message: 'Invalid authorization token' }, STATUS.UNAUTHORIZED);
|
||||
if (!currentUser) {
|
||||
createAccessLog('', USER_TOKEN_CHECK_FAILED, debug);
|
||||
|
||||
return response({ message: INVALID_AUTH_TOKEN }, STATUS.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
createAccessLog(currentUser.id, USER_TOKEN_OK, debug);
|
||||
|
||||
return response({ user: currentUser }, STATUS.OK);
|
||||
} else {
|
||||
return response({ message: USER_ID_NOT_FOUND }, STATUS.ERROR);
|
||||
}
|
||||
|
||||
return response({ user: currentUser }, 200);
|
||||
} catch (error) {
|
||||
return handleError('[Auth] - Me', error);
|
||||
}
|
||||
|
25
03_source/cms_backend/src/app/api/auth/me/test.http
Normal file
25
03_source/cms_backend/src/app/api/auth/me/test.http
Normal file
@@ -0,0 +1,25 @@
|
||||
###
|
||||
# username and password ok
|
||||
GET http://localhost:7272/api/auth/me
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbWJnbnUyengwMDBjaHEzaGZ3dmtjejlvIiwiaWF0IjoxNzQ4OTY0ODkyLCJleHAiOjE3NTAxNzQ0OTJ9.lo04laCxtm0IVeYaETEV3hXKyDmXPEn7SyWtY2VR4dI
|
||||
|
||||
|
||||
###
|
||||
# There is no user corresponding to the email address.
|
||||
POST http://localhost:7272/api/auth/sign-in
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"email": "demo@minimals1.cc",
|
||||
"password": "@2Minimal"
|
||||
}
|
||||
|
||||
###
|
||||
# Wrong password
|
||||
POST http://localhost:7272/api/auth/sign-in
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"email": "demo@minimals.cc",
|
||||
"password": "@2Min111imal"
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
export function flattenNextjsRequest(req: NextRequest) {
|
||||
return Object.fromEntries(req.headers.entries());
|
||||
}
|
@@ -3,12 +3,14 @@ import type { NextRequest } from 'next/server';
|
||||
import { sign } from 'src/utils/jwt';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { _users, JWT_SECRET, JWT_EXPIRES_IN } from 'src/_mock/_auth';
|
||||
import { JWT_SECRET, JWT_EXPIRES_IN } from 'src/_mock/_auth';
|
||||
import { createAccessLog } from 'src/app/services/AccessLog.service';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { flattenNextjsRequest } from './flattenNextjsRequest';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
/**
|
||||
* This API is used for demo purpose only
|
||||
* You should use a real database
|
||||
@@ -17,29 +19,36 @@ export const runtime = 'edge';
|
||||
* You should not expose the JWT_SECRET in the client side
|
||||
*/
|
||||
|
||||
const ERR_USER_NOT_FOUND = 'There is no user corresponding to the email address.';
|
||||
const ERR_WRONG_PASSWORD = 'Wrong password';
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||
|
||||
try {
|
||||
const { email, password } = await req.json();
|
||||
|
||||
const currentUser = _users.find((user) => user.email === email);
|
||||
|
||||
const currentUser = await prisma.user.findFirst({ where: { email } });
|
||||
if (!currentUser) {
|
||||
return response(
|
||||
{ message: 'There is no user corresponding to the email address.' },
|
||||
STATUS.UNAUTHORIZED
|
||||
);
|
||||
await createAccessLog('', `user tried login with email ${email}`, { debug });
|
||||
return response({ message: ERR_USER_NOT_FOUND }, STATUS.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
if (currentUser?.password !== password) {
|
||||
return response({ message: 'Wrong password' }, STATUS.UNAUTHORIZED);
|
||||
await createAccessLog(currentUser.id, 'user logged with wrong password', { debug });
|
||||
return response({ message: ERR_WRONG_PASSWORD }, STATUS.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
const accessToken = await sign({ userId: currentUser?.id }, JWT_SECRET, {
|
||||
expiresIn: JWT_EXPIRES_IN,
|
||||
});
|
||||
|
||||
return response({ user: currentUser, accessToken }, 200);
|
||||
await createAccessLog(currentUser.id, 'access granted', { debug });
|
||||
|
||||
return response({ user: currentUser, accessToken }, STATUS.OK);
|
||||
} catch (error) {
|
||||
await createAccessLog('', 'attempted login but failed', { debug, error });
|
||||
|
||||
return handleError('Auth - Sign in', error);
|
||||
}
|
||||
}
|
||||
|
29
03_source/cms_backend/src/app/api/auth/sign-in/test.http
Normal file
29
03_source/cms_backend/src/app/api/auth/sign-in/test.http
Normal file
@@ -0,0 +1,29 @@
|
||||
###
|
||||
# username and password ok
|
||||
POST http://localhost:7272/api/auth/sign-in
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"email": "demo@minimals.cc",
|
||||
"password": "@2Minimal"
|
||||
}
|
||||
|
||||
###
|
||||
# There is no user corresponding to the email address.
|
||||
POST http://localhost:7272/api/auth/sign-in
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"email": "demo@minimals1.cc",
|
||||
"password": "@2Minimal"
|
||||
}
|
||||
|
||||
###
|
||||
# Wrong password
|
||||
POST http://localhost:7272/api/auth/sign-in
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"email": "demo@minimals.cc",
|
||||
"password": "@2Min111imal"
|
||||
}
|
@@ -24,10 +24,7 @@ export async function POST(req: NextRequest) {
|
||||
const userExists = _users.find((user) => user.email === email);
|
||||
|
||||
if (userExists) {
|
||||
return response(
|
||||
{ message: 'There already exists an account with the given email address.' },
|
||||
STATUS.CONFLICT
|
||||
);
|
||||
return response({ message: 'There already exists an account with the given email address.' }, STATUS.CONFLICT);
|
||||
}
|
||||
|
||||
const newUser = {
|
||||
|
25
03_source/cms_backend/src/app/api/event/_GUIDELINES.md
Normal file
25
03_source/cms_backend/src/app/api/event/_GUIDELINES.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# GUIDELINE
|
||||
|
||||
## Event / event
|
||||
|
||||
- this is a `event` api endpoint
|
||||
- this is a demo to handle `event` record
|
||||
- use single file for single db table/collection only
|
||||
|
||||
## `route.ts`
|
||||
|
||||
handle `GET`, `POST`, `PUT`, `DELETE`
|
||||
|
||||
## `test.http`
|
||||
|
||||
store test request
|
||||
|
||||
## `../../services/event.service.ts`
|
||||
|
||||
event schema CRUD handler
|
||||
|
||||
`listEvents` - list `event` record
|
||||
`getEvent` - get `event` record by id
|
||||
`createNewEvent` - create `event` record
|
||||
`updateEvent` - update `event` record by id
|
||||
`deleteEvent` - delete `event` record by id
|
75
03_source/cms_backend/src/app/api/event/createEvent/route.ts
Normal file
75
03_source/cms_backend/src/app/api/event/createEvent/route.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
// src/app/api/product/createEvent/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// create product to db
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
//
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* POST - Events
|
||||
*************************************** */
|
||||
export async function POST(req: NextRequest) {
|
||||
// logger('[Event] list', events.length);
|
||||
const { data } = await req.json();
|
||||
const createForm: CreateEventData = data as unknown as CreateEventData;
|
||||
|
||||
console.log({ createForm });
|
||||
|
||||
try {
|
||||
console.log({ data });
|
||||
await prisma.productItem.create({ data: createForm });
|
||||
return response({ hello: 'world' }, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.log({ hello: 'world', data });
|
||||
return handleError('Event - Create', error);
|
||||
}
|
||||
}
|
||||
|
||||
type CreateEventData = {
|
||||
// id: string;
|
||||
sku: string;
|
||||
name: string;
|
||||
code: string;
|
||||
price: number;
|
||||
taxes: number;
|
||||
tags: string[];
|
||||
sizes: string[];
|
||||
publish: string;
|
||||
gender: string[];
|
||||
coverUrl: string;
|
||||
images: string[];
|
||||
colors: string[];
|
||||
quantity: number;
|
||||
category: string;
|
||||
available: number;
|
||||
totalSold: number;
|
||||
description: string;
|
||||
totalRatings: number;
|
||||
totalReviews: number;
|
||||
inventoryType: string;
|
||||
subDescription: string;
|
||||
priceSale: number;
|
||||
newLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
saleLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
// ratings: {
|
||||
// name: string;
|
||||
// starCount: number;
|
||||
// reviewCount: number;
|
||||
// }[];
|
||||
};
|
44
03_source/cms_backend/src/app/api/event/deleteEvent/route.ts
Normal file
44
03_source/cms_backend/src/app/api/event/deleteEvent/route.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// src/app/api/event/deleteEvent/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// delete event from db by id
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* handle Delete Events
|
||||
*************************************** */
|
||||
export async function DELETE(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: eventId must exist
|
||||
const eventId = searchParams.get('eventId');
|
||||
if (!eventId) {
|
||||
return response({ message: 'Event ID is required!' }, STATUS.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// NOTE: eventId confirmed exist, run below
|
||||
const event = await prisma.eventItem.delete({ where: { id: eventId } });
|
||||
|
||||
if (!event) {
|
||||
return response({ message: 'Event not found!' }, STATUS.NOT_FOUND);
|
||||
}
|
||||
|
||||
logger('[Event] details', event.id);
|
||||
|
||||
return response({ event }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Event - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
###
|
||||
|
||||
DELETE http://localhost:7272/api/event/deleteEvent?eventId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b06
|
51
03_source/cms_backend/src/app/api/event/details/route.ts
Normal file
51
03_source/cms_backend/src/app/api/event/details/route.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// src/app/api/event/details/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// save event to db by id
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { L_INFO, L_ERROR } from 'src/constants';
|
||||
import { getEvent } from 'src/app/services/eventItem.service';
|
||||
import { createAppLog } from 'src/app/services/AppLog.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET Event detail
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
const debug = { 'req.headers': Object.fromEntries(req.headers.entries()) };
|
||||
|
||||
const { searchParams } = req.nextUrl;
|
||||
// RULES: for the incoming request, the `eventId` must exist
|
||||
const eventId = searchParams.get('eventId');
|
||||
|
||||
try {
|
||||
if (!eventId) {
|
||||
return response({ message: 'Event ID is required!' }, STATUS.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// NOTE: `eventId` confirmed exist, run below
|
||||
const event = await getEvent(eventId);
|
||||
console.log({ event });
|
||||
|
||||
// RULES: show error if not found
|
||||
if (!event) {
|
||||
return response({ message: 'Event not found!' }, STATUS.NOT_FOUND);
|
||||
}
|
||||
|
||||
// logger('[Event] details', event.id);
|
||||
await createAppLog(L_INFO, 'get event detail ok', { eventId });
|
||||
|
||||
return response({ event }, STATUS.OK);
|
||||
} catch (error) {
|
||||
await createAppLog(L_ERROR, 'error during getting event detail', { debug, eventId });
|
||||
return handleError('Event - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
###
|
||||
GET http://localhost:7272/api/event/details?eventId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
|
||||
|
||||
###
|
||||
GET http://localhost:7272/api/event/details
|
@@ -0,0 +1,30 @@
|
||||
// src/app/api/event/image/upload/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// handle upload event image
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
// import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET - Events
|
||||
*************************************** */
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const { data } = await req.json();
|
||||
console.log('helloworld');
|
||||
|
||||
return response({ hello: 'world' }, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.log({ hello: 'world' });
|
||||
return handleError('Event - store event image', error);
|
||||
}
|
||||
}
|
22
03_source/cms_backend/src/app/api/event/list/route.ts
Normal file
22
03_source/cms_backend/src/app/api/event/list/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
// src/app/api/event/list/route.ts
|
||||
import { listEvents } from 'src/app/services/eventItem.service';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET - Events, obsoleted
|
||||
*************************************** */
|
||||
export async function GET() {
|
||||
try {
|
||||
const events = await listEvents();
|
||||
|
||||
logger('[Event] list', events.length);
|
||||
|
||||
return response({ events }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Event - Get list', error);
|
||||
}
|
||||
}
|
3
03_source/cms_backend/src/app/api/event/list/test.http
Normal file
3
03_source/cms_backend/src/app/api/event/list/test.http
Normal file
@@ -0,0 +1,3 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/event/list
|
129
03_source/cms_backend/src/app/api/event/saveEvent/route.ts
Normal file
129
03_source/cms_backend/src/app/api/event/saveEvent/route.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
// src/app/api/event/saveEvent/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// save event to db by id
|
||||
//
|
||||
// RULES:
|
||||
// T.B.A.
|
||||
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/** **************************************
|
||||
* GET - Events
|
||||
*************************************** */
|
||||
export async function POST(req: NextRequest) {
|
||||
// logger('[Event] list', events.length);
|
||||
const { data } = await req.json();
|
||||
|
||||
try {
|
||||
const events = await prisma.eventItem.updateMany({
|
||||
data: {
|
||||
name: data.name,
|
||||
sku: data.sku,
|
||||
code: data.code,
|
||||
price: data.price,
|
||||
taxes: data.taxes,
|
||||
tags: data.tags,
|
||||
sizes: data.sizes,
|
||||
publish: data.publish,
|
||||
gender: data.gender,
|
||||
coverUrl: data.coverUrl,
|
||||
images: data.images,
|
||||
colors: data.colors,
|
||||
quantity: data.quantity,
|
||||
category: data.category,
|
||||
available: data.available,
|
||||
totalSold: data.totalSold,
|
||||
description: data.description,
|
||||
totalRatings: data.totalRatings,
|
||||
totalReviews: data.totalReviews,
|
||||
inventoryType: data.inventoryType,
|
||||
subDescription: data.subDescription,
|
||||
priceSale: data.priceSale,
|
||||
//
|
||||
newLabel: {
|
||||
content: data.newLabel?.content || '',
|
||||
enabled: data.newLabel?.enabled ?? false,
|
||||
},
|
||||
saleLabel: {
|
||||
content: data.saleLabel?.content || '',
|
||||
enabled: data.saleLabel?.enabled ?? false,
|
||||
},
|
||||
ratings: {
|
||||
set: data.ratings.map((rating: { name: string; starCount: number; reviewCount: number }) => ({
|
||||
name: rating.name,
|
||||
starCount: rating.starCount,
|
||||
reviewCount: rating.reviewCount,
|
||||
})),
|
||||
},
|
||||
},
|
||||
where: { id: data.id },
|
||||
});
|
||||
|
||||
return response({ data }, STATUS.OK);
|
||||
} catch (error) {
|
||||
console.log({ data });
|
||||
return handleError('Event - Get list', error);
|
||||
}
|
||||
}
|
||||
|
||||
export type IEventItem = {
|
||||
id: string;
|
||||
sku: string;
|
||||
name: string;
|
||||
code: string;
|
||||
price: number;
|
||||
taxes: number;
|
||||
tags: string[];
|
||||
sizes: string[];
|
||||
publish: string;
|
||||
gender: string[];
|
||||
coverUrl: string;
|
||||
images: string[];
|
||||
colors: string[];
|
||||
quantity: number;
|
||||
category: string;
|
||||
available: number;
|
||||
totalSold: number;
|
||||
description: string;
|
||||
totalRatings: number;
|
||||
totalReviews: number;
|
||||
// createdAt: IDateValue;
|
||||
inventoryType: string;
|
||||
subDescription: string;
|
||||
priceSale: number | null;
|
||||
// reviews: IEventReview[];
|
||||
newLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
saleLabel: {
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
ratings: {
|
||||
name: string;
|
||||
starCount: number;
|
||||
reviewCount: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type IDateValue = string | number | null;
|
||||
|
||||
export type IEventReview = {
|
||||
id: string;
|
||||
name: string;
|
||||
rating: number;
|
||||
comment: string;
|
||||
helpful: number;
|
||||
avatarUrl: string;
|
||||
postedAt: IDateValue;
|
||||
isPurchased: boolean;
|
||||
attachments?: string[];
|
||||
};
|
35
03_source/cms_backend/src/app/api/event/search/route.ts
Normal file
35
03_source/cms_backend/src/app/api/event/search/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { logger } from 'src/utils/logger';
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import { _events } from 'src/_mock/_event';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
/** **************************************
|
||||
* GET - Search events
|
||||
*************************************** */
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
const query = searchParams.get('query')?.trim().toLowerCase();
|
||||
|
||||
if (!query) {
|
||||
return response({ results: [] }, STATUS.OK);
|
||||
}
|
||||
|
||||
const events = _events();
|
||||
|
||||
// Accept search by name or sku
|
||||
const results = events.filter(({ name, sku }) => name.toLowerCase().includes(query) || sku?.toLowerCase().includes(query));
|
||||
|
||||
logger('[Event] search-results', results.length);
|
||||
|
||||
return response({ results }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Event - Get search', error);
|
||||
}
|
||||
}
|
23
03_source/cms_backend/src/app/api/helloworld/_GUIDELINES.md
Normal file
23
03_source/cms_backend/src/app/api/helloworld/_GUIDELINES.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# GUIDELINE
|
||||
|
||||
- this is a helloworld api endpoint
|
||||
- this is a demo to handle helloworld record
|
||||
- use single file for single db table/collection only
|
||||
|
||||
## `route.ts`
|
||||
|
||||
handle `GET`, `POST`, `PUT`, `DELETE`
|
||||
|
||||
## `test.http`
|
||||
|
||||
store test request
|
||||
|
||||
## `../../services/helloworld.service.ts`
|
||||
|
||||
helloworld schema CRUD handler
|
||||
|
||||
`listHelloworlds` - list helloworld record
|
||||
`getHelloworld` - get helloworld record by id
|
||||
`createNewHelloworld` - create helloworld record
|
||||
`updateHelloworld` - update helloworld record by id
|
||||
`deleteHelloworld` - delete helloworld record by id
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user