Skip to content

Commit

Permalink
Merge branch 'fix_admin_dash' into dev-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
srukelman committed May 6, 2024
2 parents a9cc91c + 0abe5fc commit 2881c29
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
25 changes: 14 additions & 11 deletions src/components/DonationForm/DonationForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const DonationForm = () => {
const navigate = useNavigate();

const [businessId, setBusinessId] = useState(null);
const FPH_ID = 0;
const [businessName, setBusinessName] = useState('');

const [formData, setFormData] = useState({
business_id: businessId,
Expand All @@ -67,9 +69,12 @@ const DonationForm = () => {
} else {
try {
const businessIdResponse = await backend.get(`/businessUser/${currentUser.uid}`);
console.log(businessIdResponse)
const fetchedBusinessId = businessIdResponse.data[0].id;
setBusinessId(fetchedBusinessId);
setFormData(prevState => ({ ...prevState, business_id: fetchedBusinessId }));
const businessNameResponse = await backend.get(`/business/${fetchedBusinessId}`);
setBusinessName(businessNameResponse.data[0].name);
} catch (error) {
console.error('Error fetching business ID:', error);
}
Expand Down Expand Up @@ -99,20 +104,18 @@ const DonationForm = () => {
// DO TYPE IN THE DATABASE/CODE HERE, BUT THE DATA ASE DOES NOT SUPPORT SOMEONE HELP, CURRENTLY SHOWS AS TYPE:null

try {
await backend.post('/donation', formData);
console.log(formData);



const donation_data = await backend.post('/donation', formData);
const donationId = donation_data.data[0].donation_id;
console.log('Donation data:', donation_data.data[0]);
const fphNotificationData = {
businessId: businessId,
message: `Business ID: ${businessId} Donation Form Submission`,
timestamp: new Date().toLocaleString('en-US', {
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
}),
been_dismissed: false,
businessId: FPH_ID,
senderId: formData.business_id,
businessName,
donationId: donationId,
message: null,
type: 'Submitted Form',
};
console.log('Notification data:', fphNotificationData);
await backend.post('/notification', fphNotificationData);
} catch (error) {
console.error('Form submission failed:', error);
Expand Down
16 changes: 8 additions & 8 deletions src/components/ViewBusiness/ViewBusiness.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ const ViewBusiness = () => {
</Td>
<Td>
<Text fontSize="xs" color="500">
{data.primary_phone.replace(
{data.primary_phone && data.primary_phone.replace(
/(\d{3})(\d{3})(\d{4})/,
'$1-$2-$3',
)}
Expand Down Expand Up @@ -423,7 +423,7 @@ const ViewBusiness = () => {
Phone for FPOTH Website
</Text>
<Text fontSize="xs" color="500">
{data.fph_phone.replace(
{data.fph_phone && data.fph_phone.replace(
/(\d{3})(\d{3})(\d{4})/,
'$1-$2-$3',
)}
Expand Down Expand Up @@ -642,10 +642,10 @@ const ViewBusiness = () => {
</Box>
</Flex>
</Card>
<Card mt="6" ml="6" height="60%">
<Card mt="6" ml="6" maxHeight="58%">
<Flex direction="column" align="left" w="full">
<Box mt="6" ml="6" mb="4">
<Text fontSize="sm" mb="4" as="b" whiteSpace="normal">
<Box mt="6" ml="6" mb={0}>
<Text fontSize="sm" mb={0} as="b" whiteSpace="normal">
DONATION FORM HISTORY
</Text>
<CardBody pt="0" pl="0">
Expand All @@ -654,8 +654,8 @@ const ViewBusiness = () => {
{currentPageData.map((item, index) => (
<Box
key={index}
marginBottom="30px"
marginTop="30px"
marginBottom="20px"
marginTop="20px"
cursor="pointer"
color="gray.700"
fontWeight="600"
Expand All @@ -671,7 +671,7 @@ const ViewBusiness = () => {
</Box>
))}
</div>
<Box ml="90px">
<Box ml="90px" mt={-2} mb={-2}>
<Flex alignContent={'center'}>
<Box
sx={{
Expand Down

0 comments on commit 2881c29

Please sign in to comment.