done create credentials

This commit is contained in:
2026-02-28 20:52:41 +08:00
parent 832e5de433
commit da64ef2255
2 changed files with 47 additions and 26 deletions

View File

@@ -5,22 +5,30 @@ import globalStyle from "../../globalStyle.module.css";
import createCredStyle from "./styles.module.css"; import createCredStyle from "./styles.module.css";
import TopToolTip from "@/app/components/topToolTip/TopToolTip"; import TopToolTip from "@/app/components/topToolTip/TopToolTip";
import TextField from "@/app/components/fields/textfield"; import TextField from "@/app/components/fields/textfield";
import Prompts from "@/app/components/prompts/Prompts";
const Page = () => { const Page = () => {
const fileInputRef = useRef(null); const [selectedFile, setSelectedFile] = useState(null);
const [fileName, setFileName] = useState(""); // Click
const handleClick = () => {
fileInputRef.current.click();
};
const handleFileChange = (e) => { const handleFileChange = (e) => {
const file = e.target.files[0]; const file = e.target.files[0];
if (file) { if (file) {
setFileName(file.name); setSelectedFile(file);
console.log(file); // you can send this to backend later console.log(file); //send this to backend later
} }
}; };
// Drag/Drop
const handleDrop = (e) => {
e.preventDefault();
const file = e.dataTransfer.files[0];
if (file) {
setSelectedFile(file);
}
};
const handleDragOver = (e) => {
e.preventDefault();
};
return ( return (
<div className={globalStyle.section}> <div className={globalStyle.section}>
<div className={globalStyle.mainContainer}> <div className={globalStyle.mainContainer}>
@@ -44,6 +52,7 @@ const Page = () => {
{/* Content */} {/* Content */}
<div className={createCredStyle.credInputField}> <div className={createCredStyle.credInputField}>
<TextField placeHolder="Enter Credential Name" /> <TextField placeHolder="Enter Credential Name" />
<Prompts show={false} />
</div> </div>
</div> </div>
{/* Upload File */} {/* Upload File */}
@@ -51,24 +60,25 @@ const Page = () => {
{/* Label */} {/* Label */}
<div className={createCredStyle.label}> <div className={createCredStyle.label}>
<p>Upload File</p> <p>Upload File</p>
{/* Optional or Required */}
{/* <p className={createCredStyle.optionalTxt}>(Optional)</p> */}{" "}
</div> </div>
{/* Upload File */}
{/* Hidden File Input */} <label
className={createCredStyle.upload}
onDragOver={handleDragOver}
onDrop={handleDrop}
>
<input <input
type="file" type="file"
ref={fileInputRef}
onChange={handleFileChange} onChange={handleFileChange}
style={{ display: "none" }} style={{ display: "none" }}
/> />
{selectedFile ? (
{/* Custom Upload Box */} <p className={createCredStyle.chooseTxt}>
<div {/* Display file name only */}
className={createCredStyle.upload} {selectedFile.name}
onClick={handleClick} </p>
style={{ cursor: "pointer" }}
>
{fileName ? (
<p>{fileName}</p>
) : ( ) : (
<> <>
<p className={createCredStyle.chooseTxt}> <p className={createCredStyle.chooseTxt}>
@@ -79,7 +89,7 @@ const Page = () => {
</p> </p>
</> </>
)} )}
</div> </label>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -77,8 +77,18 @@
align-self: stretch; align-self: stretch;
border-radius: 4px; border-radius: 4px;
border: 1px dashed #5980f1; border: 1px dashed #5980f1;
border: 1px dashed color(display-p3 0.3804 0.4959 0.9137); border: 2px dashed color(display-p3 0.3804 0.4959 0.9137);
cursor: pointer;
} }
.upload:hover {
background: rgba(129, 135, 255, 0.25);
background: color(display-p3 0.5098 0.5294 1 / 0.25);
}
.upload:hover .chooseTxt {
color: #fff;
color: color(display-p3 1 1 1);
}
.chooseTxt { .chooseTxt {
color: #5980f1; color: #5980f1;
color: color(display-p3 0.3804 0.4959 0.9137); color: color(display-p3 0.3804 0.4959 0.9137);
@@ -90,6 +100,7 @@
line-height: normal; line-height: normal;
align-self: stretch; align-self: stretch;
} }
.dragTxt { .dragTxt {
color: #85869b; color: #85869b;
color: color(display-p3 0.5216 0.5255 0.6); color: color(display-p3 0.5216 0.5255 0.6);