This commit is contained in:
zadit
2024-12-27 08:02:11 +07:00
parent cf38edac85
commit 675f4f2c42
13 changed files with 168 additions and 72 deletions

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { createClerks } from '../helpers/userHelpers'; // Adjust the import path as needed
import { useLocation } from "react-router-dom";
const CreateClerk = ({ shopId }) => {
const [username, setUsername] = useState('');
@@ -7,6 +8,11 @@ const CreateClerk = ({ shopId }) => {
const [loading, setLoading] = useState(false);
const [message, setMessage] = useState('');
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const cafeIdParam = queryParams.get("cafeId");
const handleSubmit = async (event) => {
event.preventDefault();
setLoading(true);
@@ -20,7 +26,7 @@ const CreateClerk = ({ shopId }) => {
}
try {
const create = await createClerks(shopId, username, password);
const create = await createClerks(shopId || cafeIdParam, username, password);
if (create) setMessage('Clerk created successfully');
else setMessage('Failed to create clerk');