This commit is contained in:
zadit
2024-12-26 08:58:59 +07:00
parent c6d7ed5aae
commit cf38edac85
17 changed files with 259 additions and 167 deletions

View File

@@ -1,7 +1,8 @@
import React, { useState } from 'react';
import { createClerks } from '../helpers/userHelpers'; // Adjust the import path as needed
import { createCafeOwner } from '../helpers/userHelpers'; // Adjust the import path as needed
const CreateClerk = ({ shopId }) => {
const CreateClerk = () => {
const [email, setEmail] = useState('');
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
@@ -20,7 +21,7 @@ const CreateClerk = ({ shopId }) => {
}
try {
const create = await createClerks(shopId, username, password);
const create = await createCafeOwner(email, username, password);
if (create) setMessage('Clerk created successfully');
else setMessage('Failed to create clerk');
@@ -33,8 +34,15 @@ const CreateClerk = ({ shopId }) => {
return (
<div style={styles.container}>
<h2 style={styles.header}>Tambah Kedai</h2>
<h2 style={styles.header}>Tambah Tenant</h2>
<form onSubmit={handleSubmit} style={styles.form}>
<input
type="text"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
style={styles.input}
/>
<input
type="text"
placeholder="Username"
@@ -50,7 +58,7 @@ const CreateClerk = ({ shopId }) => {
style={styles.input}
/>
<button type="submit" style={styles.button} disabled={loading}>
{loading ? 'Creating...' : 'Create Clerk'}
{loading ? 'Creating...' : 'Create Tenant'}
</button>
{message && (
<p style={{ ...styles.message, color: message.includes('success') ? 'green' : 'red' }}>