This commit is contained in:
2024-12-10 14:27:30 -05:00
parent e0dbce2450
commit 471a8be856
5 changed files with 163 additions and 17 deletions

5
.env
View File

@@ -1,8 +1,3 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="postgresql://postgres:cul8rman@portainer.dev.gofwd.group:5433/ballistic?schema=public" DATABASE_URL="postgresql://postgres:cul8rman@portainer.dev.gofwd.group:5433/ballistic?schema=public"

26
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "balistics-builder", "name": "balistics-builder",
"version": "0.1.0", "version": "0.2.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "balistics-builder", "name": "balistics-builder",
"version": "0.1.0", "version": "0.2.0",
"dependencies": { "dependencies": {
"@chakra-ui/next-js": "^2.4.2", "@chakra-ui/next-js": "^2.4.2",
"@chakra-ui/react": "^3.1.2", "@chakra-ui/react": "^3.1.2",
@@ -20,7 +20,6 @@
"@mui/styles": "^6.1.7", "@mui/styles": "^6.1.7",
"@mui/system": "^6.1.7", "@mui/system": "^6.1.7",
"@mui/x-data-grid": "^7.22.2", "@mui/x-data-grid": "^7.22.2",
"@prisma/client": "^5.22.0",
"@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-slot": "^1.1.0",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
@@ -49,7 +48,6 @@
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "15.0.3", "eslint-config-next": "15.0.3",
"postcss": "^8", "postcss": "^8",
"prisma": "^5.22.0",
"tailwindcss": "^3.4.15", "tailwindcss": "^3.4.15",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.6.3" "typescript": "^5.6.3"
@@ -2687,6 +2685,8 @@
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz",
"integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==", "integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==",
"hasInstallScript": true, "hasInstallScript": true,
"optional": true,
"peer": true,
"engines": { "engines": {
"node": ">=16.13" "node": ">=16.13"
}, },
@@ -2703,14 +2703,16 @@
"version": "5.22.0", "version": "5.22.0",
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.22.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.22.0.tgz",
"integrity": "sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ==", "integrity": "sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ==",
"devOptional": true "optional": true,
"peer": true
}, },
"node_modules/@prisma/engines": { "node_modules/@prisma/engines": {
"version": "5.22.0", "version": "5.22.0",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.22.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.22.0.tgz",
"integrity": "sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==", "integrity": "sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==",
"devOptional": true,
"hasInstallScript": true, "hasInstallScript": true,
"optional": true,
"peer": true,
"dependencies": { "dependencies": {
"@prisma/debug": "5.22.0", "@prisma/debug": "5.22.0",
"@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2",
@@ -2722,13 +2724,15 @@
"version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", "version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz",
"integrity": "sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ==", "integrity": "sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ==",
"devOptional": true "optional": true,
"peer": true
}, },
"node_modules/@prisma/fetch-engine": { "node_modules/@prisma/fetch-engine": {
"version": "5.22.0", "version": "5.22.0",
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz",
"integrity": "sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==", "integrity": "sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==",
"devOptional": true, "optional": true,
"peer": true,
"dependencies": { "dependencies": {
"@prisma/debug": "5.22.0", "@prisma/debug": "5.22.0",
"@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2",
@@ -2739,7 +2743,8 @@
"version": "5.22.0", "version": "5.22.0",
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.22.0.tgz", "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.22.0.tgz",
"integrity": "sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q==", "integrity": "sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q==",
"devOptional": true, "optional": true,
"peer": true,
"dependencies": { "dependencies": {
"@prisma/debug": "5.22.0" "@prisma/debug": "5.22.0"
} }
@@ -8305,8 +8310,9 @@
"version": "5.22.0", "version": "5.22.0",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz", "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz",
"integrity": "sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A==", "integrity": "sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A==",
"devOptional": true,
"hasInstallScript": true, "hasInstallScript": true,
"optional": true,
"peer": true,
"dependencies": { "dependencies": {
"@prisma/engines": "5.22.0" "@prisma/engines": "5.22.0"
}, },

View File

@@ -0,0 +1,103 @@
// components/UserRegistration.js
import { useState } from 'react';
import { useToast } from '@chakra-ui/react';
import {
FormControl,
FormLabel,
Input,
Button,
Stack,
Heading,
} from '@chakra-ui/react';
import { drizzle } from 'drizzle-orm';
export default function UserRegistration() {
const [formData, setFormData] = useState({
username: '',
email: '',
password: '',
});
const toast = useToast();
const handleChange = (e) => {
const { name, value } = e.target;
setFormData({ ...formData, [name]: value });
};
const handleSubmit = async (e) => {
e.preventDefault();
// Example of database interaction using drizzle-orm:
const db = drizzle(/* your database connection logic */);
try {
// Replace 'users' with your actual table name
await db.insert('users').values(formData);
toast({
title: 'Account created.',
description: "We've created your account successfully!",
status: 'success',
duration: 5000,
isClosable: true,
});
// Reset the form
setFormData({ username: '', email: '', password: '' });
} catch (error) {
toast({
title: 'An error occurred.',
description: error.message,
status: 'error',
duration: 5000,
isClosable: true,
});
}
};
return (
<Stack spacing={4} w="400px" mx="auto" mt={10}>
<Heading as="h2" size="lg">User Registration</Heading>
<form onSubmit={handleSubmit}>
<FormControl isRequired>
<FormLabel>Username</FormLabel>
<Input
name="username"
value={formData.username}
onChange={handleChange}
placeholder="Enter your username"
/>
</FormControl>
<FormControl isRequired>
<FormLabel>Email</FormLabel>
<Input
type="email"
name="email"
value={formData.email}
onChange={handleChange}
placeholder="Enter your email"
/>
</FormControl>
<FormControl isRequired>
<FormLabel>Password</FormLabel>
<Input
type="password"
name="password"
value={formData.password}
onChange={handleChange}
placeholder="Enter your password"
/>
</FormControl>
<Button
mt={4}
colorScheme="teal"
type="submit">
Create Account
</Button>
</form>
</Stack>
);
}

View File

@@ -1,4 +1,4 @@
import { pgTable, integer, varchar, timestamp, text, numeric, unique, foreignKey, doublePrecision } from "drizzle-orm/pg-core" import { pgTable, integer, varchar, timestamp, text, numeric, unique, foreignKey, doublePrecision, real } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm" import { sql } from "drizzle-orm"
@@ -75,7 +75,7 @@ export const balAccounts = pgTable("bal_accounts", {
email: varchar({ length: 100 }), email: varchar({ length: 100 }),
username: varchar({ length: 50 }).notNull(), username: varchar({ length: 50 }).notNull(),
passwordHash: varchar("password_hash", { length: 255 }).notNull(), passwordHash: varchar("password_hash", { length: 255 }).notNull(),
}, (self) => { }, (table) => {
return { return {
balAccountsUsernameUnique: unique("bal_accounts_username_unique").on(table.username), balAccountsUsernameUnique: unique("bal_accounts_username_unique").on(table.username),
balAccountsPasswordHashUnique: unique("bal_accounts_password_hash_unique").on(table.passwordHash), balAccountsPasswordHashUnique: unique("bal_accounts_password_hash_unique").on(table.passwordHash),
@@ -202,3 +202,35 @@ export const balResellers = pgTable("bal_resellers", {
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(), createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
deletedAt: timestamp("deleted_at", { mode: 'string' }), deletedAt: timestamp("deleted_at", { mode: 'string' }),
}); });
export const psa = pgTable("psa", {
sku: varchar("SKU", { length: 50 }),
manufacturerId: varchar("Manufacturer Id", { length: 50 }),
brandName: varchar("Brand Name", { length: 50 }),
productName: varchar("Product Name", { length: 256 }),
longDescription: text("Long Description"),
shortDescription: varchar("Short Description", { length: 50 }),
department: varchar("Department", { length: 50 }),
category: varchar("Category", { length: 50 }),
subCategory: varchar("SubCategory", { length: 50 }),
thumbUrl: varchar("Thumb URL", { length: 150 }),
imageUrl: varchar("Image URL", { length: 150 }),
buyLink: varchar("Buy Link", { length: 128 }),
keywords: varchar("Keywords", { length: 50 }),
reviews: varchar("Reviews", { length: 50 }),
retailPrice: real("Retail Price"),
salePrice: real("Sale Price"),
brandPageLink: varchar("Brand Page Link", { length: 50 }),
brandLogoImage: varchar("Brand Logo Image", { length: 50 }),
productPageViewTracking: varchar("Product Page View Tracking", { length: 256 }),
parentGroupId: varchar("Parent Group ID", { length: 50 }),
fineline: varchar("Fineline", { length: 50 }),
superFineline: varchar("SuperFineline", { length: 250 }),
modelNumber: varchar("ModelNumber", { length: 50 }),
caliber: varchar("Caliber", { length: 255 }),
upc: varchar("UPC", { length: 75 }),
mediumImageUrl: varchar("Medium Image URL", { length: 50 }),
productContentWidget: varchar("Product Content Widget", { length: 256 }),
googleCategorization: varchar("Google Categorization", { length: 50 }),
itemBasedCommission: varchar("Item Based Commission", { length: 50 }),
});

10
src/pages/register.tsx Normal file
View File

@@ -0,0 +1,10 @@
// pages/register.js
import UserRegistration from '../components/UserRegistration';
export default function Register() {
return (
<div>
<UserRegistration />
</div>
);
}