Is it possible to use Leaflet.js in a way that makes it robust enough to incorporate or replicate the functionalities of other mapping platforms like Google Maps, Mapbox, or OpenLayers?
Category: javascript
Category Added in a WPeMatico Campaign
how to prevent overlapping on the same workstation in a gantt schedule?
I m making a gantt scheduler app web dev .. I m a noob
the app is now generating schedules following the sequence order and the parallel scheduling but i failed to prevent it from making 2 operations on the same workstation overlap , i want to make the 2nd operation to start when the other operation ends in case they overlap .. also failed to use react drag and drop properly but i can just do toggle buttons .. it is the overlap that i want to deal with
i tried libraries, asynch calculators , new files for the purpose of dealing with overlap but nothing seemed to work for me
Create a background effect with css and js [closed]
I have been inspired by a website background effect and I really want to create it for my html website, the website is built on wordpress and it uses owl-carousel as per my knowledge. How can I achieve this same effect in html css code or if there is any library i could use? following is the website used. However, I have done some coding stuff but I am nowhere close to it.
Reference website : https://demo.artureanec.com/themes/agencium/
My code :
<div class="abc">
<div class="container">
<div class="row">
<div class="col-lg-12">
<!-- Add your content for this section here -->
<h1>Animated Background Section</h1>
<p>This section has an animated gradient background.</p>
</div>
</div>
</div>
</div>
.technology-item {
padding: 20px;
border: 1px solid #eeeeee; /* Light grey border */
border-radius: 8px; /* Rounded corners */
transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
background-color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 160px; /* Ensure consistent height */
box-sizing: border-box;
}
.tech-icon {
margin-bottom: 15px;
overflow: hidden;
}
.tech-icon img {
max-width: 50px; /* Smaller icon size */
max-height: 50px; /* Smaller icon size */
transition: transform 0.3s ease-in-out;
display: block;
margin: 0 auto;
}
.technology-item:hover {
box-shadow: 0 4px 15px rgba(0,0,0,0.1); /* Subtle shadow on hover */
}
.technology-item:hover .tech-icon img {
transform: scale(1.15); /* Zoom effect on icon */
}
.tech-name {
font-size: 14px;
color: #333333;
margin-top: auto; /* Pushes name to bottom */
text-align: center;
}
/* Designing Success Section Styles */
.designing-success-area {
position: relative; /* Needed for pseudo-element background */
background-color: #f8f9fa; /* Light grey background as fallback or base */
}
.designing-success-area::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 40%; /* Adjust width of the map background */
background-image: url('../img/bg/world-map-dots.png'); /* Path to your dotted world map image */
background-repeat: no-repeat;
background-position: center right;
background-size: contain; /* Or cover, depending on the map image */
opacity: 0.5; /* Adjust opacity as needed */
z-index: 1;
}
.designing-success-area .container {
position: relative; /* Ensure container content is above the pseudo-element */
z-index: 2;
}
.stat-item {
background-color: #ffffff;
padding: 30px 20px;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease-in-out;
height: 100%; /* Ensure all items have the same height */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.stat-item .stat-icon-wrapper {
width: 70px;
height: 70px;
border-radius: 50%;
background-color: #e9f5ff; /* Light blue background for icon */
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
color: #007bff; /* Icon color */
}
.stat-item .stat-number {
font-size: 36px;
font-weight: 700;
color: #1a294d;
margin-bottom: 5px;
}
.stat-item .stat-label {
font-size: 16px;
color: #555;
margin-bottom: 0;
}
.stat-item:hover,
.stat-item.highlighted { /* Added .highlighted for the specific item */
background-color: #ffffff;
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
border: 1px solid #dee2e6; /* Border for hover/highlighted state */
}
.stat-item.highlighted .stat-icon-wrapper {
background-color: #d4ebff; /* Slightly darker blue for highlighted icon wrapper */
}
/* Ensure FontAwesome is linked in your HTML or imported if using a framework */
/* Temporary Debug Styles for .abc */
.abc {
position: relative;
overflow: hidden; /* Keep overflow hidden */
background-color: red; /* Brightly visible background */
color: lime; /* Brightly visible text */
padding: 50px;
text-align: center;
min-height: 300px; /* Ensure it has some height */
/* Simple mask: left half transparent, right half opaque (black mask = opaque element) */
mask-image: linear-gradient(to right,
transparent 0%,
transparent 49.9%,
black 50%,
black 100%);
/* Forcing rgba for full clarity */
/* mask-image: linear-gradient(to right,
rgba(0,0,0,0) 0%,
rgba(0,0,0,0) 49.9%,
rgba(0,0,0,1) 50%,
rgba(0,0,0,1) 100%); */
/* Ensure no old mask properties interfere */
mask-repeat: no-repeat; /* Default is fine, but explicit */
mask-position: initial; /* Default is fine */
z-index: 1; /* Stays above pseudo-elements */
}
.abc::before,
.abc::after {
content: '';
position: absolute;
top: 50%; /* Centered vertically */
width: 80px; /* Smaller, fixed size */
height: 80px;
opacity: 1;
filter: none; /* No blur */
z-index: 0; /* Behind .abc content if mask fails, part of .abc for masking */
transform: translateY(-50%); /* Align center vertically */
/* Remove any animations for this test */
animation: none;
}
.abc::before {
background: blue;
left: 25%; /* Positioned in the left part */
}
.abc::after {
background: yellow;
left: 75%; /* Positioned in the right part */
transform: translate(-100%, -50%); /* Adjust because left: 75% is its starting point */
}
/* Remove old keyframes if they exist, or they'll be unused */
@keyframes flowLights1 {}
@keyframes flowLights2 {}
@keyframes rotateLights1 {}
@keyframes rotateLights2 {}
System Bug Fixes [closed]
Developing a system using HTML, PHP, MYSQL, CSS, Java Script.
Have encountered a few errors while testing it on localhost and not sure where the errors are thats not making it function
System files are CLICK HERE
a few areas to rectify
In the My Profile Section
- profile photo, guide on how to make a photo visible on the profile.
- country is not showing
- CV not uploading
- when i click “save changes” nothing is happening.
- on my profile add a place where users can enter their “hospital/institution”
- SFS Password data is missing and SFS username and SFS password should not be edited by users
in the Examiner Section
- Users Examiner number is not showing but is on the myqsl database
- the Role should not be selectable by user but set by the admin
- when confirming availability for the 2025 exams, and clicking save changes, nothing happens after that.
in the fellows section
- category, number, and year is not showing though it is on the mysql database.
- category, Fellow number, Year – these shouldnt be changed by the user, only admin can change.
- in this section users should only see their data and not make changes.
in brief the system is used for users to confirm participation for 2025 and if confirm either mcs or fcs or both, the marking sheets will be available (upon upload my my(admin) side)
once confirmed admin can toggle to generate a QR name tag for the user who confirm FCS which when scanned will add a check for attended FCS 2025
Fellows to see their annual subscription status and admin can toggle to confirm is paid for 2025
any assistance will be helpful to rectify the errors
Create a background effect with css and js
I have been inspired by a website background effect and I really want to create it for my html website, the website is built on wordpress and it uses owl-carousel as per my knowledge. How can I achieve this same effect in html css code or if there is any library i could use? following is the website used. However, I have done some coding stuff but I am nowhere close to it.
Reference website : https://demo.artureanec.com/themes/agencium/
My code :
<div class="abc">
<div class="container">
<div class="row">
<div class="col-lg-12">
<!-- Add your content for this section here -->
<h1>Animated Background Section</h1>
<p>This section has an animated gradient background.</p>
</div>
</div>
</div>
</div>
.technology-item {
padding: 20px;
border: 1px solid #eeeeee; /* Light grey border */
border-radius: 8px; /* Rounded corners */
transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
background-color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 160px; /* Ensure consistent height */
box-sizing: border-box;
}
.tech-icon {
margin-bottom: 15px;
overflow: hidden;
}
.tech-icon img {
max-width: 50px; /* Smaller icon size */
max-height: 50px; /* Smaller icon size */
transition: transform 0.3s ease-in-out;
display: block;
margin: 0 auto;
}
.technology-item:hover {
box-shadow: 0 4px 15px rgba(0,0,0,0.1); /* Subtle shadow on hover */
}
.technology-item:hover .tech-icon img {
transform: scale(1.15); /* Zoom effect on icon */
}
.tech-name {
font-size: 14px;
color: #333333;
margin-top: auto; /* Pushes name to bottom */
text-align: center;
}
/* Designing Success Section Styles */
.designing-success-area {
position: relative; /* Needed for pseudo-element background */
background-color: #f8f9fa; /* Light grey background as fallback or base */
}
.designing-success-area::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 40%; /* Adjust width of the map background */
background-image: url('../img/bg/world-map-dots.png'); /* Path to your dotted world map image */
background-repeat: no-repeat;
background-position: center right;
background-size: contain; /* Or cover, depending on the map image */
opacity: 0.5; /* Adjust opacity as needed */
z-index: 1;
}
.designing-success-area .container {
position: relative; /* Ensure container content is above the pseudo-element */
z-index: 2;
}
.stat-item {
background-color: #ffffff;
padding: 30px 20px;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease-in-out;
height: 100%; /* Ensure all items have the same height */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.stat-item .stat-icon-wrapper {
width: 70px;
height: 70px;
border-radius: 50%;
background-color: #e9f5ff; /* Light blue background for icon */
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
color: #007bff; /* Icon color */
}
.stat-item .stat-number {
font-size: 36px;
font-weight: 700;
color: #1a294d;
margin-bottom: 5px;
}
.stat-item .stat-label {
font-size: 16px;
color: #555;
margin-bottom: 0;
}
.stat-item:hover,
.stat-item.highlighted { /* Added .highlighted for the specific item */
background-color: #ffffff;
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
border: 1px solid #dee2e6; /* Border for hover/highlighted state */
}
.stat-item.highlighted .stat-icon-wrapper {
background-color: #d4ebff; /* Slightly darker blue for highlighted icon wrapper */
}
/* Ensure FontAwesome is linked in your HTML or imported if using a framework */
/* Temporary Debug Styles for .abc */
.abc {
position: relative;
overflow: hidden; /* Keep overflow hidden */
background-color: red; /* Brightly visible background */
color: lime; /* Brightly visible text */
padding: 50px;
text-align: center;
min-height: 300px; /* Ensure it has some height */
/* Simple mask: left half transparent, right half opaque (black mask = opaque element) */
mask-image: linear-gradient(to right,
transparent 0%,
transparent 49.9%,
black 50%,
black 100%);
/* Forcing rgba for full clarity */
/* mask-image: linear-gradient(to right,
rgba(0,0,0,0) 0%,
rgba(0,0,0,0) 49.9%,
rgba(0,0,0,1) 50%,
rgba(0,0,0,1) 100%); */
/* Ensure no old mask properties interfere */
mask-repeat: no-repeat; /* Default is fine, but explicit */
mask-position: initial; /* Default is fine */
z-index: 1; /* Stays above pseudo-elements */
}
.abc::before,
.abc::after {
content: '';
position: absolute;
top: 50%; /* Centered vertically */
width: 80px; /* Smaller, fixed size */
height: 80px;
opacity: 1;
filter: none; /* No blur */
z-index: 0; /* Behind .abc content if mask fails, part of .abc for masking */
transform: translateY(-50%); /* Align center vertically */
/* Remove any animations for this test */
animation: none;
}
.abc::before {
background: blue;
left: 25%; /* Positioned in the left part */
}
.abc::after {
background: yellow;
left: 75%; /* Positioned in the right part */
transform: translate(-100%, -50%); /* Adjust because left: 75% is its starting point */
}
/* Remove old keyframes if they exist, or they'll be unused */
@keyframes flowLights1 {}
@keyframes flowLights2 {}
@keyframes rotateLights1 {}
@keyframes rotateLights2 {}
C# Kendo Grid – cascading combo box with pre-loaded values
I have a .NET MVC app where I’m using Kendo grid. I have a form that a user can fill out and save it as a draft, then come back later and finish it. When I go to edit the form I saved as a draft, I want all of the combo boxes (including cascading ones) to auto-fill with the previously selected values. I’m able to do this fine with non-cascading combo boxes, and somewhat with cascading combo boxes, but the problem I’m having is that the displayed value in my cascading combo box is the value (an int ID) when I want it to display the text value (a string).
@(Html.Kendo().ComboBox()
.Name("ChildId") // Matches the column name
.DataTextField("Text")
.DataValueField("Value")
.CascadeFrom("ParentId") // Cascades based on ParentId
.CascadeOnPageLoadIfThereBeAValueInTheOtherCombo() // I'm looking for something like this
.DataSource(source => source
.Read(read => read.Action("GetChildData", "Home"))
)
.OptionLabel("Select Child")
)
I understand that the data does not get pulled into the cascading combo box normally until a selection is made from the dropdown box it cascades from, and if I’m just basing the Kendo combobox on an ID attribute it won’t know what text to display without getting the list items, but in this case a selection was already made previously so I want it to get that data immediately (on page load). Is there a way I can do it in JavaScript or call some Kendo method in C# that tells it to populate with the data immediately without waiting for the initial user interaction?
If I can at a minimum set the display text to what I want then that might be enough.
Managing window closing in a PWA
Is there anything other than beforeunload available to PWAs when the user closes an installed PWA application’s window? I’m building a desktop application that may have unsaved edits across multiple files and the flow would currently be:
- User clicks the close button
beforeunloadshows “You have unsaved changes. Click Cancel to choose what to save or OK to quit.”- If the user chooses cancel, an HTML-based dialogue is shown in the web application for each file with the standard <Yes> <No> <Cancel> <No to All> buttons
When the user clicks close, ideally I’d like only my HTML dialogue to be shown, but I’m curious to learn about what options exist.
How to preserve cursor-based infinite scroll data with Next.js Link component like tags?
Question
I’m facing an issue with Next.js Link component and cursor-based infinite scroll data preservation.
When using regular tags, the browser perfectly maintains the previous page state including all loaded infinite scroll data when clicking the back button. However, with Next.js Link component, it refetches the initial data instead of preserving the previously loaded data.
Current Behavior:
Using :
User loads Page A and scrolls down (loading items 1-60)
User clicks link to Page B
User clicks back button to Page A
Page A reloads and shows only initial items (1-20), losing previously loaded items
Using :
User loads Page A and scrolls down (loading items 1-60)
User clicks link to Page B
User clicks back button to Page A
Page A shows all previously loaded items (1-60) perfectly
What I’ve tried:
- Following Next.js official documentation recommendations:
According to Next.js Documentation, these props should help maintain page state:
shallow: Updates the path without running data fetching methods
scroll: Controls scrolling behavior to the top of the page
But it wasn’t implemented the way I wanted it to be.
Conclusition
- Next.js recommends using the Link tag, but there will be no problem using the tag in this case, right?
- If I use Link components, what do I do if I do what I want to implement?
Thank you
TipTaps/ProseMirror: The CustomNode (CustomImage) can not disable or configure to “openOnClick: false”
I tried to create an Img Tag and then I can wrap the a tag around it, I tried to create the custom node Call CustomImage, I try some code from Generative AI and tweak but hard to understand, now I want to prevent it to click on the edit when it has link on them, it like the Link.configure({openOnClick: false,}), but since this is the custom node it does not have the property. and it seems my CustomImage is so fragile and might be broke because I just make it work not ensuring it stability and reusability and pass all test case.
here the secnario
- when the image is idle it can be select and can be add the link
- when I added the link it have the link and be clickable
- but when I tried to edit the link on the editor it just prompt me to the link on the image it can not be change the link.
Due to limit of how much code I can share, here is the github link that have all the code github.com/mk-working/tiptap-question/tree/main , Thank you
Creating a histogram in MUI X Charts with a reference line
I am creating a histogram in MUI X Charts using a Bar Chart component. I do the binning separately using d3.
I’ll provide a minimal working example. Let’s say that I have
const freqs = [23, 103, 280, 540, 589, 417, 276, 113, 32, 4, 4, 8, 2, 1]
const thresholds = [0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8]
and that I create my “histogram” as follows.
<BarChart
xAxis={[
{
data: thresholds,
scaleType: 'band',
categoryGapRatio: 0,
tickPlacement: 'end',
tickLabelPlacement: 'tick'
}
]}
series={[
{
data: freqs,
type: 'bar'
}
]}
/>
See the output here: histogram
I now want to set a reference line at x=0.7. I try to do this as follows:
<ChartContainer
xAxis={[
{
data: labels,
scaleType: 'band',
categoryGapRatio: 0,
tickPlacement: 'end',
tickLabelPlacement: 'tick'
}
]}
series={[
{
data: freqs,
type: 'bar'
}
]}
>
{/* Bars */}
<BarPlot />
{/* Standard chart extras */}
<ChartsXAxis />
<ChartsYAxis />
<ChartsTooltip />
{/* Reference line */}
<ChartsReferenceLine
x={0.7}
/>
</ChartContainer>
The problem is that my scaleType is not continuous, so I don’t get the desired output.
I can set x={0.8} and get a line, as shown in histogram with line. Note that it looks like it’s at x=0.6 because of the tick placement, but that’s something that I can deal with.
What can I do to achieve the desired behaviour?. The data is dynamic and will be constantly changing, so I would like to avoid hard-coding the thresholds.
Form Ajax Post, cannot access form request data
I have the following simple form and I am posting the form as JSON object, however, I can’t seem to be able to parse the json data on the API.
testing with the following two methods which both work and post the form content as json to the api, but I cant seem to be able to access the request data/body.
$( "#signupBtn" ).on( "click", function(event) {
event.preventDefault();
var formData = new FormData(document.getElementById('signup'))
$.ajax({
type: "POST",
url: "http://campaign.marktech.ltd:8080/mt/signup.jssp",
data: JSON.stringify(Object.fromEntries(formData)),
processData: false,
contentType: 'json',
error: function(jqXHR, textStatus, errorMessage) {
console.log(errorMessage);
},
success: function(data) {console.log(data)}
});
});
/* var form = document.getElementById('signup');
$( "#signupBtn" ).on( "click", function(event) {
var xhr = new XMLHttpRequest();
var formData = new FormData(form);
//open the request
xhr.open('POST', 'http://campaign.marktech.ltd:8080/mt/signup.jssp')
xhr.setRequestHeader("Content-Type", "application/json");
//send the form data
xhr.send(JSON.stringify(Object.fromEntries(formData)));
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
//form.reset(); //reset form after AJAX success or do something else
}
}
//Fail the onsubmit to avoid page refresh.
return false;
});
*/
and here is the bit of code the API returning a response after the post request is made
var response = {
'response':'apiHelo',
'Refererr':request.getHeader("referer"),
'data':JSON.stringify(request.body)
}
document.write(JSON.stringify(response));
Here is the request json
The form is making contact with the api, the api is responding but I am trying to process,parse, or return the request data/body and doesnt work. Ive tried request.data request.body and also stringified it, to no avail. My goal is to return the request data back to the form for my testing, then I can be sure that I am accessing it correctly on the API and begin storing it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>martech.network</title>
<link rel="icon" href="https://martech.network/favicon.ico" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4Q6Gf2aSP4eDXB8Miphtr37CMZZQ5oXLH2yaXMJ2w8e2ZtHTl7GptT4jmndRuHDT" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-j1CDi7MgGQ12Z7Qab0qlWQ/Qqz24Gc6BM0thvEMVjHnfYGF0rmFCozFSxQBxwHKO" crossorigin="anonymous"></script>
<!--<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>-->
</head>
<body>
<div class="container px-5 my-5">
<form id="signup">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" id="signupBtn" value="Submit">
</form>
</div>
<script type="text/javascript">
$( "#signupBtn" ).on( "click", function(event) {
event.preventDefault();
var formData = new FormData(document.getElementById('signup'))
$.ajax({
type: "POST",
url: "http://campaign.marktech.ltd:8080/mt/signup.jssp",
data: JSON.stringify(Object.fromEntries(formData)),
processData: false,
contentType: 'json',
error: function(jqXHR, textStatus, errorMessage) {
console.log(errorMessage);
},
success: function(data) {console.log(data)}
});
});
/* var form = document.getElementById('signup');
$( "#signupBtn" ).on( "click", function(event) {
var xhr = new XMLHttpRequest();
var formData = new FormData(form);
//open the request
xhr.open('POST', 'http://campaign.marktech.ltd:8080/mt/signup.jssp')
xhr.setRequestHeader("Content-Type", "application/json");
//send the form data
xhr.send(JSON.stringify(Object.fromEntries(formData)));
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
//form.reset(); //reset form after AJAX success or do something else
}
}
//Fail the onsubmit to avoid page refresh.
return false;
});
*/
</script>
</body>
</html>
Set iFrame Height Based on Today’s Date
I have a dozen iframes displaying content on the same WordPress page, but I want to set the iframe height to zero if a specified date for each iframe is less than the current date. Each iframe contains date sensitive content that I want to hide until specified dates. I have seen script that assigns a height to a variable, but I don’t know how to assign that variable to the frame height.
What I’m trying to do is set height= h.
Any help is appreciated.
<iframe width="694" height="666" frameborder="0" scrolling="no"
src="https://docs.google.com/spreadsheets/...
</iframe>
I am trying to incorporate this script logic into the HTML:
script>
var end = new Date('2025-05-21');
var now = new Date();
if (end - now <= 0) {
var h = "0";
} else {
var h = "666";
}
</script>
How do I access other’s public user data from my Vite+React front end? I’m using Clerk
I am trying to access public user data from my Vite+React front end, but I need other users’ data. I do have a PHP back end, but the library for getting the data is broken. ChatGPT refuses to give me help besides telling me to use the broken library. Here is my current PHP file for fetching user data, and my React component that displays the data.
<?php
declare(strict_types=1);
require_once __DIR__ . "vendor/autoload.php";
include "env-variables.php";
use ClerkBackendClerkBackend;
header("Content-Type: application/json");
$clerkSecret = $env["clerk_secret"] ?? null;
if (!$clerkSecret) {
http_response_code(500);
echo json_encode(["error" => "Clerk secret key is not set."]);
exit;
}
$userId = $_GET["id"] ?? null;
if (!$userId) {
http_response_code(400);
echo json_encode(["error" => "Missing user ID."]);
exit;
}
try {
$clerk = ClerkBackend::builder()
->setSecurity($clerkSecret)
->build();
$response = $clerk->users->get($userId);
if ($response->statusCode !== 200 || $response->user == null) {
http_response_code($response->statusCode);
echo json_encode(["error" => "Failed to retrieve user data."]);
exit;
}
$user = $response->user;
$publicData = [
"id" => $user->id,
"first_name" => $user->firstName,
"last_name" => $user->lastName,
"image_url" => $user->imageUrl,
];
echo json_encode($publicData);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(["error" => "An error occurred.", "details" => $e->getMessage()]);
}
import { useEffect, useState } from "react"
import type Post from "../types/post"
import { useClerk } from "@clerk/clerk-react"
function formatDate(dateString: string): string {
const date = new Date(dateString)
return date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
hour: "numeric",
minute: "2-digit",
})
}
interface PostCardProps {
post: Post
isLink: boolean
}
export default function PostCard({ post, isLink, }: PostCardProps) {
const clerk = useClerk()
const [user, setUser] = useState<any>(null)
useEffect(() => {
async function fetchUser() {
const fetchedUserRes = await fetch(`/api/get-user.php?id=${post.userid}`)
const fetchedUser = await fetchedUserRes.json()
setUser(fetchedUser)
}
fetchUser()
}, [post, clerk])
const element = <>
<h2>{post.title}</h2>
<div className="flex items-center gap-[.5rem]">
<img src={user?.image_url} alt="#" />
<span>{user?.username ?? user?.firstname ?? user?.email ?? "Anonymous"}</span>
</div>
<div className="ml-[1rem]">{post.text.split("n").map((line: string) => <p>{line}</p>)}</div>
<span className="my-[.5rem] text-foreground-2 text-sm">Posted {formatDate(post.created_at)}</span>
</>
return isLink ?
<a href={`/post.php?id=${post.id}`} className="override-typography flex flex-col p-[1rem] bg-theme border-[.2rem] border-foreground-2 rounded-[.5rem]">
{element}
</a>
: <div className="flex flex-col p-[1rem] bg-theme border-[.2rem] border-foreground-2 rounded-[.5rem]">
{element}
</div>
}
Como consigo corrigir este problema ao tentar criar uma tela de login no meu aplicativo React Native? Estou utilizando os email e senha do firebase [closed]
ERROR Error: Component auth has not been registered yet, js engine: hermes
WARN Route “./index.js” is missing the required default export. Ensure a React component is exported as default.
FormData HTTP request sent by Angular is not readable by Spring backend
I am sending a File in a POST request using Angular. I use standard HttpClient and set the payload as FormData in order to send multipart/form-data:
const url = '...';
const formData = new FormData();
formData.append('file', file); // file is type File
this.httpClient.post(url, formData);
Since I don’t override Content-Type header, Angular creates it for me, together with the multipart ‘boundary’. That can be seen by copying the request as cURL in Chrome Dev tools:
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary0jzgUXpnrXuu4Fjt'
However, the same cURL request shows, after all the headers (-H), a row that begins with --data-raw:
--data-raw $'------WebKitFormBoundary0jzgUXpnrXuu4Fjtrn...
Allegedly that --data-raw is not compatible with what the backend is expecting to read and is causing the request to fail when read.
When doing the request from Postman, setting the same form-data format with a File, the cURL request shows a different row after the headers, beginning with --form:
--form 'file=@"/path_to_file/file_name.ext"'
What else could I set to the request so that Angular sends it with --form instead of --data-raw so that the Spring backend could read it?

