Compare commits
28 Commits
master
...
develop/cm
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5bebc1f40e | ||
![]() |
f4e5f94e17 | ||
![]() |
2d022cb613 | ||
![]() |
3560ea79fc | ||
![]() |
a441e3e52d | ||
![]() |
09ded06dd2 | ||
![]() |
7ecacd0692 | ||
![]() |
8a094afdd2 | ||
![]() |
64ca29cf60 | ||
![]() |
1aa0502edc | ||
![]() |
3e1f2e1057 | ||
![]() |
9be33f641f | ||
![]() |
30e4c69343 | ||
![]() |
04634b5c65 | ||
![]() |
f659020d89 | ||
![]() |
184aaa1b0a | ||
![]() |
a6170778cd | ||
![]() |
650127821b | ||
![]() |
5440f8ea14 | ||
![]() |
f4c9dbcc34 | ||
![]() |
f756fb8527 | ||
![]() |
3f10a0728c | ||
![]() |
ee0aa0353b | ||
![]() |
2c7316786c | ||
![]() |
89f91ec2a0 | ||
![]() |
1441863dcd | ||
![]() |
1835caee68 | ||
![]() |
bac8c70d4b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,7 +7,7 @@ _del
|
||||
*.bak
|
||||
*.log
|
||||
*.del
|
||||
**/_del
|
||||
**/*del
|
||||
|
||||
**/volumes/**
|
||||
006_lab
|
||||
|
@@ -1,11 +1,14 @@
|
||||
```markdown
|
||||
# Greetings
|
||||
|
||||
Hi,
|
||||
Imaging you are a software engineer and i will send you the guideline.
|
||||
|
||||
Imagine you are a software engineer and i will send you the guideline.
|
||||
plesae read it, prepare yourself and i will tell you the task afterwards
|
||||
|
||||
please read and understand the markdown files in directory
|
||||
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/000_AI_WORKSPACE/software_engineer/greetings`,
|
||||
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/000_AI_WORKSPACE/software-engineer/greetings`,
|
||||
it provides background information of project i want you to help.
|
||||
|
||||
thanks
|
||||
```
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
const getId = (id) => id.padStart(15, "0");
|
||||
const getId = (id) => id.padStart(15, '0');
|
||||
|
||||
const row_array = Array.from({ length: 10 }, (_, i) => [
|
||||
getId(String(i + 1)),
|
||||
faker.person.firstName(),
|
||||
"",
|
||||
'',
|
||||
faker.internet.email(),
|
||||
faker.phone.number(),
|
||||
faker.company.name(),
|
||||
@@ -19,13 +19,11 @@ const row_array = Array.from({ length: 10 }, (_, i) => [
|
||||
},
|
||||
Math.floor(Math.random() * (100 - 0 + 1)) + 0,
|
||||
faker.location.timeZone(),
|
||||
["en", "de", "es", "fr", "ja", "ko", "zh-CN"].sort(
|
||||
() => Math.random() - 0.5
|
||||
)[0],
|
||||
['en', 'de', 'es', 'fr', 'ja', 'ko', 'zh-CN'].sort(() => Math.random() - 0.5)[0],
|
||||
faker.finance.currencyCode(),
|
||||
]);
|
||||
|
||||
import fs from "fs";
|
||||
const filePath = "output.json";
|
||||
import fs from 'fs';
|
||||
const filePath = 'output.json';
|
||||
fs.writeFileSync(filePath, JSON.stringify(row_array, null, 2));
|
||||
console.log(`Wrote ${row_array.length} records to ${filePath}`);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Generated at: 2025-05-11T08:58:29.867Z
|
||||
// Generated at: 2025-05-13T05:24:33.962Z
|
||||
|
||||
|
||||
//
|
||||
@@ -114,7 +114,6 @@ Table Notifications {
|
||||
id text [pk, not null]
|
||||
read boolean
|
||||
type text
|
||||
author text
|
||||
job text
|
||||
description text
|
||||
NOTI_ID text
|
||||
@@ -122,6 +121,10 @@ Table Notifications {
|
||||
updated datetime
|
||||
to_user_id integer [ref: > UserMetas.id] // relation704048736
|
||||
from_user_id integer [ref: > UserMetas.id] // relation556806202
|
||||
author integer [ref: > UserMetas.id] // relation3182418120
|
||||
content text
|
||||
company text
|
||||
link varchar
|
||||
}
|
||||
|
||||
//
|
||||
@@ -203,9 +206,9 @@ Table QuizLPCategories {
|
||||
cat_image file
|
||||
pos integer
|
||||
init_answer text
|
||||
visible text
|
||||
created datetime
|
||||
updated datetime
|
||||
visible text
|
||||
slug text
|
||||
remarks text
|
||||
description text
|
||||
@@ -220,8 +223,6 @@ Table QuizLPQuestions {
|
||||
word text
|
||||
sound file
|
||||
cat_id integer [ref: > QuizLPCategories.id] // relation3870140739
|
||||
created datetime
|
||||
updated datetime
|
||||
cat_name text
|
||||
cat_image file
|
||||
pos integer
|
||||
@@ -230,6 +231,8 @@ Table QuizLPQuestions {
|
||||
slug text
|
||||
remarks text
|
||||
description text
|
||||
created datetime
|
||||
updated datetime
|
||||
}
|
||||
|
||||
//
|
||||
@@ -255,9 +258,9 @@ Table QuizMFCategories {
|
||||
cat_image file
|
||||
pos integer
|
||||
init_answer text
|
||||
visible text
|
||||
created datetime
|
||||
updated datetime
|
||||
visible text
|
||||
}
|
||||
|
||||
//
|
||||
@@ -338,17 +341,23 @@ Table Teachers {
|
||||
// collection type: base
|
||||
Table UserMetas {
|
||||
id text [pk, not null]
|
||||
helloworld text
|
||||
address text
|
||||
meta text
|
||||
user_id integer [ref: > users.id] // relation2809058197
|
||||
state text
|
||||
created datetime
|
||||
updated datetime
|
||||
status text
|
||||
avatar file
|
||||
role text
|
||||
name text
|
||||
email text
|
||||
phone text
|
||||
company text
|
||||
taxId text
|
||||
timezone text
|
||||
language text
|
||||
currency text
|
||||
billingAddress integer [ref: > billingAddress.id] // relation2115670734
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -1057,16 +1057,6 @@
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json3182418120",
|
||||
"maxSize": 0,
|
||||
"name": "author",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json4225294584",
|
||||
@@ -1150,6 +1140,51 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1305841361",
|
||||
"hidden": false,
|
||||
"id": "relation3182418120",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "author",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"convertURLs": false,
|
||||
"hidden": false,
|
||||
"id": "editor4274335913",
|
||||
"maxSize": 0,
|
||||
"name": "content",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "editor"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json1337919823",
|
||||
"maxSize": 0,
|
||||
"name": "company",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"exceptDomains": null,
|
||||
"hidden": false,
|
||||
"id": "url917281265",
|
||||
"name": "link",
|
||||
"onlyDomains": null,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "url"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -1715,6 +1750,20 @@
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -1735,20 +1784,6 @@
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
@@ -1857,26 +1892,6 @@
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
@@ -1979,6 +1994,26 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "editor"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -2147,6 +2182,20 @@
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -2166,20 +2215,6 @@
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -2835,7 +2870,7 @@
|
||||
"id": "text4192936109",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "helloworld",
|
||||
"name": "address",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
@@ -2866,6 +2901,20 @@
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2744374011",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "state",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -2886,20 +2935,6 @@
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2744374011",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "status",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "file376926767",
|
||||
@@ -2966,6 +3001,89 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1337919823",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "company",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2020362641",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "taxId",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text922858135",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "timezone",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3571151285",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "language",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1767278655",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "currency",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1509025625",
|
||||
"hidden": false,
|
||||
"id": "relation2115670734",
|
||||
"maxSelect": 999,
|
||||
"minSelect": 0,
|
||||
"name": "billingAddress",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -3569,11 +3687,11 @@
|
||||
},
|
||||
{
|
||||
"id": "pbc_1509025625",
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "billingAddress",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
@@ -3763,11 +3881,11 @@
|
||||
},
|
||||
{
|
||||
"id": "pbc_2109205374",
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "t1",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
|
@@ -9,7 +9,7 @@ import { ArrowLeft as ArrowLeftIcon } from '@phosphor-icons/react/dist/ssr/Arrow
|
||||
|
||||
import { config } from '@/config';
|
||||
import { paths } from '@/paths';
|
||||
import { CustomerCreateForm } from '@/components/dashboard/student/student-create-form';
|
||||
import { StudentCreateForm } from '@/components/dashboard/student/student-create-form';
|
||||
|
||||
export const metadata = { title: `Create | Customers | Dashboard | ${config.site.name}` } satisfies Metadata;
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function Page(): React.JSX.Element {
|
||||
<Typography variant="h4">Create customer</Typography>
|
||||
</div>
|
||||
</Stack>
|
||||
<CustomerCreateForm />
|
||||
<StudentCreateForm />
|
||||
</Stack>
|
||||
</Box>
|
||||
);
|
||||
|
@@ -1 +0,0 @@
|
||||
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/students/edit/[customerId]/page.tsx.draft` to handle `Student` record thanks, modify comments/variables/paths/functions name please
|
@@ -0,0 +1,6 @@
|
||||
this `tsx` file is clone from elsewhere,
|
||||
please understand, modify and update the content of
|
||||
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/students/edit/[customerId]/page.tsx.draft`
|
||||
to handle `Student` record thanks,
|
||||
|
||||
modify comments/variables/paths/functions name please
|
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
// src/app/dashboard/students/edit/[customerId]/page.tsx
|
||||
|
||||
// src/app/dashboard/students/edit/[customerId]/page.tsx
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import Box from '@mui/material/Box';
|
||||
@@ -11,7 +11,8 @@ import { ArrowLeft as ArrowLeftIcon } from '@phosphor-icons/react/dist/ssr/Arrow
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import { CrCategoryEditForm } from '@/components/dashboard/cr/categories/cr-category-edit-form';
|
||||
// TODO: remove me
|
||||
// import { CrCategoryEditForm } from '@/components/dashboard/cr/categories/cr-category-edit-form';
|
||||
import { StudentEditForm } from '@/components/dashboard/student/student-edit-form';
|
||||
|
||||
export default function Page(): React.JSX.Element {
|
@@ -1,9 +1,17 @@
|
||||
'use client';
|
||||
|
||||
// src/components/dashboard/student/student-create-form.tsx
|
||||
//
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { UpdateBillingAddressById } from '@/db/billingAddress/UpdateById';
|
||||
import { createStudent } from '@/db/Students/Create';
|
||||
import { getStudentById } from '@/db/Students/GetById';
|
||||
import { UpdateStudentById } from '@/db/Students/UpdateById';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
//
|
||||
import Avatar from '@mui/material/Avatar';
|
||||
import Box from '@mui/material/Box';
|
||||
import Button from '@mui/material/Button';
|
||||
@@ -16,41 +24,38 @@ import FormControl from '@mui/material/FormControl';
|
||||
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||
import FormHelperText from '@mui/material/FormHelperText';
|
||||
import InputLabel from '@mui/material/InputLabel';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import OutlinedInput from '@mui/material/OutlinedInput';
|
||||
import Select from '@mui/material/Select';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import Grid from '@mui/material/Unstable_Grid2';
|
||||
//
|
||||
import { Camera as CameraIcon } from '@phosphor-icons/react/dist/ssr/Camera';
|
||||
//
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z as zod } from 'zod';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { base64ToFile, fileToBase64 } from '@/lib/file-to-base64';
|
||||
import { pb } from '@/lib/pb';
|
||||
import { Option } from '@/components/core/option';
|
||||
import { toast } from '@/components/core/toaster';
|
||||
import { createCustomer } from '@/db/Customers/Create';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import FormLoading from '@/components/loading';
|
||||
|
||||
function fileToBase64(file: Blob): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = () => {
|
||||
resolve(reader.result as string);
|
||||
};
|
||||
reader.onerror = () => {
|
||||
reject(new Error('Error converting file to base64'));
|
||||
};
|
||||
});
|
||||
}
|
||||
// import ErrorDisplay from '../../error';
|
||||
import ErrorDisplay from '../error';
|
||||
import { CreateFormProps, Student } from './type.d';
|
||||
|
||||
// TODO: review schema
|
||||
const schema = zod.object({
|
||||
avatar: zod.string().optional(),
|
||||
name: zod.string().min(1, 'Name is required').max(255),
|
||||
email: zod.string().email('Must be a valid email').min(1, 'Email is required').max(255),
|
||||
phone: zod.string().min(1, 'Phone is required').max(15),
|
||||
company: zod.string().max(255),
|
||||
phone: zod.string().min(1, 'Phone is required').max(25),
|
||||
company: zod.string().max(255).optional(),
|
||||
billingAddress: zod.object({
|
||||
country: zod.string().min(1, 'Country is required').max(255),
|
||||
state: zod.string().min(1, 'State is required').max(255),
|
||||
@@ -63,12 +68,12 @@ const schema = zod.object({
|
||||
timezone: zod.string().min(1, 'Timezone is required').max(255),
|
||||
language: zod.string().min(1, 'Language is required').max(255),
|
||||
currency: zod.string().min(1, 'Currency is required').max(255),
|
||||
avatar: zod.string().optional(),
|
||||
});
|
||||
|
||||
type Values = zod.infer<typeof schema>;
|
||||
|
||||
const defaultValues = {
|
||||
avatar: '',
|
||||
name: 'new name',
|
||||
email: '123@123.com',
|
||||
phone: '91234567',
|
||||
@@ -85,10 +90,18 @@ const defaultValues = {
|
||||
timezone: 'new_york',
|
||||
language: 'en',
|
||||
currency: 'USD',
|
||||
avatar: '',
|
||||
} satisfies Values;
|
||||
|
||||
export function CustomerCreateForm(): React.JSX.Element {
|
||||
export function StudentCreateForm(): React.JSX.Element {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation(['students']);
|
||||
|
||||
//
|
||||
const [isUpdating, setIsUpdating] = React.useState<boolean>(false);
|
||||
const [showLoading, setShowLoading] = React.useState<boolean>(false);
|
||||
//
|
||||
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -100,14 +113,35 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
|
||||
const onSubmit = React.useCallback(
|
||||
async (values: Values): Promise<void> => {
|
||||
// Use standard create method from db/Customers/Create
|
||||
const tempCreate: CreateFormProps = {
|
||||
avatar: values.avatar ? await base64ToFile(values.avatar) : null,
|
||||
//
|
||||
name: values.name,
|
||||
email: values.email,
|
||||
phone: values.phone,
|
||||
company: values.company,
|
||||
timezone: values.timezone,
|
||||
language: values.language,
|
||||
currency: values.currency,
|
||||
taxId: values.taxId,
|
||||
state: 'pending',
|
||||
meta: {},
|
||||
};
|
||||
|
||||
try {
|
||||
// Use standard create method from db/Customers/Create
|
||||
const record = await createCustomer(values);
|
||||
toast.success('Customer created');
|
||||
router.push(paths.dashboard.students.view(record.id));
|
||||
// if (billingAddressId) {
|
||||
// await UpdateBillingAddressById(billingAddressId, values.billingAddress);
|
||||
// }
|
||||
|
||||
const record = await createStudent(tempCreate);
|
||||
toast.success('Student created');
|
||||
// router.push(paths.dashboard.students.view(record.id));
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
toast.error('Failed to create customer');
|
||||
toast.error('Failed to create Student');
|
||||
} finally {
|
||||
setIsUpdating(false);
|
||||
}
|
||||
},
|
||||
[router]
|
||||
@@ -137,7 +171,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
spacing={4}
|
||||
>
|
||||
<Stack spacing={3}>
|
||||
<Typography variant="h6">Account information</Typography>
|
||||
<Typography variant="h6">{t('create.basic-info')}</Typography>
|
||||
<Grid
|
||||
container
|
||||
spacing={3}
|
||||
@@ -151,12 +185,13 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
<Box
|
||||
sx={{
|
||||
border: '1px dashed var(--mui-palette-divider)',
|
||||
borderRadius: '50%',
|
||||
borderRadius: '5%',
|
||||
display: 'inline-flex',
|
||||
p: '4px',
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
variant="rounded"
|
||||
src={avatar}
|
||||
sx={{
|
||||
'--Avatar-size': '100px',
|
||||
@@ -175,8 +210,8 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
spacing={1}
|
||||
sx={{ alignItems: 'flex-start' }}
|
||||
>
|
||||
<Typography variant="subtitle1">Avatar</Typography>
|
||||
<Typography variant="caption">Min 400x400px, PNG or JPEG</Typography>
|
||||
<Typography variant="subtitle1">{t('create.avatar')}</Typography>
|
||||
<Typography variant="caption">{t('create.avatarRequirements')}</Typography>
|
||||
<Button
|
||||
color="secondary"
|
||||
onClick={() => {
|
||||
@@ -184,7 +219,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
}}
|
||||
variant="outlined"
|
||||
>
|
||||
Select
|
||||
{t('create.avatar_select')}
|
||||
</Button>
|
||||
<input
|
||||
hidden
|
||||
@@ -226,7 +261,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
error={Boolean(errors.email)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Email address</InputLabel>
|
||||
<InputLabel required>{t('create.email-address')}</InputLabel>
|
||||
<OutlinedInput
|
||||
{...field}
|
||||
type="email"
|
||||
@@ -248,7 +283,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
error={Boolean(errors.phone)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Phone number</InputLabel>
|
||||
<InputLabel required>{t('create.phone-number')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.phone ? <FormHelperText>{errors.phone.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
@@ -268,7 +303,10 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel>Company</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
<OutlinedInput
|
||||
{...field}
|
||||
placeholder="no company name"
|
||||
/>
|
||||
{errors.company ? <FormHelperText>{errors.company.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
)}
|
||||
@@ -276,8 +314,9 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
{/* */}
|
||||
<Stack spacing={3}>
|
||||
<Typography variant="h6">Billing information</Typography>
|
||||
<Typography variant="h6">{t('create.billing-information')}</Typography>
|
||||
<Grid
|
||||
container
|
||||
spacing={3}
|
||||
@@ -296,10 +335,12 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
>
|
||||
<InputLabel required>Country</InputLabel>
|
||||
<Select {...field}>
|
||||
<Option value="">Choose a country</Option>
|
||||
<Option value="us">United States</Option>
|
||||
<Option value="de">Germany</Option>
|
||||
<Option value="es">Spain</Option>
|
||||
<MenuItem value="">Choose a country</MenuItem>
|
||||
<MenuItem value="US">United States</MenuItem>
|
||||
<MenuItem value="UK">United Kingdom</MenuItem>
|
||||
<MenuItem value="CA">Canada</MenuItem>
|
||||
<MenuItem value="DE">Germany</MenuItem>
|
||||
<MenuItem value="ES">Spain</MenuItem>
|
||||
</Select>
|
||||
{errors.billingAddress?.country ? (
|
||||
<FormHelperText>{errors.billingAddress?.country?.message}</FormHelperText>
|
||||
@@ -362,7 +403,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
error={Boolean(errors.billingAddress?.zipCode)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Zip code</InputLabel>
|
||||
<InputLabel required>{t('create.zip-code')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.billingAddress?.zipCode ? (
|
||||
<FormHelperText>{errors.billingAddress?.zipCode?.message}</FormHelperText>
|
||||
@@ -383,7 +424,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
error={Boolean(errors.billingAddress?.line1)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Address</InputLabel>
|
||||
<InputLabel required>{t('create.address-line-1')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.billingAddress?.line1 ? (
|
||||
<FormHelperText>{errors.billingAddress?.line1?.message}</FormHelperText>
|
||||
@@ -424,7 +465,7 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
/>
|
||||
</Stack>
|
||||
<Stack spacing={3}>
|
||||
<Typography variant="h6">Additional information</Typography>
|
||||
<Typography variant="h6">{t('create.additional-information')}</Typography>
|
||||
<Grid
|
||||
container
|
||||
spacing={3}
|
||||
@@ -443,10 +484,14 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
>
|
||||
<InputLabel required>Timezone</InputLabel>
|
||||
<Select {...field}>
|
||||
<Option value="">Select a timezone</Option>
|
||||
<Option value="new_york">US - New York</Option>
|
||||
<Option value="california">US - California</Option>
|
||||
<Option value="london">UK - London</Option>
|
||||
<MenuItem value="">Select a timezone</MenuItem>
|
||||
<MenuItem value="Europe/London">London</MenuItem>
|
||||
<MenuItem value="Asia/Tokyo">Tokyo</MenuItem>
|
||||
<MenuItem value="America/Boa_Vista">Boa Vista</MenuItem>
|
||||
<MenuItem value="America/Grand_Turk">Grand Turk</MenuItem>
|
||||
<MenuItem value="Asia/Manila">Manila</MenuItem>
|
||||
<MenuItem value="Asia/Urumqi">Urumqi</MenuItem>
|
||||
<MenuItem value="Africa/Tunis">Tunis</MenuItem>
|
||||
</Select>
|
||||
{errors.timezone ? <FormHelperText>{errors.timezone.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
@@ -467,10 +512,11 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
>
|
||||
<InputLabel required>Language</InputLabel>
|
||||
<Select {...field}>
|
||||
<Option value="">Select a language</Option>
|
||||
<Option value="en">English</Option>
|
||||
<Option value="es">Spanish</Option>
|
||||
<Option value="de">German</Option>
|
||||
<MenuItem value="">Select a language</MenuItem>
|
||||
<MenuItem value="en">English</MenuItem>
|
||||
<MenuItem value="es">Spanish</MenuItem>
|
||||
<MenuItem value="de">German</MenuItem>
|
||||
<MenuItem value="fr">French</MenuItem>
|
||||
</Select>
|
||||
{errors.language ? <FormHelperText>{errors.language.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
@@ -489,12 +535,12 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
error={Boolean(errors.currency)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel>Currency</InputLabel>
|
||||
<InputLabel required>{t('create.currency')}</InputLabel>
|
||||
<Select {...field}>
|
||||
<Option value="">Select a currency</Option>
|
||||
<Option value="USD">USD</Option>
|
||||
<Option value="EUR">EUR</Option>
|
||||
<Option value="RON">RON</Option>
|
||||
<MenuItem value="">no currency selected</MenuItem>
|
||||
<MenuItem value="USD">USD</MenuItem>
|
||||
<MenuItem value="EUR">EUR</MenuItem>
|
||||
<MenuItem value="GBP">GBP</MenuItem>
|
||||
</Select>
|
||||
{errors.currency ? <FormHelperText>{errors.currency.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
@@ -511,14 +557,17 @@ export function CustomerCreateForm(): React.JSX.Element {
|
||||
component={RouterLink}
|
||||
href={paths.dashboard.students.list}
|
||||
>
|
||||
Cancel
|
||||
{t('create.cancelButton')}
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
<LoadingButton
|
||||
disabled={isUpdating}
|
||||
loading={isUpdating}
|
||||
type="submit"
|
||||
variant="contained"
|
||||
>
|
||||
Create customer
|
||||
</Button>
|
||||
{t('create.updateButton')}
|
||||
</LoadingButton>
|
||||
</CardActions>
|
||||
</Card>
|
||||
<Box sx={{ display: isDevelopment ? 'block' : 'none' }}>
|
||||
|
@@ -1,10 +1,15 @@
|
||||
'use client';
|
||||
|
||||
// src/components/dashboard/student/student-edit-form.tsx
|
||||
//
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
//
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import { COL_CUSTOMERS, COL_USER_METAS } from '@/constants';
|
||||
import { UpdateBillingAddressById } from '@/db/billingAddress/UpdateById';
|
||||
import { getStudentById } from '@/db/Students/GetById';
|
||||
import { UpdateStudentById } from '@/db/Students/UpdateById';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
//
|
||||
@@ -87,14 +92,15 @@ const defaultValues = {
|
||||
|
||||
export function StudentEditForm(): React.JSX.Element {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { t } = useTranslation(['students']);
|
||||
|
||||
const { customerId } = useParams<{ customerId: string }>();
|
||||
const { id: studentId } = useParams<{ id: string }>();
|
||||
//
|
||||
const [isUpdating, setIsUpdating] = React.useState<boolean>(false);
|
||||
const [showLoading, setShowLoading] = React.useState<boolean>(false);
|
||||
//
|
||||
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
||||
const [billingAddressId, setBillingAddressId] = React.useState<string | null>(null);
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -110,30 +116,38 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
setIsUpdating(true);
|
||||
|
||||
const updateData = {
|
||||
avatar: values.avatar ? await base64ToFile(values.avatar) : null,
|
||||
//
|
||||
name: values.name,
|
||||
email: values.email,
|
||||
phone: values.phone,
|
||||
company: values.company,
|
||||
billingAddress: values.billingAddress,
|
||||
taxId: values.taxId,
|
||||
//
|
||||
// billingAddress: values.billingAddress,
|
||||
//
|
||||
timezone: values.timezone,
|
||||
language: values.language,
|
||||
currency: values.currency,
|
||||
avatar: values.avatar ? await base64ToFile(values.avatar) : null,
|
||||
taxId: values.taxId,
|
||||
};
|
||||
|
||||
try {
|
||||
await pb.collection(COL_CUSTOMERS).update(customerId, updateData);
|
||||
toast.success('Customer updated successfully');
|
||||
// await pb.collection(COL_USER_METAS).update(studentId, updateData);
|
||||
await UpdateStudentById(studentId, updateData);
|
||||
toast.success('Student updated successfully');
|
||||
router.push(paths.dashboard.students.list);
|
||||
|
||||
if (billingAddressId) {
|
||||
await UpdateBillingAddressById(billingAddressId, values.billingAddress);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
toast.error('Failed to update customer');
|
||||
toast.error('Failed to update student');
|
||||
} finally {
|
||||
setIsUpdating(false);
|
||||
}
|
||||
},
|
||||
[customerId, router]
|
||||
[studentId, router]
|
||||
);
|
||||
|
||||
const avatarInputRef = React.useRef<HTMLInputElement>(null);
|
||||
@@ -162,13 +176,14 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
setShowLoading(true);
|
||||
|
||||
try {
|
||||
const result = await pb.collection(COL_CUSTOMERS).getOne(id);
|
||||
const result = await getStudentById(id);
|
||||
reset({ ...defaultValues, ...result });
|
||||
console.log({ result });
|
||||
|
||||
if (result.avatar_file) {
|
||||
setBillingAddressId(result.billingAddress.id);
|
||||
|
||||
if (result.avatar) {
|
||||
const fetchResult = await fetch(
|
||||
`http://127.0.0.1:8090/api/files/${result.collectionId}/${result.id}/${result.avatar_file}`
|
||||
`http://127.0.0.1:8090/api/files/${result.collectionId}/${result.id}/${result.avatar}`
|
||||
);
|
||||
const blob = await fetchResult.blob();
|
||||
const url = await fileToBase64(blob);
|
||||
@@ -176,7 +191,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
toast.error('Failed to load customer data');
|
||||
toast.error('Failed to load student data');
|
||||
setShowError({ show: true, detail: JSON.stringify(error, null, 2) });
|
||||
} finally {
|
||||
setShowLoading(false);
|
||||
@@ -186,9 +201,9 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
void loadExistingData(customerId);
|
||||
void loadExistingData(studentId);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [customerId]);
|
||||
}, [studentId]);
|
||||
|
||||
if (showLoading) return <FormLoading />;
|
||||
if (showError.show)
|
||||
@@ -299,7 +314,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
error={Boolean(errors.email)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Email</InputLabel>
|
||||
<InputLabel required>{t('edit.email-address')}</InputLabel>
|
||||
<OutlinedInput
|
||||
{...field}
|
||||
type="email"
|
||||
@@ -321,7 +336,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
error={Boolean(errors.phone)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Phone</InputLabel>
|
||||
<InputLabel required>{t('edit.phone-number')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.phone ? <FormHelperText>{errors.phone.message}</FormHelperText> : null}
|
||||
</FormControl>
|
||||
@@ -354,7 +369,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
</Stack>
|
||||
{/* */}
|
||||
<Stack spacing={3}>
|
||||
<Typography variant="h6">Billing Information</Typography>
|
||||
<Typography variant="h6">{t('edit.billing-information')}</Typography>
|
||||
<Grid
|
||||
container
|
||||
spacing={3}
|
||||
@@ -373,9 +388,12 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
>
|
||||
<InputLabel required>Country</InputLabel>
|
||||
<Select {...field}>
|
||||
<MenuItem value="">No Country selected</MenuItem>
|
||||
<MenuItem value="US">United States</MenuItem>
|
||||
<MenuItem value="UK">United Kingdom</MenuItem>
|
||||
<MenuItem value="CA">Canada</MenuItem>
|
||||
<MenuItem value="DE">Germany</MenuItem>
|
||||
<MenuItem value="ES">Spain</MenuItem>
|
||||
</Select>
|
||||
{errors.billingAddress?.country ? (
|
||||
<FormHelperText>{errors.billingAddress.country.message}</FormHelperText>
|
||||
@@ -438,7 +456,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
error={Boolean(errors.billingAddress?.zipCode)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Zip Code</InputLabel>
|
||||
<InputLabel required>{t('edit.zip-code')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.billingAddress?.zipCode ? (
|
||||
<FormHelperText>{errors.billingAddress.zipCode.message}</FormHelperText>
|
||||
@@ -459,7 +477,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
error={Boolean(errors.billingAddress?.line1)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Address Line 1</InputLabel>
|
||||
<InputLabel required>{t('edit.address-line-1')}</InputLabel>
|
||||
<OutlinedInput {...field} />
|
||||
{errors.billingAddress?.line1 ? (
|
||||
<FormHelperText>{errors.billingAddress.line1.message}</FormHelperText>
|
||||
@@ -494,7 +512,7 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={3}>
|
||||
<Typography variant="h6">Additional Information</Typography>
|
||||
<Typography variant="h6">{t('edit.additional-information')}</Typography>
|
||||
<Grid
|
||||
container
|
||||
spacing={3}
|
||||
@@ -541,8 +559,10 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
>
|
||||
<InputLabel required>Language</InputLabel>
|
||||
<Select {...field}>
|
||||
<MenuItem value="">no language selected</MenuItem>
|
||||
<MenuItem value="en">English</MenuItem>
|
||||
<MenuItem value="es">Spanish</MenuItem>
|
||||
<MenuItem value="de">German</MenuItem>
|
||||
<MenuItem value="fr">French</MenuItem>
|
||||
</Select>
|
||||
{errors.language ? <FormHelperText>{errors.language.message}</FormHelperText> : null}
|
||||
@@ -562,8 +582,9 @@ export function StudentEditForm(): React.JSX.Element {
|
||||
error={Boolean(errors.currency)}
|
||||
fullWidth
|
||||
>
|
||||
<InputLabel required>Currency</InputLabel>
|
||||
<InputLabel required>{t('edit.currency')}</InputLabel>
|
||||
<Select {...field}>
|
||||
<MenuItem value="">no currency selected</MenuItem>
|
||||
<MenuItem value="USD">USD</MenuItem>
|
||||
<MenuItem value="EUR">EUR</MenuItem>
|
||||
<MenuItem value="GBP">GBP</MenuItem>
|
||||
|
@@ -23,21 +23,23 @@ export interface CreateFormProps {
|
||||
email: string;
|
||||
phone?: string;
|
||||
company?: string;
|
||||
billingAddress?: {
|
||||
country: string;
|
||||
state: string;
|
||||
city: string;
|
||||
zipCode: string;
|
||||
line1: string;
|
||||
line2?: string;
|
||||
};
|
||||
// handle seperately
|
||||
// billingAddress?: {
|
||||
// country: string;
|
||||
// state: string;
|
||||
// city: string;
|
||||
// zipCode: string;
|
||||
// line1: string;
|
||||
// line2?: string;
|
||||
// };
|
||||
taxId?: string;
|
||||
timezone: string;
|
||||
language: string;
|
||||
currency: string;
|
||||
avatar?: string;
|
||||
avatar?: File | null;
|
||||
// quota?: number;
|
||||
// status?: 'pending' | 'active' | 'blocked';
|
||||
state?: 'pending' | 'active' | 'blocked';
|
||||
meta: Record<string, null>;
|
||||
}
|
||||
|
||||
// RULES: form data structure for editing existing student
|
||||
|
@@ -1,10 +1,12 @@
|
||||
'use client';
|
||||
|
||||
// src/components/dashboard/teacher/teacher-edit-form.tsx
|
||||
//
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
//
|
||||
import { COL_TEACHERS, COL_USER_METAS } from '@/constants';
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
//
|
||||
@@ -32,6 +34,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { z as zod } from 'zod';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { base64ToFile, fileToBase64 } from '@/lib/file-to-base64';
|
||||
import { pb } from '@/lib/pb';
|
||||
@@ -40,7 +43,6 @@ import FormLoading from '@/components/loading';
|
||||
|
||||
// import ErrorDisplay from '../../error';
|
||||
import ErrorDisplay from '../error';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
|
||||
// TODO: review this
|
||||
const schema = zod.object({
|
||||
|
@@ -32,6 +32,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { z as zod } from 'zod';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { base64ToFile, fileToBase64 } from '@/lib/file-to-base64';
|
||||
import { pb } from '@/lib/pb';
|
||||
@@ -40,7 +41,6 @@ import FormLoading from '@/components/loading';
|
||||
|
||||
// import ErrorDisplay from '../../error';
|
||||
import ErrorDisplay from '../error';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
|
||||
// TODO: review this
|
||||
const schema = zod.object({
|
||||
|
@@ -1,8 +1,55 @@
|
||||
'use client';
|
||||
|
||||
import type { BillingAddress } from '@/db/billingAddress/type';
|
||||
|
||||
// RULES: sorting direction for teacher lists
|
||||
export type SortDir = 'asc' | 'desc';
|
||||
|
||||
// obsoleted
|
||||
// export interface BillingAddress {
|
||||
// city: string;
|
||||
// country: string;
|
||||
// line1: string;
|
||||
// line2: string;
|
||||
// state: string;
|
||||
// zipCode: string;
|
||||
// //
|
||||
// id: string;
|
||||
// collectionId: string;
|
||||
// collectionName: string;
|
||||
// updated: string;
|
||||
// created: string;
|
||||
// }
|
||||
|
||||
export interface DBUserMeta {
|
||||
name: string;
|
||||
//
|
||||
// NOTE: obslete "avatar" and use "avatar_file"
|
||||
avatar?: string;
|
||||
avatar_file?: string;
|
||||
//
|
||||
email: string;
|
||||
phone: string;
|
||||
quota: number;
|
||||
company: string;
|
||||
//
|
||||
// billingAddress: BillingAddress[] | [];
|
||||
expand: { billingAddress?: BillingAddress[] };
|
||||
|
||||
// status is obsoleted, replace by state
|
||||
status: 'pending' | 'active' | 'blocked';
|
||||
state: 'pending' | 'active' | 'blocked';
|
||||
//
|
||||
timezone: string;
|
||||
language: string;
|
||||
currency: string;
|
||||
//
|
||||
id: string;
|
||||
created: string;
|
||||
updated?: string;
|
||||
collectionId: string;
|
||||
}
|
||||
|
||||
// RULES: core teacher data structure
|
||||
export interface UserMeta {
|
||||
name: string;
|
||||
@@ -14,10 +61,18 @@ export interface UserMeta {
|
||||
email: string;
|
||||
phone?: string;
|
||||
quota: number;
|
||||
company?: string;
|
||||
//
|
||||
billingAddress: BillingAddress | Record<string, never>;
|
||||
|
||||
// status is obsoleted, replace by state
|
||||
status: 'pending' | 'active' | 'blocked';
|
||||
state: 'pending' | 'active' | 'blocked';
|
||||
//
|
||||
timezone: string;
|
||||
language: string;
|
||||
currency: string;
|
||||
|
||||
//
|
||||
id: string;
|
||||
createdAt: Date;
|
||||
|
@@ -1,10 +1,15 @@
|
||||
'use client';
|
||||
|
||||
// src/components/dashboard/user_meta/user-meta-edit-form.tsx
|
||||
//
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
//
|
||||
import { COL_TEACHERS, COL_USER_METAS } from '@/constants';
|
||||
import { COL_CUSTOMERS, COL_USER_METAS } from '@/constants';
|
||||
import { UpdateBillingAddressById } from '@/db/billingAddress/UpdateById';
|
||||
import { getUserMetaById } from '@/db/UserMetas/GetById';
|
||||
import { UpdateUserMetaById } from '@/db/UserMetas/UpdateById';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
//
|
||||
@@ -32,6 +37,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { z as zod } from 'zod';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { base64ToFile, fileToBase64 } from '@/lib/file-to-base64';
|
||||
import { pb } from '@/lib/pb';
|
||||
@@ -40,7 +46,6 @@ import FormLoading from '@/components/loading';
|
||||
|
||||
// import ErrorDisplay from '../../error';
|
||||
import ErrorDisplay from '../error';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
|
||||
// TODO: review this
|
||||
const schema = zod.object({
|
||||
@@ -89,7 +94,7 @@ export function UserMetaEditForm(): React.JSX.Element {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
|
||||
const { id: teacherId } = useParams<{ id: string }>();
|
||||
const { id: userMetaId } = useParams<{ id: string }>();
|
||||
//
|
||||
const [isUpdating, setIsUpdating] = React.useState<boolean>(false);
|
||||
const [showLoading, setShowLoading] = React.useState<boolean>(false);
|
||||
@@ -123,7 +128,7 @@ export function UserMetaEditForm(): React.JSX.Element {
|
||||
};
|
||||
|
||||
try {
|
||||
await pb.collection(COL_USER_METAS).update(teacherId, updateData);
|
||||
await pb.collection(COL_USER_METAS).update(userMetaId, updateData);
|
||||
toast.success('Teacher updated successfully');
|
||||
router.push(paths.dashboard.teachers.list);
|
||||
} catch (error) {
|
||||
@@ -133,7 +138,7 @@ export function UserMetaEditForm(): React.JSX.Element {
|
||||
setIsUpdating(false);
|
||||
}
|
||||
},
|
||||
[teacherId, router]
|
||||
[userMetaId, router]
|
||||
);
|
||||
|
||||
const avatarInputRef = React.useRef<HTMLInputElement>(null);
|
||||
@@ -186,9 +191,9 @@ export function UserMetaEditForm(): React.JSX.Element {
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
void loadExistingData(teacherId);
|
||||
void loadExistingData(userMetaId);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [teacherId]);
|
||||
}, [userMetaId]);
|
||||
|
||||
if (showLoading) return <FormLoading />;
|
||||
if (showError.show)
|
||||
|
@@ -5,6 +5,7 @@ const COL_LESSON_TYPES = 'LessonsTypes';
|
||||
const COL_LESSON_CATEGORIES = 'LessonsCategories';
|
||||
const COL_USERS = 'users';
|
||||
const COL_USER_METAS = 'UserMetas';
|
||||
const COL_BILLING_ADDRESS = 'billingAddress';
|
||||
|
||||
// RULES:
|
||||
// do not use LP_CATEGORIES anymore
|
||||
@@ -56,4 +57,5 @@ export {
|
||||
COL_VOCABULARIES,
|
||||
NS_VOCABULARY,
|
||||
//
|
||||
COL_BILLING_ADDRESS,
|
||||
};
|
||||
|
@@ -1,11 +1,12 @@
|
||||
// api method for crate student record
|
||||
// RULES:
|
||||
// TBA
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_STUDENTS } from '@/constants';
|
||||
import type { CreateFormProps } from '@/components/dashboard/student/type.d';
|
||||
import { COL_STUDENTS, COL_USER_METAS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/student/type.d';
|
||||
|
||||
export async function createStudent(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_STUDENTS).create(data);
|
||||
return pb.collection(COL_USER_METAS).create(data);
|
||||
}
|
||||
|
@@ -1,7 +1,28 @@
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_STUDENTS } from '@/constants';
|
||||
import { RecordModel } from 'pocketbase';
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
|
||||
export async function getStudentById(id: string): Promise<RecordModel> {
|
||||
return pb.collection(COL_STUDENTS).getOne(id);
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { DBUserMeta, UserMeta } from '@/components/dashboard/user_meta/type.d';
|
||||
|
||||
export async function getStudentById(id: string): Promise<UserMeta> {
|
||||
const record = await pb.collection(COL_USER_METAS).getOne<DBUserMeta>(id, { expand: 'billingAddress, helloworld' });
|
||||
|
||||
const temp: UserMeta = {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
email: record.email,
|
||||
quota: record.quota,
|
||||
billingAddress: record.expand.billingAddress ? record.expand.billingAddress[0] : {},
|
||||
status: record.status,
|
||||
state: record.state,
|
||||
createdAt: new Date(record.created),
|
||||
collectionId: record.collectionId,
|
||||
avatar: record.avatar,
|
||||
phone: record.phone,
|
||||
company: record.company,
|
||||
timezone: record.timezone,
|
||||
language: record.language,
|
||||
currency: record.currency,
|
||||
};
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
10
002_source/cms/src/db/Students/UpdateById.tsx
Normal file
10
002_source/cms/src/db/Students/UpdateById.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
import type { UpdateStudent } from './type';
|
||||
|
||||
export async function UpdateStudentById(id: string, data: Partial<UpdateStudent>): Promise<RecordModel> {
|
||||
return pb.collection(COL_USER_METAS).update(id, data);
|
||||
}
|
28
002_source/cms/src/db/Students/type.d.ts
vendored
28
002_source/cms/src/db/Students/type.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
import type { BillingAddress } from '@/components/dashboard/user_meta/type.d';
|
||||
|
||||
// Student type definitions
|
||||
export interface Student {
|
||||
id: string;
|
||||
@@ -9,3 +11,29 @@ export interface Student {
|
||||
status: 'active' | 'blocked' | 'pending';
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface UpdateStudent {
|
||||
name?: string;
|
||||
//
|
||||
// NOTE: obslete "avatar" and use "avatar_file"
|
||||
// avatar_file?: string;
|
||||
avatar: File | null;
|
||||
//
|
||||
email?: string;
|
||||
phone?: string;
|
||||
quota?: number;
|
||||
company?: string;
|
||||
//
|
||||
// relation handle seperately
|
||||
// billingAddress: BillingAddress | Record<string, never>;
|
||||
|
||||
// status is obsoleted, replace by state
|
||||
// status: 'pending' | 'active' | 'blocked';
|
||||
state?: 'pending' | 'active' | 'blocked';
|
||||
//
|
||||
timezone?: string;
|
||||
language?: string;
|
||||
currency?: string;
|
||||
//
|
||||
taxId?: string;
|
||||
}
|
||||
|
10
002_source/cms/src/db/UserMetas/UpdateById.tsx
Normal file
10
002_source/cms/src/db/UserMetas/UpdateById.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
import type { UpdateUserMeta } from './type';
|
||||
|
||||
export async function UpdateUserMetaById(id: string, data: Partial<UpdateUserMeta>): Promise<RecordModel> {
|
||||
return pb.collection(COL_USER_METAS).update(id, data);
|
||||
}
|
39
002_source/cms/src/db/UserMetas/type.d.ts
vendored
Normal file
39
002_source/cms/src/db/UserMetas/type.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { BillingAddress } from '@/components/dashboard/user_meta/type.d';
|
||||
|
||||
// UserMeta type definitions
|
||||
export interface UserMeta {
|
||||
id: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
quota: number;
|
||||
status: 'active' | 'blocked' | 'pending';
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface UpdateUserMeta {
|
||||
name?: string;
|
||||
//
|
||||
// NOTE: obslete "avatar" and use "avatar_file"
|
||||
// avatar_file?: string;
|
||||
avatar: File | null;
|
||||
//
|
||||
email?: string;
|
||||
phone?: string;
|
||||
quota?: number;
|
||||
company?: string;
|
||||
//
|
||||
// relation handle seperately
|
||||
// billingAddress: BillingAddress | Record<string, never>;
|
||||
|
||||
// status is obsoleted, replace by state
|
||||
// status: 'pending' | 'active' | 'blocked';
|
||||
state?: 'pending' | 'active' | 'blocked';
|
||||
//
|
||||
timezone?: string;
|
||||
language?: string;
|
||||
currency?: string;
|
||||
//
|
||||
taxId?: string;
|
||||
}
|
11
002_source/cms/src/db/billingAddress/Create.tsx
Normal file
11
002_source/cms/src/db/billingAddress/Create.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
// api method for crate student record
|
||||
// RULES:
|
||||
// TBA
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_STUDENTS } from '@/constants';
|
||||
import type { CreateFormProps } from '@/components/dashboard/student/type.d';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
export async function createStudent(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_STUDENTS).create(data);
|
||||
}
|
6
002_source/cms/src/db/billingAddress/Delete.tsx
Normal file
6
002_source/cms/src/db/billingAddress/Delete.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_STUDENTS, COL_USER_METAS } from '@/constants';
|
||||
|
||||
export async function deleteStudent(id: string): Promise<boolean> {
|
||||
return pb.collection(COL_USER_METAS).delete(id);
|
||||
}
|
9
002_source/cms/src/db/billingAddress/GetActiveCount.tsx
Normal file
9
002_source/cms/src/db/billingAddress/GetActiveCount.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { COL_STUDENTS, COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetActiveCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: 'status = "active" && role = "student"',
|
||||
});
|
||||
return count;
|
||||
}
|
7
002_source/cms/src/db/billingAddress/GetAll.tsx
Normal file
7
002_source/cms/src/db/billingAddress/GetAll.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_STUDENTS } from '@/constants';
|
||||
import { RecordModel } from 'pocketbase';
|
||||
|
||||
export async function getAllStudents(options = {}): Promise<RecordModel[]> {
|
||||
return pb.collection(COL_STUDENTS).getFullList(options);
|
||||
}
|
10
002_source/cms/src/db/billingAddress/GetAllCount.tsx
Normal file
10
002_source/cms/src/db/billingAddress/GetAllCount.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
|
||||
export async function getAllStudentsCount(): Promise<number> {
|
||||
const result = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: `role = "student"`,
|
||||
//
|
||||
});
|
||||
return result.totalItems;
|
||||
}
|
9
002_source/cms/src/db/billingAddress/GetBlockedCount.tsx
Normal file
9
002_source/cms/src/db/billingAddress/GetBlockedCount.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetBlockedCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: 'status = "blocked" && role = "student"',
|
||||
});
|
||||
return count;
|
||||
}
|
34
002_source/cms/src/db/billingAddress/GetById.tsx
Normal file
34
002_source/cms/src/db/billingAddress/GetById.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { COL_BILLING_ADDRESS, COL_STUDENTS, COL_USER_METAS } from '@/constants';
|
||||
import { RecordModel } from 'pocketbase';
|
||||
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { DBUserMeta, UserMeta } from '@/components/dashboard/user_meta/type.d';
|
||||
|
||||
export async function getBillingAddressById(id: string): Promise<UserMeta> {
|
||||
const record = await pb
|
||||
.collection(COL_BILLING_ADDRESS)
|
||||
.getOne<DBUserMeta>(id, { expand: 'billingAddress, helloworld' });
|
||||
|
||||
console.log({ record });
|
||||
|
||||
const temp: UserMeta = {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
email: record.email,
|
||||
quota: record.quota,
|
||||
billingAddress: record.expand.billingAddress ? record.expand.billingAddress[0] : {},
|
||||
status: record.status,
|
||||
state: record.state,
|
||||
createdAt: new Date(record.created),
|
||||
collectionId: record.collectionId,
|
||||
avatar: record.avatar,
|
||||
phone: record.phone,
|
||||
company: record.company,
|
||||
timezone: record.timezone,
|
||||
language: record.language,
|
||||
currency: record.currency,
|
||||
};
|
||||
|
||||
return temp;
|
||||
}
|
9
002_source/cms/src/db/billingAddress/GetPendingCount.tsx
Normal file
9
002_source/cms/src/db/billingAddress/GetPendingCount.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetPendingCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: 'status = "pending" && role = "student"',
|
||||
});
|
||||
return count;
|
||||
}
|
3
002_source/cms/src/db/billingAddress/Helloworld.tsx
Normal file
3
002_source/cms/src/db/billingAddress/Helloworld.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
export function helloCustomer() {
|
||||
return 'Hello from Customers module!';
|
||||
}
|
8
002_source/cms/src/db/billingAddress/Update.tsx
Normal file
8
002_source/cms/src/db/billingAddress/Update.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
import type { EditFormProps } from '@/components/dashboard/customer/type.d';
|
||||
|
||||
export async function updateCustomer(id: string, data: Partial<EditFormProps>): Promise<RecordModel> {
|
||||
return pb.collection(COL_CUSTOMERS).update(id, data);
|
||||
}
|
10
002_source/cms/src/db/billingAddress/UpdateById.tsx
Normal file
10
002_source/cms/src/db/billingAddress/UpdateById.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { COL_BILLING_ADDRESS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
import type { UpdateBillingAddress } from './type';
|
||||
|
||||
export async function UpdateBillingAddressById(id: string, data: Partial<UpdateBillingAddress>): Promise<RecordModel> {
|
||||
return pb.collection(COL_BILLING_ADDRESS).update(id, data);
|
||||
}
|
31
002_source/cms/src/db/billingAddress/_GUIDELINES.md
Normal file
31
002_source/cms/src/db/billingAddress/_GUIDELINES.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `Customer`/`Customers` records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
- write (Update.tsx)
|
||||
- count (GetAllCount.tsx, GetActiveCount.tsx, GetBlockedCount.tsx, GetPendingCount.tsx)
|
||||
- misc (Helloworld.tsx)
|
||||
- delete (Delete.tsx)
|
||||
- list (GetAll.tsx)
|
||||
|
||||
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||
|
||||
## Assumption and Requirements
|
||||
|
||||
- assume `pb` is located in `@/lib/pb`
|
||||
- no need to handle error in this function, i'll handle it in the caller
|
||||
- type information defined in `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/Customers/type.d.tsx`
|
||||
|
||||
simple template:
|
||||
|
||||
```typescript
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
|
||||
export async function createCustomer(data: CreateFormProps) {
|
||||
// ...content
|
||||
// use direct return of pb.collection (e.g. return pb.collection(xxx))
|
||||
}
|
||||
```
|
23
002_source/cms/src/db/billingAddress/type.d.ts
vendored
Normal file
23
002_source/cms/src/db/billingAddress/type.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export interface BillingAddress {
|
||||
city: string;
|
||||
country: string;
|
||||
line1: string;
|
||||
line2: string;
|
||||
state: string;
|
||||
zipCode: string;
|
||||
//
|
||||
id: string;
|
||||
collectionId: string;
|
||||
collectionName: string;
|
||||
updated: string;
|
||||
created: string;
|
||||
}
|
||||
|
||||
export interface UpdateBillingAddress {
|
||||
city?: string;
|
||||
country?: string;
|
||||
line1?: string;
|
||||
line2?: string;
|
||||
state?: string;
|
||||
zipCode?: string;
|
||||
}
|
14
002_source/docker/.env
Normal file
14
002_source/docker/.env
Normal file
@@ -0,0 +1,14 @@
|
||||
# THIS IS env file for use with docker-compose.yml
|
||||
|
||||
# cms
|
||||
|
||||
# doc
|
||||
|
||||
# ionic_mobile
|
||||
|
||||
# api_ts
|
||||
|
||||
# pocketbase
|
||||
PB_HOSTNAME=pocketbase
|
||||
PB_USERNAME=admin@123.com
|
||||
PB_PASSWORD=Aa12345678
|
35
002_source/docker/docker-compose.db.yml
Normal file
35
002_source/docker/docker-compose.db.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
volumes:
|
||||
shared:
|
||||
dist:
|
||||
|
||||
services:
|
||||
pocketbase:
|
||||
# image: ghcr.io/muchobien/pocketbase:latest
|
||||
build:
|
||||
context: ./pocketbase/docker
|
||||
args:
|
||||
- VERSION=0.26.6 # Specify the PocketBase version here
|
||||
# hostname: pocketbase
|
||||
restart: always
|
||||
# environment:
|
||||
# ENCRYPTION: example #optional
|
||||
ports:
|
||||
- 8090:8090
|
||||
volumes:
|
||||
- ./volumes/pocketbase/pb_data:/pb_data
|
||||
#
|
||||
- ../pocketbase/pb_migrations:/pb_migrations
|
||||
- ../pocketbase/pb_hooks:/pb_hooks
|
||||
# healthcheck:
|
||||
# #optional (recommended) since v0.10.0
|
||||
# test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||
# interval: 5s
|
||||
# timeout: 5s
|
||||
# retries: 5
|
||||
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: 0.5
|
||||
reservations:
|
||||
cpus: 0.01
|
@@ -6,7 +6,7 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1"
|
||||
cpus: '1'
|
||||
|
||||
doc:
|
||||
environment:
|
||||
@@ -14,7 +14,7 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1"
|
||||
cpus: '1'
|
||||
|
||||
ionic_mobile:
|
||||
environment:
|
||||
@@ -22,7 +22,7 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1"
|
||||
cpus: '1'
|
||||
|
||||
api_ts:
|
||||
environment:
|
||||
@@ -30,4 +30,4 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1"
|
||||
cpus: '1'
|
@@ -26,9 +26,9 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
cpus: "0.01"
|
||||
cpus: '0.01'
|
||||
|
||||
doc:
|
||||
build: ./doc
|
||||
@@ -50,9 +50,9 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
cpus: "0.01"
|
||||
cpus: '0.01'
|
||||
|
||||
ionic_mobile:
|
||||
# image: node:20-bullseye-slim
|
||||
@@ -80,15 +80,16 @@ services:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
cpus: "0.01"
|
||||
cpus: '0.01'
|
||||
|
||||
api_ts:
|
||||
# TODO: review this config, the api_ts volumes should be place inside 002_source/docker/volumes
|
||||
image: 192.168.10.61:5000/api_ts_ubuntu
|
||||
# build: ./api_ts
|
||||
volumes:
|
||||
- ./api_ts:/app
|
||||
- ../api_ts:/app
|
||||
working_dir: /app
|
||||
# env_file:
|
||||
# - .env
|
||||
@@ -117,33 +118,3 @@ services:
|
||||
cpus: 0.5
|
||||
reservations:
|
||||
cpus: 0.01
|
||||
|
||||
pocketbase:
|
||||
# image: ghcr.io/muchobien/pocketbase:latest
|
||||
build:
|
||||
context: ./pocketbase/docker
|
||||
args:
|
||||
- VERSION=0.26.6 # Specify the PocketBase version here
|
||||
# hostname: pocketbase
|
||||
restart: always
|
||||
# environment:
|
||||
# ENCRYPTION: example #optional
|
||||
ports:
|
||||
- 8090:8090
|
||||
volumes:
|
||||
- ./pocketbase/volumes/pb_data:/pb_data
|
||||
- ./pocketbase/pb_hooks:/pb_hooks
|
||||
- ./pocketbase/pb_migrations:/pb_migrations
|
||||
# healthcheck:
|
||||
# #optional (recommended) since v0.10.0
|
||||
# test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||
# interval: 5s
|
||||
# timeout: 5s
|
||||
# retries: 5
|
||||
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: 0.5
|
||||
reservations:
|
||||
cpus: 0.01
|
1
002_source/ionic_mobile/.gitignore
vendored
1
002_source/ionic_mobile/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.env
|
||||
**/*.log
|
||||
**/*.del
|
||||
**/*.bak
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"endOfLine": "lf",
|
||||
"printWidth": 120,
|
||||
"quoteProps": "consistent",
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 120,
|
||||
"quoteProps": "consistent",
|
||||
"plugins": []
|
||||
}
|
||||
|
3
002_source/ionic_mobile/TODO.md
Normal file
3
002_source/ionic_mobile/TODO.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# TODO
|
||||
|
||||
- [ ] add login mechanism
|
@@ -1,8 +1,8 @@
|
||||
import { defineConfig } from "cypress";
|
||||
import { defineConfig } from 'cypress';
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: "http://localhost:5173",
|
||||
baseUrl: 'http://localhost:5173',
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"watch": ["src"],
|
||||
"watch": [
|
||||
"src"
|
||||
],
|
||||
"ext": "ts,tsx",
|
||||
"exec": "npm run bulid"
|
||||
}
|
||||
|
391
002_source/ionic_mobile/package-lock.json
generated
391
002_source/ionic_mobile/package-lock.json
generated
@@ -58,6 +58,7 @@
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-organize-imports": "^4.1.0",
|
||||
"prettier-plugin-unused-imports-configurable": "^1.14.2",
|
||||
"sass": "^1.88.0",
|
||||
"terser": "^5.4.0",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "~5.2.0",
|
||||
@@ -2780,6 +2781,338 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz",
|
||||
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"detect-libc": "^1.0.3",
|
||||
"is-glob": "^4.0.3",
|
||||
"micromatch": "^4.0.5",
|
||||
"node-addon-api": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@parcel/watcher-android-arm64": "2.5.1",
|
||||
"@parcel/watcher-darwin-arm64": "2.5.1",
|
||||
"@parcel/watcher-darwin-x64": "2.5.1",
|
||||
"@parcel/watcher-freebsd-x64": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
||||
"@parcel/watcher-win32-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-ia32": "2.5.1",
|
||||
"@parcel/watcher-win32-x64": "2.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-android-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-freebsd-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-ia32": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz",
|
||||
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher/node_modules/detect-libc": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
|
||||
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"detect-libc": "bin/detect-libc.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher/node_modules/node-addon-api": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
|
||||
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@prettier/plugin-xml": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-2.2.0.tgz",
|
||||
@@ -4837,6 +5170,22 @@
|
||||
"regexp-to-ast": "0.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/chokidar": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
||||
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"readdirp": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.16.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/chownr": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
|
||||
@@ -8899,6 +9248,13 @@
|
||||
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/immutable": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.2.tgz",
|
||||
"integrity": "sha512-qHKXW1q6liAk1Oys6umoaZbDRqjcjgSrbnrifHsfsttza7zcvRAsL7mMV6xWcyhwQy7Xj5v4hhbr6b+iDYwlmQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
|
||||
@@ -13085,6 +13441,20 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/readdirp": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 14.18.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/redent": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz",
|
||||
@@ -13886,6 +14256,27 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.88.0",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.88.0.tgz",
|
||||
"integrity": "sha512-sF6TWQqjFvr4JILXzG4ucGOLELkESHL+I5QJhh7CNaE+Yge0SI+ehCatsXhJ7ymU1hAFcIS3/PBpjdIbXoyVbg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chokidar": "^4.0.0",
|
||||
"immutable": "^5.0.2",
|
||||
"source-map-js": ">=0.6.2 <2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"sass": "sass.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@parcel/watcher": "^2.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz",
|
||||
|
@@ -36,11 +36,14 @@
|
||||
"@ionic/react-router": "^8.0.0",
|
||||
"@ionic/storage": "^4.0.0",
|
||||
"@lifeomic/attempt": "^3.1.0",
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@tanstack/react-query-devtools": "^5.74.6",
|
||||
"@types/react-router": "^5.1.20",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"axios": "^1.8.1",
|
||||
"i18next": "^24.2.2",
|
||||
"ionicons": "^7.0.0",
|
||||
"pocketbase": "^0.26.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-i18next": "^15.4.1",
|
||||
@@ -49,10 +52,7 @@
|
||||
"react-router-dom": "^5.3.4",
|
||||
"react-use": "^17.6.0",
|
||||
"react-use-audio-player": "^2.3.0-alpha.1",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@tanstack/react-query-devtools": "^5.74.6",
|
||||
"pocketbase": "^0.26.0"
|
||||
"remark-gfm": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@capacitor/assets": "^3.0.5",
|
||||
@@ -73,6 +73,7 @@
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-plugin-organize-imports": "^4.1.0",
|
||||
"prettier-plugin-unused-imports-configurable": "^1.14.2",
|
||||
"sass": "^1.88.0",
|
||||
"terser": "^5.4.0",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "~5.2.0",
|
||||
|
BIN
002_source/ionic_mobile/public/assets/login2.jpeg
Normal file
BIN
002_source/ionic_mobile/public/assets/login2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 296 KiB |
5
002_source/ionic_mobile/scripts/004_dev.sh
Executable file
5
002_source/ionic_mobile/scripts/004_dev.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
npm run dev
|
8
002_source/ionic_mobile/scripts/010_rsync_backup.sh
Executable file
8
002_source/ionic_mobile/scripts/010_rsync_backup.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
rsync -avh --exclude="node_modules" ../ionic_mobile/ \
|
||||
../_archive/ionic_mobile_draft_012
|
||||
|
||||
echo "done"
|
8
002_source/ionic_mobile/scripts/999_express_commit.sh
Executable file
8
002_source/ionic_mobile/scripts/999_express_commit.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
git add src
|
||||
git commit -m'update,'
|
||||
|
||||
echo "done"
|
@@ -21,6 +21,10 @@ import ConnectivesWordPage from './pages/Favorite/ConnectivesWordPage';
|
||||
import FavVocabularyPage from './pages/Favorite/Vocabulary';
|
||||
import FavoriteVocabularyPage from './pages/Favorite/WordPage';
|
||||
import ConnectivesPage from './pages/Lesson/ConnectivesPage';
|
||||
import AuthHome from './pages/auth/Home';
|
||||
import { AuthLogin } from './pages/auth/Login';
|
||||
import { AuthSignUp } from './pages/auth/SignUp';
|
||||
|
||||
import Lesson from './pages/Lesson/index';
|
||||
|
||||
// NOTES: old version using json file
|
||||
@@ -88,6 +92,7 @@ function RouteConfig() {
|
||||
<ListeningPractice />
|
||||
</Route>
|
||||
|
||||
{/* http://localhost:5173/connective_revision/r/000000000000001 */}
|
||||
<Route exact path={`${CONNECTIVE_REVISION_LINK}/r/:p_route`}>
|
||||
<ConnectiveRevisionQuizRun />
|
||||
</Route>
|
||||
@@ -96,6 +101,7 @@ function RouteConfig() {
|
||||
<ConnectiveRevisionQuizResult />
|
||||
</Route>
|
||||
|
||||
{/* http://localhost:5173/connective_revision */}
|
||||
<Route exact path={CONNECTIVE_REVISION_LINK}>
|
||||
<ConnectiveRevisionSelectCategory />
|
||||
</Route>
|
||||
@@ -154,6 +160,18 @@ function RouteConfig() {
|
||||
<ConnectivesPage />
|
||||
</Route>
|
||||
|
||||
<Route exact path={`/auth/Home`}>
|
||||
<AuthHome />
|
||||
</Route>
|
||||
|
||||
<Route exact path={`/auth/login`}>
|
||||
<AuthLogin />
|
||||
</Route>
|
||||
|
||||
<Route exact path={`/auth/signup`}>
|
||||
<AuthSignUp />
|
||||
</Route>
|
||||
|
||||
{/* TODO: remove below */}
|
||||
<Route exact path="/tab1">
|
||||
<Tab1 />
|
||||
|
21
002_source/ionic_mobile/src/components/Action/index.tsx
Normal file
21
002_source/ionic_mobile/src/components/Action/index.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { IonCol, IonRouterLink, IonRow } from '@ionic/react';
|
||||
|
||||
function Action(props: { message: string; text: string; link: string }): React.JSX.Element {
|
||||
return (
|
||||
<>
|
||||
<IonRow className="ion-text-center ion-justify-content-center">
|
||||
<IonCol size="12">
|
||||
<p>
|
||||
{props.message}
|
||||
<IonRouterLink className="custom-link" routerLink={props.link}>
|
||||
{' '}
|
||||
{props.text} →
|
||||
</IonRouterLink>
|
||||
</p>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export { Action };
|
40
002_source/ionic_mobile/src/components/CustomField/index.tsx
Normal file
40
002_source/ionic_mobile/src/components/CustomField/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { IonInput, IonLabel } from '@ionic/react';
|
||||
import styles from './style.module.scss';
|
||||
|
||||
function CustomField({
|
||||
field,
|
||||
errors,
|
||||
}: {
|
||||
field: {
|
||||
id: string;
|
||||
label: string;
|
||||
required: boolean;
|
||||
input: {
|
||||
props: { type: string; placeholder: string };
|
||||
state: {
|
||||
value: string;
|
||||
reset: (newValue: any) => void;
|
||||
onIonChange: (e: any) => Promise<void>;
|
||||
onKeyUp: (e: any) => Promise<void>;
|
||||
};
|
||||
};
|
||||
};
|
||||
errors: any;
|
||||
}): React.JSX.Element {
|
||||
const error = errors && errors.filter((e) => e.id === field.id)[0];
|
||||
const errorMessage = error && errors.filter((e) => e.id === field.id)[0].message;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.field}>
|
||||
<IonLabel className={styles.fieldLabel}>
|
||||
{field.label}
|
||||
{error && <p className="animate__animated animate__bounceIn">{errorMessage}</p>}
|
||||
</IonLabel>
|
||||
<IonInput className={styles.customInput} {...field.input.props} {...field.input.state} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export { CustomField };
|
@@ -0,0 +1,29 @@
|
||||
.field:not(:last-child) {
|
||||
margin-bottom: 1rem !important;
|
||||
}
|
||||
|
||||
.field {
|
||||
ion-label {
|
||||
padding-left: 0.2rem;
|
||||
padding-right: 0.5rem;
|
||||
color: #d3a6c7;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
|
||||
p {
|
||||
color: rgb(236, 149, 35);
|
||||
}
|
||||
}
|
||||
}
|
||||
.customInput {
|
||||
// --background: #834e76;
|
||||
--padding-bottom: 1rem;
|
||||
--padding-top: 1rem;
|
||||
--padding-start: 1rem;
|
||||
--padding-end: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 0.25rem;
|
||||
transition: all 0.2s linear;
|
||||
}
|
5
002_source/ionic_mobile/src/components/Helloworld.tsx
Normal file
5
002_source/ionic_mobile/src/components/Helloworld.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
function Helloworld(): React.JSX.Element {
|
||||
return <>Helloworld Component</>;
|
||||
}
|
||||
|
||||
export { Helloworld };
|
9
002_source/ionic_mobile/src/components/Wave/index.tsx
Normal file
9
002_source/ionic_mobile/src/components/Wave/index.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
export const Wave = () => (
|
||||
<svg style={{ marginBottom: '-0.5rem' }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
|
||||
<path
|
||||
fill="#7a506f"
|
||||
fillOpacity="1"
|
||||
d="M0,288L40,277.3C80,267,160,245,240,224C320,203,400,181,480,176C560,171,640,181,720,181.3C800,181,880,171,960,144C1040,117,1120,75,1200,58.7C1280,43,1360,53,1400,58.7L1440,64L1440,320L1400,320C1360,320,1280,320,1200,320C1120,320,1040,320,960,320C880,320,800,320,720,320C640,320,560,320,480,320C400,320,320,320,240,320C160,320,80,320,40,320L0,320Z"
|
||||
></path>
|
||||
</svg>
|
||||
);
|
71
002_source/ionic_mobile/src/data/fields.tsx
Normal file
71
002_source/ionic_mobile/src/data/fields.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import { useFormInput } from './utils';
|
||||
|
||||
export const useSignupFields = () => {
|
||||
return [
|
||||
{
|
||||
id: 'name',
|
||||
label: 'Name',
|
||||
required: true,
|
||||
input: {
|
||||
props: {
|
||||
type: 'text',
|
||||
placeholder: 'Joe Bloggs',
|
||||
},
|
||||
state: useFormInput(''),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
label: 'Email',
|
||||
required: true,
|
||||
input: {
|
||||
props: {
|
||||
type: 'email',
|
||||
placeholder: 'joe@bloggs.com',
|
||||
},
|
||||
state: useFormInput(''),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'password',
|
||||
label: 'Password',
|
||||
required: true,
|
||||
input: {
|
||||
props: {
|
||||
type: 'password',
|
||||
placeholder: '*********',
|
||||
},
|
||||
state: useFormInput(''),
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
export const useLoginFields = () => {
|
||||
return [
|
||||
{
|
||||
id: 'email',
|
||||
label: 'Email',
|
||||
required: true,
|
||||
input: {
|
||||
props: {
|
||||
type: 'email',
|
||||
placeholder: 'joe@bloggs.com',
|
||||
},
|
||||
state: useFormInput(''),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'password',
|
||||
label: 'Password',
|
||||
required: true,
|
||||
input: {
|
||||
props: {
|
||||
type: 'password',
|
||||
placeholder: '*******',
|
||||
},
|
||||
state: useFormInput(''),
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
38
002_source/ionic_mobile/src/data/utils.tsx
Normal file
38
002_source/ionic_mobile/src/data/utils.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
export const useFormInput = (initialValue = '') => {
|
||||
const [value, setValue] = useState(initialValue);
|
||||
|
||||
const handleChange = async (e) => {
|
||||
const tempValue = await e.currentTarget.value;
|
||||
setValue(tempValue);
|
||||
};
|
||||
|
||||
return {
|
||||
value,
|
||||
reset: (newValue) => setValue(newValue),
|
||||
onIonChange: handleChange,
|
||||
onKeyUp: handleChange,
|
||||
};
|
||||
};
|
||||
|
||||
export const validateForm = (fields) => {
|
||||
let errors = [];
|
||||
|
||||
fields.forEach((field) => {
|
||||
if (field.required) {
|
||||
const fieldValue = field.input.state.value;
|
||||
|
||||
if (fieldValue === '') {
|
||||
const error = {
|
||||
id: field.id,
|
||||
message: `Please check your ${field.id}`,
|
||||
};
|
||||
|
||||
errors.push(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return errors;
|
||||
};
|
@@ -2,5 +2,8 @@
|
||||
|
||||
- single file contains single function only
|
||||
- please refer to the `tsx` files already exist in this directory for
|
||||
|
||||
- styling
|
||||
- naming convention
|
||||
|
||||
- `useListQuizListeningPracticeContent.tsx` is a sample for listing question in listening practice.
|
||||
|
30
002_source/ionic_mobile/src/hooks/fetchCRQuestions.tsx
Normal file
30
002_source/ionic_mobile/src/hooks/fetchCRQuestions.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { idCard } from 'ionicons/icons';
|
||||
import { QuizCRQuestion } from '../types/QuizCRQuestion';
|
||||
import { usePocketBase } from './usePocketBase';
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import PocketBase from 'pocketbase';
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: Infinity,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const fetchCRQuestions = async (cat_id: string, pb: PocketBase) => {
|
||||
const response = await queryClient.fetchQuery({
|
||||
queryKey: ['fetchData', cat_id],
|
||||
staleTime: 60 * 1000,
|
||||
queryFn: async () => {
|
||||
return await pb.collection('QuizCRQuestions').getList<QuizCRQuestion>(1, 9999, {
|
||||
filter: `cat_id = "${cat_id}"`,
|
||||
$autoCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
export default fetchCRQuestions;
|
@@ -0,0 +1,38 @@
|
||||
// CR = ConnectiveRevision
|
||||
import { usePocketBase } from './usePocketBase.tsx';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import IListeningPracticeCategory from '../interfaces/IListeningPracticeCategory.tsx';
|
||||
|
||||
const useListQuizCRCategories = () => {
|
||||
const { user, pb } = usePocketBase();
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
'useListQuizConnectiveRevisionContent',
|
||||
'feeds',
|
||||
'all',
|
||||
user?.id || '',
|
||||
//
|
||||
],
|
||||
staleTime: 60 * 1000,
|
||||
queryFn: async ({
|
||||
queryKey,
|
||||
}: {
|
||||
queryKey: [
|
||||
'useListQuizConnectiveRevisionContent',
|
||||
'feeds',
|
||||
'all',
|
||||
string | null,
|
||||
//
|
||||
];
|
||||
}) => {
|
||||
console.log('calling useListQuizConnectiveRevisionContent');
|
||||
return await pb.collection('LessonsCategories').getList<IListeningPracticeCategory>(1, 9999, {
|
||||
sort: 'pos',
|
||||
$autoCancel: false,
|
||||
});
|
||||
},
|
||||
// enabled: !!user?.id,
|
||||
});
|
||||
};
|
||||
|
||||
export default useListQuizCRCategories;
|
@@ -0,0 +1,26 @@
|
||||
import { usePocketBase } from './usePocketBase.tsx';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { QuizCRQuestion } from '../types/QuizCRQuestion.ts/index.ts';
|
||||
|
||||
const useListQuizCRQuestionByCRCategoryId = (CRCategoryId: string) => {
|
||||
const { user, pb } = usePocketBase();
|
||||
return useQuery({
|
||||
queryKey: ['useListQuizCRQuestionByCRCategoryId', 'feeds', 'all', user?.id || '', CRCategoryId],
|
||||
staleTime: 60 * 1000,
|
||||
queryFn: async ({
|
||||
queryKey,
|
||||
}: {
|
||||
queryKey: ['useListQuizCRQuestionByCRCategoryId', 'feeds', 'all', string | null, string];
|
||||
}) => {
|
||||
console.log('calling useListQuizCRQuestionByCRCategoryId');
|
||||
return await pb.collection('QuizCRQuestions').getList<QuizCRQuestion>(1, 9999, {
|
||||
filter: `cat_id = "${CRCategoryId}"`,
|
||||
sort: 'id',
|
||||
$autoCancel: false,
|
||||
});
|
||||
},
|
||||
// enabled: !!user?.id && !!CRCategoryId,
|
||||
});
|
||||
};
|
||||
|
||||
export default useListQuizCRQuestionByCRCategoryId;
|
@@ -5,7 +5,9 @@ interface IConnectivesRevisionCategory {
|
||||
test_i: number;
|
||||
cat_info: string;
|
||||
cat_name: string;
|
||||
content: IConnectivesRevisionQuestion[] | [];
|
||||
content?: IConnectivesRevisionQuestion[] | [];
|
||||
//
|
||||
id: string;
|
||||
}
|
||||
|
||||
export default IConnectivesRevisionCategory;
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// abonded
|
||||
interface IQuestionMeta {
|
||||
question_idx: number;
|
||||
question_fh: string;
|
||||
|
@@ -155,7 +155,7 @@ const QuizContent: React.FC<IQuestionCard> = ({
|
||||
>
|
||||
{answer_list.map((connective, idx) => {
|
||||
return (
|
||||
<div>
|
||||
<div key={idx}>
|
||||
<IonButton
|
||||
color={'dark'}
|
||||
ref={button_refs[idx]}
|
||||
|
@@ -8,11 +8,15 @@ import { useMyIonQuizContext } from '../../contexts/MyIonQuiz';
|
||||
import { listConectivesRevisionContent } from '../../public_data/listConectivesRevisionContent';
|
||||
import { shuffleArray } from '../../utils/shuffleArray';
|
||||
import QuizContent from './QuizContent';
|
||||
import fetchCRQuestions from '../../hooks/fetchCRQuestions';
|
||||
import { usePocketBase } from '../../hooks/usePocketBase';
|
||||
|
||||
function ConnectiveRevisionQuizRun() {
|
||||
const router = useIonRouter();
|
||||
const { p_route } = useParams<{ p_route: string }>();
|
||||
const i_p_route = parseInt(p_route);
|
||||
const { p_route: cat_id } = useParams<{ p_route: string }>();
|
||||
|
||||
// NOTE: abonded, should be updated with `i_cat_id` when done
|
||||
const i_p_route = parseInt(cat_id);
|
||||
|
||||
const { setTabActive } = useAppStateContext();
|
||||
const [question_list, setQuestionList] = useState<IQuestionJson[] | []>([]);
|
||||
@@ -22,6 +26,9 @@ function ConnectiveRevisionQuizRun() {
|
||||
const [isOpenCorrectAnswer, setIsOpenCorrectAnswer] = useState(false);
|
||||
const [isOpenWrongAnswer, setIsOpenWrongAnswer] = useState(false);
|
||||
const [answer_list, setAnswerList] = useState<string[]>(['but', 'and', 'or', 'of', 'with']);
|
||||
|
||||
const { user, pb } = usePocketBase();
|
||||
|
||||
const {
|
||||
setConnectiveRevisionCurrentTest,
|
||||
setConnectiveRevisionProgress,
|
||||
@@ -79,19 +86,19 @@ function ConnectiveRevisionQuizRun() {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const res_json = await listConectivesRevisionContent();
|
||||
let temp_init_ans = res_json[i_p_route].init_ans;
|
||||
const res_json = await fetchCRQuestions(cat_id, pb);
|
||||
let temp_init_ans: string[] = res_json.items[0].init_answer;
|
||||
|
||||
setInitAnswer(temp_init_ans);
|
||||
let temp = res_json[i_p_route].content;
|
||||
let temp = res_json.items;
|
||||
let shuffled_temp = shuffleArray(temp);
|
||||
// let shuffled_temp = temp;
|
||||
setQuestionList(shuffled_temp);
|
||||
|
||||
let question_meta_current = res_json[i_p_route].content[0];
|
||||
let question_meta_current = res_json.items[0] as unknown as IQuestionMeta;
|
||||
setCurrentQuestionMeta({
|
||||
question_idx: current_question_idx,
|
||||
...question_meta_current,
|
||||
question_idx: current_question_idx,
|
||||
});
|
||||
})();
|
||||
setTabActive(QUIZ_MAIN_MENU_LINK);
|
||||
@@ -113,31 +120,7 @@ function ConnectiveRevisionQuizRun() {
|
||||
total_questions_num={question_list.length}
|
||||
answer_list={answer_list}
|
||||
quiz_idx={i_p_route + 1}
|
||||
//
|
||||
/>
|
||||
{/* */}
|
||||
{/* <CorrectAnswerToast isOpen={isOpenCorrectAnswer} dismiss={() => setIsOpenCorrectAnswer(false)} /> */}
|
||||
{/* */}
|
||||
{/* <WrongAnswerToast
|
||||
correct_answer={current_question_meta.modal_ans}
|
||||
isOpen={isOpenWrongAnswer}
|
||||
dismiss={() => setIsOpenWrongAnswer(false)}
|
||||
/> */}
|
||||
{/*
|
||||
<IonToast
|
||||
isOpen={isOpenCorrectAnswer}
|
||||
message='This answer is correct'
|
||||
onDidDismiss={() => setIsOpenCorrectAnswer(false)}
|
||||
duration={1000 - 100}
|
||||
color='success'
|
||||
></IonToast>
|
||||
<IonToast
|
||||
isOpen={isOpenWrongAnswer}
|
||||
message='This answer is wrong'
|
||||
onDidDismiss={() => setIsOpenWrongAnswer(false)}
|
||||
duration={1000 - 100}
|
||||
color='danger'
|
||||
></IonToast> */}
|
||||
</IonContent>
|
||||
</IonPage>
|
||||
</>
|
||||
|
@@ -8,6 +8,7 @@ import { ConnectiveRevisionAllResult } from '../../contexts/ConnectiveRevisionRa
|
||||
import { useMyIonQuizContext } from '../../contexts/MyIonQuiz';
|
||||
import IConnectivesRevisionCategory from '../../interfaces/IConnectivesRevisionCategory';
|
||||
import { listConectivesRevisionContent } from '../../public_data/listConectivesRevisionContent';
|
||||
import useListQuizCRCategories from '../../hooks/useListQuizCRCategories';
|
||||
|
||||
function ConnectiveRevisionSelectCategory() {
|
||||
const PAGE_TITLE = 'Connective Revision';
|
||||
@@ -17,12 +18,12 @@ function ConnectiveRevisionSelectCategory() {
|
||||
let [categories, setCategories] = useState<IConnectivesRevisionCategory[] | []>([]);
|
||||
let { setTabActive, setConnectiveRevisionInProgress } = useAppStateContext();
|
||||
|
||||
useEffect(() => {
|
||||
listConectivesRevisionContent().then((res_json) => {
|
||||
setCategories(res_json);
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// listConectivesRevisionContent().then((res_json) => {
|
||||
// setCategories(res_json);
|
||||
// setLoading(false);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
let { loadConnectiveRevisionScoreBoard } = useMyIonQuizContext();
|
||||
let [scoreboard_meta, setScoreboardMeta] = useState<ConnectiveRevisionAllResult>();
|
||||
@@ -36,6 +37,14 @@ function ConnectiveRevisionSelectCategory() {
|
||||
setTabActive(QUIZ_MAIN_MENU_LINK);
|
||||
}, []);
|
||||
|
||||
let result = useListQuizCRCategories();
|
||||
useEffect(() => {
|
||||
if (result.status === 'success') {
|
||||
setCategories(result.data.items);
|
||||
setLoading(false);
|
||||
}
|
||||
}, [result]);
|
||||
|
||||
if (loading) return <LoadingScreen />;
|
||||
if (!scoreboard_meta) return <LoadingScreen />;
|
||||
|
||||
@@ -87,36 +96,34 @@ function ConnectiveRevisionSelectCategory() {
|
||||
</div>
|
||||
<div>{'Question Bank'}</div>
|
||||
<div style={{ width: '80vw' }}>
|
||||
{categories
|
||||
.map((item) => item.cat_name)
|
||||
.map((item_name, idx) => (
|
||||
<div style={{ margin: '0.9rem 0 0.9rem' }} key={idx}>
|
||||
<IonButton
|
||||
color="dark"
|
||||
fill="outline"
|
||||
expand="block"
|
||||
onClick={() => {
|
||||
setConnectiveRevisionInProgress(true);
|
||||
router.push(`${CONNECTIVE_REVISION_LINK}/r/${idx}`, 'none', 'replace');
|
||||
{categories.map((item, idx) => (
|
||||
<div style={{ margin: '0.9rem 0 0.9rem' }} key={idx}>
|
||||
<IonButton
|
||||
color="dark"
|
||||
fill="outline"
|
||||
expand="block"
|
||||
onClick={() => {
|
||||
setConnectiveRevisionInProgress(true);
|
||||
router.push(`${CONNECTIVE_REVISION_LINK}/r/${item.id}`, 'none', 'replace');
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div>{item_name}</div>
|
||||
<div>
|
||||
{scoreboard_meta[idx.toString()] || 0}
|
||||
{'%'}
|
||||
</div>
|
||||
<div>{item.cat_name}</div>
|
||||
<div>
|
||||
{scoreboard_meta[idx.toString()] || 0}
|
||||
{'%'}
|
||||
</div>
|
||||
</IonButton>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</IonButton>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</IonContent>
|
||||
|
56
002_source/ionic_mobile/src/pages/auth/Home/index.tsx
Normal file
56
002_source/ionic_mobile/src/pages/auth/Home/index.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
IonButton,
|
||||
IonCardTitle,
|
||||
IonCol,
|
||||
IonContent,
|
||||
IonFooter,
|
||||
IonGrid,
|
||||
IonHeader,
|
||||
IonImg,
|
||||
IonPage,
|
||||
IonRouterLink,
|
||||
IonRow,
|
||||
IonToolbar,
|
||||
} from '@ionic/react';
|
||||
// import { Action } from '../components/Action';
|
||||
import styles from './style.module.scss';
|
||||
import { Action } from '../../../components/Action';
|
||||
|
||||
const AuthHome = () => {
|
||||
return (
|
||||
<IonPage className={'styles.homePage'}>
|
||||
<IonHeader>
|
||||
{/* <IonToolbar className="ion-no-margin ion-no-padding"> */}
|
||||
<IonImg src="/assets/login2.jpeg" />
|
||||
{/* </IonToolbar> */}
|
||||
</IonHeader>
|
||||
<IonContent fullscreen>
|
||||
<div className={styles.getStarted}>
|
||||
<IonGrid>
|
||||
<IonRow className={`ion-text-center ion-justify-content-center ${styles.heading}`}>
|
||||
<IonCol size="11" className={styles.headingText}>
|
||||
<IonCardTitle>Join millions of other people discovering their creative side</IonCardTitle>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
|
||||
<IonRow className={`ion-text-center ion-justify-content-center`}>
|
||||
<IonRouterLink routerLink="/signup" className="custom-link">
|
||||
<IonCol size="11">
|
||||
<IonButton className={`${styles.getStartedButton} custom-button`}>Get started →</IonButton>
|
||||
</IonCol>
|
||||
</IonRouterLink>
|
||||
</IonRow>
|
||||
</IonGrid>
|
||||
</div>
|
||||
</IonContent>
|
||||
|
||||
<IonFooter>
|
||||
<IonGrid>
|
||||
<Action message="Already got an account?" text="Login" link="/login" />
|
||||
</IonGrid>
|
||||
</IonFooter>
|
||||
</IonPage>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthHome;
|
@@ -0,0 +1,41 @@
|
||||
.homePage {
|
||||
ion-header {
|
||||
ion-img {
|
||||
border-bottom: 3px solid rgb(236, 149, 35);
|
||||
}
|
||||
}
|
||||
|
||||
ion-footer {
|
||||
// background-color: #7c3b6a;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.getStarted {
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
background-image: radial-gradient(#b8b8b8 1px, transparent 1px), radial-gradient(#b8b8b8 1px, #ffffff 1px);
|
||||
background-size: 40px 40px;
|
||||
background-position:
|
||||
0 0,
|
||||
20px 20px;
|
||||
|
||||
ion-card-title {
|
||||
color: black !important;
|
||||
letter-spacing: -0.08rem;
|
||||
font-weight: 900 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.heading {
|
||||
margin-top: 7rem;
|
||||
}
|
||||
|
||||
.getStartedButton {
|
||||
font-size: 1.2rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.helloworld {
|
||||
color: gold;
|
||||
}
|
93
002_source/ionic_mobile/src/pages/auth/Login/index.tsx
Normal file
93
002_source/ionic_mobile/src/pages/auth/Login/index.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
import {
|
||||
IonBackButton,
|
||||
IonButton,
|
||||
IonButtons,
|
||||
IonCardTitle,
|
||||
IonCol,
|
||||
IonContent,
|
||||
IonFooter,
|
||||
IonGrid,
|
||||
IonHeader,
|
||||
IonIcon,
|
||||
IonImg,
|
||||
IonInput,
|
||||
IonInputPasswordToggle,
|
||||
IonPage,
|
||||
IonRouterLink,
|
||||
IonRow,
|
||||
IonText,
|
||||
IonToolbar,
|
||||
} from '@ionic/react';
|
||||
import styles from './style.module.scss';
|
||||
|
||||
import { arrowBack, shapesOutline } from 'ionicons/icons';
|
||||
import { CustomField } from '../../../components/CustomField';
|
||||
import { useLoginFields } from '../../../data/fields';
|
||||
|
||||
import { Action } from '../../../components/Action';
|
||||
import { Wave } from '../../../components/Wave';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useParams } from 'react-router';
|
||||
|
||||
function AuthLogin(): React.JSX.Element {
|
||||
const params = useParams();
|
||||
const [errors, setErrors] = useState(false);
|
||||
|
||||
const login = () => {};
|
||||
|
||||
return (
|
||||
<IonPage className={styles.loginPage}>
|
||||
<IonHeader>
|
||||
<IonToolbar>
|
||||
<IonButtons slot="start">
|
||||
<IonBackButton icon={arrowBack} text="" className="custom-back" />
|
||||
</IonButtons>
|
||||
|
||||
<IonButtons slot="end">
|
||||
<IonButton className="custom-button">
|
||||
<IonIcon icon={shapesOutline} />
|
||||
</IonButton>
|
||||
</IonButtons>
|
||||
</IonToolbar>
|
||||
</IonHeader>
|
||||
{/* */}
|
||||
<IonContent fullscreen>
|
||||
<IonGrid className="ion-padding">
|
||||
<IonRow>
|
||||
<IonCol size="12" className={styles.headingText}>
|
||||
<IonCardTitle>Log in</IonCardTitle>
|
||||
<h5>Welcome back, hope you're doing well</h5>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
|
||||
<IonRow className="ion-margin-top ion-padding-top">
|
||||
<IonCol size="12">
|
||||
<IonInput labelPlacement="floating" value="hi@ionic.io">
|
||||
<div slot="label">
|
||||
Email <IonText color="danger">(Required)</IonText>
|
||||
</div>
|
||||
</IonInput>
|
||||
<IonInput type="password" label="Password" value="NeverGonnaGiveYouUp">
|
||||
<IonInputPasswordToggle slot="end"></IonInputPasswordToggle>
|
||||
</IonInput>
|
||||
|
||||
<IonButton className="custom-button" expand="block" onClick={login}>
|
||||
Login
|
||||
</IonButton>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
</IonGrid>
|
||||
</IonContent>
|
||||
{/* */}
|
||||
<IonFooter>
|
||||
<IonGrid className="ion-no-margin ion-no-padding">
|
||||
<Action message="Don't have an account?" text="Sign up" link="/auth/signup" />
|
||||
<Wave />
|
||||
</IonGrid>
|
||||
</IonFooter>
|
||||
</IonPage>
|
||||
);
|
||||
}
|
||||
|
||||
export { AuthLogin };
|
@@ -0,0 +1,17 @@
|
||||
.loginPage {
|
||||
ion-toolbar {
|
||||
--border-style: none;
|
||||
--border-color: transparent;
|
||||
--padding-top: 1rem;
|
||||
--padding-bottom: 1rem;
|
||||
--padding-start: 1rem;
|
||||
--padding-end: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.headingText {
|
||||
h5 {
|
||||
margin-top: 0.2rem;
|
||||
// color: #d3a6c7;
|
||||
}
|
||||
}
|
95
002_source/ionic_mobile/src/pages/auth/SignUp/index.tsx
Normal file
95
002_source/ionic_mobile/src/pages/auth/SignUp/index.tsx
Normal file
@@ -0,0 +1,95 @@
|
||||
import {
|
||||
IonBackButton,
|
||||
IonButton,
|
||||
IonButtons,
|
||||
IonCardTitle,
|
||||
IonCol,
|
||||
IonContent,
|
||||
IonFooter,
|
||||
IonGrid,
|
||||
IonHeader,
|
||||
IonIcon,
|
||||
IonImg,
|
||||
IonInput,
|
||||
IonInputPasswordToggle,
|
||||
IonPage,
|
||||
IonRouterLink,
|
||||
IonRow,
|
||||
IonText,
|
||||
IonToolbar,
|
||||
} from '@ionic/react';
|
||||
import styles from './style.module.scss';
|
||||
|
||||
import { arrowBack, shapesOutline } from 'ionicons/icons';
|
||||
import { CustomField } from '../../../components/CustomField';
|
||||
import { useLoginFields, useSignupFields } from '../../../data/fields';
|
||||
|
||||
import { Action } from '../../../components/Action';
|
||||
import { Wave } from '../../../components/Wave';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useParams } from 'react-router';
|
||||
|
||||
function AuthSignUp(): React.JSX.Element {
|
||||
const params = useParams();
|
||||
const fields = useSignupFields();
|
||||
const [errors, setErrors] = useState(false);
|
||||
|
||||
const login = () => {};
|
||||
|
||||
function createAccount() {}
|
||||
|
||||
return (
|
||||
<IonPage className={styles.loginPage}>
|
||||
<IonHeader>
|
||||
<IonToolbar>
|
||||
<IonButtons slot="start">
|
||||
<IonBackButton icon={arrowBack} text="" className="custom-back" />
|
||||
</IonButtons>
|
||||
|
||||
<IonButtons slot="end">
|
||||
<IonButton className="custom-button">
|
||||
<IonIcon icon={shapesOutline} />
|
||||
</IonButton>
|
||||
</IonButtons>
|
||||
</IonToolbar>
|
||||
</IonHeader>
|
||||
{/* */}
|
||||
<IonContent fullscreen>
|
||||
<IonGrid className="ion-padding">
|
||||
<IonRow>
|
||||
<IonCol size="12" className={styles.headingText}>
|
||||
<IonCardTitle>Sign up</IonCardTitle>
|
||||
<h5>Lets get to know each other</h5>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
|
||||
<IonRow className="ion-margin-top ion-padding-top">
|
||||
<IonCol size="12">
|
||||
{fields.map((field, i) => {
|
||||
return (
|
||||
<div key={i}>
|
||||
<CustomField field={field} errors={errors} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
<IonButton className="custom-button" expand="block" onClick={createAccount}>
|
||||
Create account
|
||||
</IonButton>
|
||||
</IonCol>
|
||||
</IonRow>
|
||||
</IonGrid>
|
||||
</IonContent>
|
||||
{/* */}
|
||||
<IonFooter>
|
||||
<IonGrid className="ion-no-margin ion-no-padding">
|
||||
<Action message="Already got an account?" text="Login" link="/auth/login" />
|
||||
<Wave />
|
||||
</IonGrid>
|
||||
</IonFooter>
|
||||
</IonPage>
|
||||
);
|
||||
}
|
||||
|
||||
export { AuthSignUp };
|
@@ -0,0 +1,17 @@
|
||||
.signupPage {
|
||||
ion-toolbar {
|
||||
--border-style: none;
|
||||
--border-color: transparent;
|
||||
--padding-top: 1rem;
|
||||
--padding-bottom: 1rem;
|
||||
--padding-start: 1rem;
|
||||
--padding-end: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.headingText {
|
||||
h5 {
|
||||
margin-top: 0.2rem;
|
||||
// color: #d3a6c7;
|
||||
}
|
||||
}
|
33
002_source/ionic_mobile/src/types/QuizCRQuestion.ts
Normal file
33
002_source/ionic_mobile/src/types/QuizCRQuestion.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Represents a Connectives Revision Quiz Question
|
||||
*/
|
||||
export interface QuizCRQuestion {
|
||||
/** Unique identifier */
|
||||
id: string;
|
||||
/** Creation timestamp */
|
||||
created: Date;
|
||||
/** Last update timestamp */
|
||||
updated: Date;
|
||||
/** First half of the question */
|
||||
question_fh: string;
|
||||
/** Second half of the question */
|
||||
question_sh: string;
|
||||
/** Modal answer text */
|
||||
modal_ans: string;
|
||||
/** Initial answer text */
|
||||
init_answer: string[];
|
||||
/** Category ID reference */
|
||||
cat_id: string;
|
||||
/** Additional options in JSON format */
|
||||
options: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expanded QuizCRQuestion with related category data
|
||||
*/
|
||||
export interface QuizCRQuestionExpanded extends QuizCRQuestion {
|
||||
/** Category name */
|
||||
cat_name?: string;
|
||||
/** Category image */
|
||||
cat_image?: string;
|
||||
}
|
@@ -1,3 +1,7 @@
|
||||
# GUIDELINES
|
||||
|
||||
- please follow to the `schema.dbml` when you draft types related to db
|
||||
|
||||
## highlighted samples
|
||||
|
||||
- `QuizLPQuestion.d.ts`
|
||||
|
@@ -2,11 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": [
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ESNext"
|
||||
],
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": false,
|
||||
@@ -20,17 +16,16 @@
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"./dist",
|
||||
//
|
||||
"**/*.del",
|
||||
"**/*copy.*",
|
||||
"**/*copy*.*",
|
||||
"**/*.bak",
|
||||
"**/*.fix",
|
||||
"node_modules",
|
||||
"./dist"
|
||||
"**/*.fix"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
|
1
002_source/pocketbase/.gitignore
vendored
1
002_source/pocketbase/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
#
|
||||
volumes
|
||||
pb_migrations
|
||||
|
23315
002_source/pocketbase/pb_data/types.d.ts
vendored
23315
002_source/pocketbase/pb_data/types.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,7 @@ $app.rootCmd.addCommand(
|
||||
require(`${__hooks}/seed/002_LessonsCategories.js`)($app);
|
||||
require(`${__hooks}/seed/003_Categories.js`)($app);
|
||||
require(`${__hooks}/seed/004_clean_users.js`)($app);
|
||||
require(`${__hooks}/seed/005_Users_teacher.js`)($app);
|
||||
require(`${__hooks}/seed/006_Users_student.js`)($app);
|
||||
|
||||
require(`${__hooks}/seed/007_Users_admin.js`)($app);
|
||||
require(`${__hooks}/seed/010_Vocabularies.js`)($app);
|
||||
//
|
||||
@@ -35,6 +34,10 @@ $app.rootCmd.addCommand(
|
||||
require(`${__hooks}/seed/052_Students.js`)($app);
|
||||
//
|
||||
require(`${__hooks}/seed/060_Notifications.js`)($app);
|
||||
require(`${__hooks}/seed/062_billingAddress.js`)($app);
|
||||
//
|
||||
require(`${__hooks}/seed/063_Users_teacher.js`)($app);
|
||||
require(`${__hooks}/seed/064_Users_student.js`)($app);
|
||||
|
||||
$app.reloadCachedCollections();
|
||||
$app.reloadSettings();
|
||||
|
54
002_source/pocketbase/pb_hooks/seed/062_billingAddress.js
Normal file
54
002_source/pocketbase/pb_hooks/seed/062_billingAddress.js
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// RULES:
|
||||
// this is not a normal nodejs engine,
|
||||
// it is a nodejs provided by golang,
|
||||
// so fakerjs cannot be used here
|
||||
// use vscode extensions 'Gruntfuggly.align-mode' to align comma
|
||||
//
|
||||
const config = require("/pb_hooks/seed/config.js");
|
||||
const utils = require("/pb_hooks/seed/utils.js");
|
||||
|
||||
//
|
||||
module.exports = ($app) => {
|
||||
const { CR_cat_id_news, CR_cat_id_technology, user_id_admin, user_id_test_teacher_1 } = config;
|
||||
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||
|
||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||
const SAMPLE_BILLING_ADDRESS_CSV = `
|
||||
Central African Republic , Arizona , Winfieldburgh , 92017-8004, 1838 Willa Freeway , Suite 307
|
||||
Iraq , Nevada , Casa Grande , 83831-3843, 6984 Alberto Radial , Suite 154
|
||||
Grenada , Georgia , New Brodyfort , 18887-7075, 493 Pfannerstill Meadow, Apt. 358
|
||||
Australia , North Carolina, Fort Jerrell , 14211 , 1763 West Street , Suite 699
|
||||
Reunion , New York , Kayton , 82048-0645, 636 Angel Junction , Apt. 361
|
||||
Heard Island and McDonald Islands, Wisconsin , Jalenbury , 75732-7013, 669 Sven Trail , Suite 409
|
||||
Israel , Maryland , East Allenmouth, 21779 , 6070 W Grand Avenue , Suite 448
|
||||
Canada , Michigan , Lafayette , 90430-8775, 430 Orland Place , Suite 891
|
||||
South Georgia , Colorado , Lake Isaias , 26025-5909, 143 Kautzer Unions , Apt. 752
|
||||
Mali , Illinois , Stammburgh , 92318 , 7669 Jude Drive , Apt. 594
|
||||
`;
|
||||
const SAMPLE_BILLING_ADDRESS_AA = SAMPLE_BILLING_ADDRESS_CSV.trim()
|
||||
.split("\n")
|
||||
.map((r) => r.split(",").map((c) => c.trim()));
|
||||
|
||||
let row_array = SAMPLE_BILLING_ADDRESS_AA;
|
||||
dirtyTruncateTable("billingAddress");
|
||||
|
||||
let ba_collection = $app.findCollectionByNameOrId("billingAddress");
|
||||
|
||||
for (let i = 0; i < row_array.length; i++) {
|
||||
let ba = row_array[i];
|
||||
|
||||
let record = new Record(ba_collection);
|
||||
record.set("id", getId(i.toString()));
|
||||
record.set("country", ba[0]);
|
||||
record.set("state", ba[1]);
|
||||
record.set("city", ba[2]);
|
||||
record.set("zipCode", ba[3]);
|
||||
record.set("line1", ba[4]);
|
||||
record.set("line2", ba[5]);
|
||||
|
||||
$app.save(record);
|
||||
}
|
||||
|
||||
console.log(`062_billingAddress done`);
|
||||
};
|
@@ -1,9 +1,16 @@
|
||||
//
|
||||
// RULES:
|
||||
// this is not a normal nodejs engine,
|
||||
// it is a nodejs provided by golang,
|
||||
// so fakerjs cannot be used here
|
||||
// use vscode extensions 'Gruntfuggly.align-mode' to align comma
|
||||
//
|
||||
const config = require("/pb_hooks/seed/config.js");
|
||||
const utils = require("/pb_hooks/seed/utils.js");
|
||||
|
||||
module.exports = ($app) => {
|
||||
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||
const { getId, getAsset } = utils;
|
||||
const { getId, getAsset, randomId } = utils;
|
||||
|
||||
let row_array = [
|
||||
[getId("11"), "teacher1@123.com", "teacher1@123.com", "teacher1@123.com", true, true, "test_teacher_1"],
|
||||
@@ -52,15 +59,10 @@ module.exports = ($app) => {
|
||||
um_record.set("email", user[3]);
|
||||
um_record.set("phone", "9123456" + i.toString());
|
||||
|
||||
um_record.set("billingAddress", randomId(10));
|
||||
|
||||
$app.save(um_record);
|
||||
}
|
||||
|
||||
console.log("005 add teacher user done");
|
||||
console.log("063 add teacher user done");
|
||||
};
|
||||
|
||||
// TODO: delete this ?
|
||||
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||
// cmd_to_exec.output();
|
||||
// };
|
@@ -1,9 +1,16 @@
|
||||
//
|
||||
// RULES:
|
||||
// this is not a normal nodejs engine,
|
||||
// it is a nodejs provided by golang,
|
||||
// so fakerjs cannot be used here
|
||||
// use vscode extensions 'Gruntfuggly.align-mode' to align comma
|
||||
//
|
||||
const config = require("/pb_hooks/seed/config.js");
|
||||
const utils = require("/pb_hooks/seed/utils.js");
|
||||
|
||||
module.exports = ($app) => {
|
||||
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||
const { getId, getAsset } = utils;
|
||||
const { getId, getAsset, randomId } = utils;
|
||||
|
||||
let row_array = [
|
||||
[getId("1"), "user1@123.com", "user1@123.com", "user1@123.com", true, true, "test_student_1"],
|
||||
@@ -51,20 +58,20 @@ module.exports = ($app) => {
|
||||
um_record.set("avatar_file", um[5]);
|
||||
//
|
||||
|
||||
um_record.set("role", um[6]);
|
||||
um_record.set("name", um[7]);
|
||||
um_record.set("email", user[3]);
|
||||
um_record.set("phone", "9123456" + i.toString());
|
||||
um_record.set("company", "company_" + i.toString());
|
||||
um_record.set("taxId", "taxId_" + i.toString());
|
||||
um_record.set("timezone", "America/New_York");
|
||||
um_record.set("language", "en");
|
||||
um_record.set("currency", "EUR");
|
||||
um_record.set("billingAddress", randomId(10));
|
||||
|
||||
um_record.set("role", um[6]);
|
||||
|
||||
$app.save(um_record);
|
||||
}
|
||||
|
||||
console.log("006 add student user done");
|
||||
console.log("064 add student user done");
|
||||
};
|
||||
|
||||
// TODO: delete this ?
|
||||
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||
// cmd_to_exec.output();
|
||||
// };
|
3
002_source/pocketbase/pb_hooks/seed/helloworld.json
Normal file
3
002_source/pocketbase/pb_hooks/seed/helloworld.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"hello": "json"
|
||||
}
|
@@ -1174,6 +1174,17 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"exceptDomains": null,
|
||||
"hidden": false,
|
||||
"id": "url917281265",
|
||||
"name": "link",
|
||||
"onlyDomains": null,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "url"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -1739,6 +1750,20 @@
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -1759,20 +1784,6 @@
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
@@ -1881,26 +1892,6 @@
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
@@ -2003,6 +1994,26 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "editor"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -2171,6 +2182,20 @@
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -2190,20 +2215,6 @@
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2058414169",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "visible",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -2859,7 +2870,7 @@
|
||||
"id": "text4192936109",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "helloworld",
|
||||
"name": "address",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
@@ -2890,6 +2901,20 @@
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2744374011",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "state",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
@@ -2910,20 +2935,6 @@
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2744374011",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "status",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "file376926767",
|
||||
@@ -2990,6 +3001,89 @@
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1337919823",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "company",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2020362641",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "taxId",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text922858135",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "timezone",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3571151285",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "language",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1767278655",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "currency",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_1509025625",
|
||||
"hidden": false,
|
||||
"id": "relation2115670734",
|
||||
"maxSelect": 999,
|
||||
"minSelect": 0,
|
||||
"name": "billingAddress",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
@@ -3593,11 +3687,11 @@
|
||||
},
|
||||
{
|
||||
"id": "pbc_1509025625",
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "billingAddress",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
@@ -3787,11 +3881,11 @@
|
||||
},
|
||||
{
|
||||
"id": "pbc_2109205374",
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"name": "t1",
|
||||
"type": "base",
|
||||
"fields": [
|
||||
|
@@ -10,6 +10,10 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
getId: (id) => id.padStart(15, 0),
|
||||
randomId: (max) =>
|
||||
Math.floor(Math.random() * max)
|
||||
.toString()
|
||||
.padStart(15, 0),
|
||||
|
||||
dirtyTruncateTable: (COLLECTION_NAME) => {
|
||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||
|
@@ -1,136 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1305841361");
|
||||
|
||||
return app.delete(collection);
|
||||
}, (app) => {
|
||||
const collection = new Collection({
|
||||
"createRule": "",
|
||||
"deleteRule": "",
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text4192936109",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "helloworld",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json3622966325",
|
||||
"maxSize": 0,
|
||||
"name": "meta",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"hidden": false,
|
||||
"id": "relation2809058197",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "user_id",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2744374011",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "state",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "file376926767",
|
||||
"maxSelect": 1,
|
||||
"maxSize": 0,
|
||||
"mimeTypes": [],
|
||||
"name": "avatar",
|
||||
"presentable": false,
|
||||
"protected": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"thumbs": [],
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1466534506",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "role",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"id": "pbc_1305841361",
|
||||
"indexes": [],
|
||||
"listRule": "",
|
||||
"name": "UserMetas",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": "",
|
||||
"viewRule": ""
|
||||
});
|
||||
|
||||
return app.save(collection);
|
||||
})
|
@@ -1,45 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
||||
|
||||
// add field
|
||||
collection.fields.addAt(9, new Field({
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1579384326",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "name",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}))
|
||||
|
||||
// add field
|
||||
collection.fields.addAt(10, new Field({
|
||||
"exceptDomains": null,
|
||||
"hidden": false,
|
||||
"id": "email3885137012",
|
||||
"name": "email",
|
||||
"onlyDomains": null,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "email"
|
||||
}))
|
||||
|
||||
return app.save(collection)
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
||||
|
||||
// remove field
|
||||
collection.fields.removeById("text1579384326")
|
||||
|
||||
// remove field
|
||||
collection.fields.removeById("email3885137012")
|
||||
|
||||
return app.save(collection)
|
||||
})
|
@@ -1,29 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("_pb_users_auth_")
|
||||
|
||||
// add field
|
||||
collection.fields.addAt(11, new Field({
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1146066909",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "phone",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}))
|
||||
|
||||
return app.save(collection)
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("_pb_users_auth_")
|
||||
|
||||
// remove field
|
||||
collection.fields.removeById("text1146066909")
|
||||
|
||||
return app.save(collection)
|
||||
})
|
@@ -1,29 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
||||
|
||||
// add field
|
||||
collection.fields.addAt(11, new Field({
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1146066909",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "phone",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}))
|
||||
|
||||
return app.save(collection)
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
||||
|
||||
// remove field
|
||||
collection.fields.removeById("text1146066909")
|
||||
|
||||
return app.save(collection)
|
||||
})
|
@@ -1,20 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1413424569")
|
||||
|
||||
// update collection data
|
||||
unmarshal({
|
||||
"name": "Teachers_xxx"
|
||||
}, collection)
|
||||
|
||||
return app.save(collection)
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1413424569")
|
||||
|
||||
// update collection data
|
||||
unmarshal({
|
||||
"name": "Teachers"
|
||||
}, collection)
|
||||
|
||||
return app.save(collection)
|
||||
})
|
@@ -1,17 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DB_COMPOSE_FILE="-f ./docker-compose.db.yml"
|
||||
_COMPOSE_FILE="-f ./docker-compose.yml"
|
||||
DEV_COMPOSE_FILE="-f ./docker-compose.dev.yml"
|
||||
|
||||
COMPOSE_FILES="$DB_COMPOSE_FILE $_COMPOSE_FILE $DEV_COMPOSE_FILE"
|
||||
|
||||
set -x
|
||||
|
||||
cd docker
|
||||
|
||||
docker compose $COMPOSE_FILES kill
|
||||
docker compose $COMPOSE_FILES down
|
||||
|
||||
set -ex
|
||||
|
||||
docker compose kill
|
||||
docker compose down
|
||||
docker compose $COMPOSE_FILES up -d pocketbase api_ts --remove-orphans
|
||||
|
||||
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d pocketbase api_ts --remove-orphans
|
||||
# docker compose logs -f pocketbase api_ts
|
||||
docker compose $COMPOSE_FILES logs pocketbase
|
||||
|
||||
echo "done"
|
||||
|
||||
sudo chown 1000:1000 -R ./volumes
|
||||
|
||||
echo "please run yourself !!!!"
|
||||
echo "nodemon -w /pb_hooks --exec "pocketbase seed""
|
||||
echo ""
|
||||
docker compose exec -it pocketbase sh
|
||||
docker compose $COMPOSE_FILES exec -it pocketbase sh
|
||||
|
||||
cd ..
|
||||
|
@@ -12,6 +12,6 @@ rsync -avh \
|
||||
--exclude ".next" \
|
||||
--exclude "node_modules" \
|
||||
--exclude ".git" \
|
||||
. ../_archive/022_init_lesson_categories
|
||||
. ../_archive/023_init_lesson_categories
|
||||
|
||||
echo "done"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function removeNodeModules(dir) {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
@@ -8,13 +8,13 @@ function removeNodeModules(dir) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name === "node_modules") {
|
||||
if (entry.name === 'node_modules') {
|
||||
fs.rmSync(fullPath, { recursive: true });
|
||||
} else {
|
||||
removeNodeModules(fullPath);
|
||||
}
|
||||
|
||||
if (entry.name === ".next") {
|
||||
if (entry.name === '.next') {
|
||||
fs.rmSync(fullPath, { recursive: true });
|
||||
} else {
|
||||
removeNodeModules(fullPath);
|
||||
@@ -23,5 +23,5 @@ function removeNodeModules(dir) {
|
||||
}
|
||||
}
|
||||
|
||||
removeNodeModules(".");
|
||||
removeNodeModules('.');
|
||||
console.log("All 'node_modules' directories have been removed.");
|
Reference in New Issue
Block a user