Added search support for filename on seond printfile.

This commit is contained in:
Vegard Fladby 2026-01-17 11:32:06 +01:00
parent 3a1f84435f
commit c45c3638aa
3 changed files with 9 additions and 6 deletions

View file

@ -35,5 +35,6 @@ COPY --from=build /app/web/dist /app/web/dist
EXPOSE 4000
WORKDIR /app/server
STOPSIGNAL SIGTERM
RUN chmod +x /app/server/entrypoint.sh
CMD ["/bin/sh", "/app/server/entrypoint.sh"]

View file

@ -17,4 +17,4 @@ if [ -n "$DATABASE_URL" ]; then
fi
echo "Starting server..."
node dist/index.js
exec node dist/index.js

View file

@ -463,15 +463,15 @@ function MappingRow({
const [suggestMessage, setSuggestMessage] = useState<string | null>(null);
const [suggested, setSuggested] = useState<FileItem[]>([]);
const [selectedSuggestion, setSelectedSuggestion] = useState<string>("");
const [activeSearch, setActiveSearch] = useState<string>("");
useEffect(() => {
setFileNames(getMappingFiles(current));
}, [current?.simplyprintFileName, current?.simplyprintFileNames]);
useEffect(() => {
const searchValue =
fileNames.find((name: string) => name.trim().length > 0) ?? "";
if (!searchValue.trim()) {
const searchValue = activeSearch.trim();
if (!searchValue) {
setFiles([]);
return;
}
@ -479,7 +479,7 @@ function MappingRow({
const handle = window.setTimeout(async () => {
try {
const result = await fetchJson<{ files: FileItem[] }>(
`/api/simplyprint/files?search=${encodeURIComponent(searchValue.trim())}`
`/api/simplyprint/files?search=${encodeURIComponent(searchValue)}`
);
setFiles(result.files.slice(0, 8));
} catch (error) {
@ -488,7 +488,7 @@ function MappingRow({
}, 300);
return () => window.clearTimeout(handle);
}, [fileNames]);
}, [activeSearch]);
useEffect(() => {
if (selectedSuggestion) {
@ -565,6 +565,7 @@ function MappingRow({
next[index] = value;
return next;
});
setActiveSearch(value);
};
const addFileInput = () => {
@ -590,6 +591,7 @@ function MappingRow({
<input
list={`files-${productId}-${variantId ?? "product"}`}
value={name}
onFocus={() => setActiveSearch(name)}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
updateFileName(index, event.target.value)
}