``refactor UserMeta creation and authentication client to improve documentation and type consistency
``
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
// api method for crate customer record
|
// src/db/UserMetas/Create.tsx
|
||||||
// RULES:
|
//
|
||||||
// TBA
|
// PURPOSE:
|
||||||
import { pb } from '@/lib/pb';
|
// create user meta
|
||||||
|
//
|
||||||
import { COL_USER_METAS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import type { CreateFormProps } from '@/components/dashboard/user_meta/type.d';
|
|
||||||
import type { RecordModel } from 'pocketbase';
|
import type { RecordModel } from 'pocketbase';
|
||||||
|
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
import type { CreateFormProps } from '@/components/dashboard/user_meta/type.d';
|
||||||
|
|
||||||
export async function createUserMeta(data: CreateFormProps): Promise<RecordModel> {
|
export async function createUserMeta(data: CreateFormProps): Promise<RecordModel> {
|
||||||
return pb.collection(COL_USER_METAS).create(data);
|
return pb.collection(COL_USER_METAS).create(data);
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,12 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
// src/lib/auth/custom/client.ts
|
||||||
|
//
|
||||||
import { getUserMetaById } from '@/db/UserMetas/GetById';
|
import { getUserMetaById } from '@/db/UserMetas/GetById';
|
||||||
|
|
||||||
|
import type { User } from '@/types/user';
|
||||||
import { logger } from '@/lib/default-logger';
|
import { logger } from '@/lib/default-logger';
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import type { User } from '@/types/user';
|
|
||||||
|
|
||||||
function generateToken(): string {
|
function generateToken(): string {
|
||||||
const arr = new Uint8Array(12);
|
const arr = new Uint8Array(12);
|
||||||
@@ -11,14 +14,6 @@ function generateToken(): string {
|
|||||||
return Array.from(arr, (v) => v.toString(16).padStart(2, '0')).join('');
|
return Array.from(arr, (v) => v.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
const user_xxx = {
|
|
||||||
id: 'USR-000',
|
|
||||||
avatar: '/assets/avatar.png',
|
|
||||||
firstName: 'Sofia',
|
|
||||||
lastName: 'Rivers',
|
|
||||||
email: 'sofia@devias.io',
|
|
||||||
} satisfies User;
|
|
||||||
|
|
||||||
export interface SignUpParams {
|
export interface SignUpParams {
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
Reference in New Issue
Block a user