Skip to content

Commit 2956e4b

Browse files
luo0602141017fu050409github-actions[bot]
authored
feat(WIP): init ui (#103)
* release: alpha (#61) * release: bump version (#63) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * fix(lint): fix code spell check * ci(release): remove `tailwindcss` building * fix(profile): fix profile problem panel (#65) * chore: fix aur release * release: bump version (#66) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * chore: fix code spell check * feat: add `NProgress` bar (#67) * feat: add n progress bar * chore: bump version * release: bump version (#68) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * chore: fix aur ssh known hosts * chore: fix version check * release: alpha releases (#62) * refactor(submit): enable code submission (#69) * release: bump version (#70) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * chore: try split aur release * chore: fix aur action * ci: add string in aur release * ci(release): retry to aur release * ci(release): fix covector ci * release: bump version (#72) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * revert(ci): revert aur release * refactor(asset): full rewrite asset logic (#73) * refactor(asset): full rewrite asset logic * release: bump version (#74) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * chore: fix aur release * release: bump version (#75) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat: optimize monaco editor error notification (#76) * release: bump version (#77) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * refactor(problem): sync changes with backend (#78) * release: bump version (#79) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat: optimize the code and add splash screen (#80) * release: bump version (#81) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * refactor: create problem page (#82) * refactor: create problem page * chore: fix code spell check * feat: optimize problem page (#84) * release: bump version (#83) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * fix(problem): fix markdown preview (#85) * release: bump version (#86) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat(register): support for birthday (#87) * feat(problem): support auto load submissions (#89) * feat(problem): support auto load submissions * chore: bump version * release: bump version (#88) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat(contest): support create contest (#90) * release: bump version (#91) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * fix: upload size limit (#92) * fix(signup): fix optional fields (#93) * release: bump version (#94) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat(contest): support for contest page (#95) * chore: prepare for beta release --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: fix ci branches * release: bump version (#96) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat(contest): support acc (#97) * feat(contest): support acc * chore: bump version * release: bump version (#98) chore: publish new versions Co-authored-by: fu050409 <46275354+fu050409@users.noreply.github.com> * feat(org): inrt ui * feat(org): inrt ui * feat(org): inrt ui * feat(org): inrt ui * feat(org): inrt ui * feat(org): inrt ui --------- Co-authored-by: 苏向夜 <46275354+fu050409@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 苏向夜 <fu050409@163.com>
1 parent 1a7644b commit 2956e4b

File tree

4 files changed

+158
-1
lines changed

4 files changed

+158
-1
lines changed

pnpm-lock.yaml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release-aur.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const releaseAur = defineCommand({
178178
execSync(`git -C aur config user.name "苏向夜"`, { stdio: "inherit" });
179179
execSync(`git -C aur config user.email "fu050409@163.com"`, {
180180
stdio: "inherit",
181+
cwd: "aur",
181182
});
182183

183184
// Test AUR package (skip in CI)

src/scripts/api.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,23 @@ export const fetchRanks = async (id: string, auth: Credentials) => {
246246
} catch (error) {
247247
return handleAxiosError(AxiosError.from(error));
248248
}
249-
}
249+
}
250+
251+
interface OrganizationData {
252+
name: string;
253+
display_name: string;
254+
description: string;
255+
}
256+
257+
export const createOrganization = async (auth: Credentials, form: OrganizationData) => {
258+
try {
259+
const response = await axios.post("/org/create", {
260+
id: auth.id,
261+
token: auth.token,
262+
org: form,
263+
});
264+
return response.data as Response<Credentials>;
265+
} catch (error) {
266+
return handleAxiosError(AxiosError.from(error));
267+
}
268+
};

src/views/org/create.vue

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<script setup lang="ts">
2+
import * as api from "@/scripts/api";
3+
import { useRouter } from 'vue-router';
4+
import { useAccountStore } from '@/scripts/store';
5+
import { ref } from 'vue';
6+
import { reactive } from 'vue';
7+
import { useToast } from 'primevue/usetoast';
8+
9+
10+
const path = [{ label: 'New Organization' }];
11+
12+
const router = useRouter();
13+
const toast = useToast();
14+
15+
const accountStore = useAccountStore();
16+
if (!accountStore.isLoggedIn) {
17+
toast.add({ severity: 'error', summary: 'Error', detail: 'Please login first', life: 3000 });
18+
router.push('/login');
19+
}
20+
21+
22+
const initialValues = reactive({
23+
org_name: "",
24+
contact_email: "",
25+
terms: false,
26+
});
27+
28+
interface OrgCreateForm<T> {
29+
org_name?: T;
30+
contact_email?: T;
31+
terms?: T;
32+
}
33+
34+
const resolver = ({ values }: { values: OrgCreateForm<string> }) => {
35+
const errors: OrgCreateForm<{ message: string }[]> = {};
36+
37+
if (!values.org_name) {
38+
errors.org_name = [{ message: 'Organization Name is required.' }];
39+
}
40+
41+
if (!values.contact_email) {
42+
errors.contact_email = [{ message: 'Your Contact Email is required.' }];
43+
}
44+
45+
if (!values.terms) {
46+
errors.terms = [{ message: "You must agree to the terms and conditions." }]
47+
}
48+
49+
return {
50+
errors
51+
};
52+
};
53+
54+
const name = ref('');
55+
const email = ref('');
56+
const description = ref('');
57+
const display_name = ref('');
58+
59+
const inProgress = ref(false);
60+
const onCreateOrg = async () => {
61+
inProgress.value = true;
62+
const res = await api.createOrganization(
63+
accountStore.auth!,
64+
{
65+
name: name.value,
66+
description: description.value,
67+
display_name: display_name.value,
68+
})
69+
if (!res.success) {
70+
toast.add({ severity: 'error', summary: 'Error', detail: res.message, life: 3000 });
71+
};
72+
inProgress.value = false;
73+
// router.push("/org/create" + res.data!.id);
74+
// TODO: redirect to organization home page
75+
}
76+
</script>
77+
78+
79+
80+
<template>
81+
<div class="flex-1 flex flex-col">
82+
<UniversalToolBar :path></UniversalToolBar>
83+
<div class="max-w-full w-[768px] md:max-w-[768px] mx-auto">
84+
<Panel class="mt-10 w-full h-full">
85+
<div class="flex flex-col gap-8 w-full">
86+
<div class="mt-10 text-center">
87+
<span class="text-gray-500 mb-4">Tell us about your organization</span>
88+
<h1 class="text-3xl font-bold">Set up your organization</h1>
89+
</div>
90+
<div class="flex flex-col">
91+
<Form v-slot="$form" :initialValues :resolver class="flex flex-col gap-4 w-full ">
92+
<div class="card flex flex-col justify-center">
93+
<div class="flex flex-col">
94+
<label for="name" style="font-size: 20px;">Organization Name *</label>
95+
<InputText v-model="name" name="name"></InputText>
96+
</div>
97+
<Message v-if="$form.org_name?.invalid" severity="error" size="small" variant="simple">
98+
{{
99+
$form.org_name.error.message }}</Message>
100+
<div>
101+
<span class="text-gray-500 mb-4" style="font-size:13px">This will be the name of
102+
your
103+
organization on AlgoHub.</span>
104+
</div>
105+
<div class="mt-6 flex flex-col">
106+
<label for="email" style="font-size: 20px;">Contact Email *</label>
107+
<InputText v-model="email" email="email"></InputText>
108+
</div>
109+
<Message v-if="$form.contact_email?.invalid" severity="error" size="small"
110+
variant="simple">
111+
{{
112+
$form.contact_email.error.message }}</Message>
113+
</div>
114+
<div class="flex flex-col gap-1 w-full">
115+
<div class="flex items-center gap-2">
116+
<Checkbox inputId="terms" name="terms" binary />
117+
<label for="terms" class="text-sm">I have read and agree to the <a href="#"
118+
class="underline">Affero
119+
General Public License v3</a>.</label>
120+
</div>
121+
<Message v-if="$form.terms?.invalid" severity="error" size="small" variant="simple">{{
122+
$form.terms.error.message }}</Message>
123+
</div>
124+
<Button @click="onCreateOrg" :loading="inProgress" label="Next"></Button>
125+
</Form>
126+
</div>
127+
</div>
128+
</Panel>
129+
</div>
130+
<UniversalFooter></UniversalFooter>
131+
</div>
132+
</template>

0 commit comments

Comments
 (0)