wow you can upload shit such a great achievement good job amy

This commit is contained in:
amy 2024-12-03 20:18:14 +03:30
parent 3ac8b4790a
commit 23d05febfa
Signed by: amy
SSH key fingerprint: SHA256:Y6VEv6ZOxI6zqjjOF4luhfaCoY+zDK0w62P+qhQYie4
8 changed files with 128 additions and 32 deletions

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

30
.idea/workspace.xml generated
View file

@ -4,12 +4,28 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="4cc93404-63bf-4aee-bd04-2b0203a508b3" name="Changes" comment="" />
<list default="true" id="4cc93404-63bf-4aee-bd04-2b0203a508b3" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/app/helpers.tsx" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/app/main.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/app/images/upload/page.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/images/upload/page.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/app/page.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/page.tsx" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript JSX File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 1
}</component>
@ -21,7 +37,9 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "/home/exhq/codeshit/ether-frontend",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/home/exhq/codeshit/ether",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -48,6 +66,14 @@
<updated>1733164121833</updated>
<workItem from="1733164123211" duration="1350000" />
<workItem from="1733167273601" duration="2934000" />
<workItem from="1733173018210" duration="8000" />
<workItem from="1733181290940" duration="1456000" />
<workItem from="1733186553046" duration="4000" />
<workItem from="1733197339309" duration="581000" />
<workItem from="1733200504378" duration="23000" />
<workItem from="1733232865117" duration="6000" />
<workItem from="1733238983600" duration="81000" />
<workItem from="1733239451427" duration="4696000" />
</task>
<servers />
</component>

BIN
public/main.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

5
src/app/helpers.tsx Normal file
View file

@ -0,0 +1,5 @@
export const getCookie = (name:string) => {
const cookieString = document.cookie;
const cookies = cookieString.split('; ').find(row => row.startsWith(name + '='));
return cookies ? cookies.split('=')[1] : null;
};

View file

@ -1,17 +1,63 @@
"use client";
import "@radix-ui/themes/styles.css";
import {Button, Text, Theme} from "@radix-ui/themes";
import {useState} from "react";
import {getCookie} from "@/app/helpers";
export default function Page() {
const [file, setFile] = useState(null);
const [message, setMessage] = useState('');
const handleFileChange = (e: any) => {
setFile(e.target.files[0]);
};
const handleUpload = async () => {
if (!file) {
setMessage('Please select a file first.');
return;
}
const formData = new FormData();
formData.append('file', file);
let apikey = ""
await fetch('http://localhost:7070/api/token', {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-expect-error
headers: {
'Authorization': getCookie("access_token"),
}
}).then(res => res.json().then(data => {
console.log(data)
apikey = data.apiToken;
}));
try {
await fetch('http://localhost:7070/api/upload', {
method: 'POST',
body: formData,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-expect-error
headers: {
'Authorization': apikey,
}
}).then(res => res.json().then(data => console.log(data)));
} catch (error) {
console.log(error);
}
};
return (
<Theme appearance="dark">
<center>
<Text>
upload a file
</Text>
<br/>
<br/>
<input type="file" accept="image/*"/>
</center>
</Theme>
<div style={{padding: '20px', fontFamily: 'Arial, sans-serif'}}>
<h2>Upload a File</h2>
<input type="file" onChange={handleFileChange}/>
<button onClick={handleUpload} style={{marginLeft: '10px'}}>
Upload
</button>
{message && <p>{message}</p>}
</div>
);
}

14
src/app/main.css Normal file
View file

@ -0,0 +1,14 @@
.logo {
width: 200px;
}
.leftside{
float: left;
margin-top: 5em;
margin-left: 5em;
}
.textleft{
float: left;
margin-top: 5em;
margin-left: 5em;
}

View file

@ -1,26 +1,19 @@
import "./main.css"
import { cookies } from 'next/headers'
import "@radix-ui/themes/styles.css";
import {Avatar, Button, Heading, Text, Theme} from "@radix-ui/themes";
import {Text, Theme} from "@radix-ui/themes";
export default function Home() {
export default async function Home() {
console.log((await cookies()).get("access_token"))
return (
<Theme appearance="dark">
<center>
<Avatar
size="8"
src="https://pico.exhq.dev/-SvcHc7yBkT/pasted-2024-12-02T194552.569Z.png"
fallback="A"
/>
<Heading weight="bold" as="h1">tappo</Heading>
<br/>
<Heading as="h2">bunch o fucking services that already exist so many fucking places</Heading>
<br/>
<a href="https://google.com">
<Button color="crimson" variant="soft">
Login or something idfk
</Button>
</a>
</center>
<div className="leftside">
<img className="logo" src="./main.png" />
</div>
<div className="textleft">
<Text size="6">Tappo</Text>
<Text size="3">Tappo</Text>
</div>
</Theme>
);
}