Skip to content

Commit a3d3d5d

Browse files
committed
feat(profile): add support for uploading user config
1 parent 6eac280 commit a3d3d5d

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

src/app/(default)/u/setting/profile/page.tsx

+21-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import {
1616
import {Form, useForm} from "@mantine/form";
1717
import {useState} from "react";
1818
import {notifications} from "@mantine/notifications";
19+
import {UserConfigUploadParam} from "@/server/types";
20+
import {UserApi} from "@/server/UserApi";
21+
import {AppWrite} from "@/server/Client";
1922

2023
export default function SettingProfile() {
2124
const user = useUserContext();
@@ -31,6 +34,7 @@ export default function SettingProfile() {
3134
timezone: dash?.user.timezone || "",
3235
},
3336
})
37+
const api = new UserApi();
3438
const combobox = useCombobox({
3539
onDropdownClose: () => combobox.resetSelectedOption(),
3640
onDropdownOpen: () => combobox.updateSelectedOptionIndex('active'),
@@ -104,7 +108,7 @@ export default function SettingProfile() {
104108
return;
105109
}
106110

107-
const payload = {
111+
const payload:UserConfigUploadParam = {
108112
name: value.name,
109113
email: value.email,
110114
description: value.description,
@@ -114,7 +118,22 @@ export default function SettingProfile() {
114118
timezone: value.timezone,
115119
topic: Topics,
116120
};
117-
console.log(payload);
121+
api.UploadConfig(payload).then((res)=>{
122+
if (res.status === 200 && res.data){
123+
const app:AppWrite<string> = JSON.parse(res.data);
124+
if (app.code === 200 ){
125+
notifications.show({
126+
title: "Upload Success",
127+
message: "Upload Success",
128+
icon: <i className="iconfont icon-success"></i>,
129+
color: "green",
130+
});
131+
setTimeout(()=>{
132+
window.location.reload()
133+
}, 1000)
134+
}
135+
}
136+
});
118137
}
119138
return(
120139
<div className="user-setting-profile">

src/server/types.ts

+46-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface CommitModel {
7373
author: string;
7474
email: string;
7575
message: string;
76-
time: string;
76+
time: number;
7777
status: string;
7878
runner: string[];
7979
}
@@ -241,4 +241,48 @@ export interface SSHKeyModel {
241241
description?: string;
242242
created_at: DateTime;
243243
updated_at: DateTime;
244-
}
244+
}
245+
246+
247+
export interface UserConfigUploadParam {
248+
name?: string;
249+
description?: string;
250+
email?: string;
251+
location?: string;
252+
website?: string;
253+
timezone?: string;
254+
language?: string;
255+
topic: string[];
256+
}
257+
258+
export interface ProductListParam {
259+
page: number;
260+
limit: number;
261+
order: string;
262+
search?: string;
263+
}
264+
265+
export interface DataProductModel {
266+
uid: string;
267+
name: string;
268+
description?: string;
269+
hash: string;
270+
size: number;
271+
owner: string;
272+
repository_uid: string;
273+
type: string;
274+
license: string;
275+
price?: number;
276+
created_at: DateTime;
277+
updated_at: DateTime;
278+
}
279+
280+
export interface DataProductPostParam {
281+
name: string;
282+
description?: string;
283+
license: string;
284+
price?: number;
285+
hash: string;
286+
type: string;
287+
}
288+

src/style/repo.css

+16
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,20 @@
175175
font-size: 1rem;
176176
}
177177
}
178+
}
179+
180+
.post {
181+
position: absolute;
182+
display: flex;
183+
flex-direction: column;
184+
gap: 1rem;
185+
width: 50%;
186+
left: 50%;
187+
transform: translateX(-50%);
188+
#LayoutModelRepositoryPOST {
189+
display: flex;
190+
flex-direction: column;
191+
gap: 1rem;
192+
193+
}
178194
}

0 commit comments

Comments
 (0)