Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(org): create org page #103

Merged
merged 37 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c59cd4d
release: alpha (#61)
fu050409 Nov 30, 2024
3c27e24
Merge branch 'main' into alpha
fu050409 Nov 30, 2024
885de38
release: bump version (#63)
github-actions[bot] Nov 30, 2024
9710c94
fix(lint): fix code spell check
fu050409 Nov 30, 2024
a243999
ci(release): remove `tailwindcss` building
fu050409 Nov 30, 2024
62d606c
Merge branch 'main' into alpha
fu050409 Nov 30, 2024
514f839
fix(profile): fix profile problem panel (#65)
fu050409 Nov 30, 2024
7703d20
chore: fix aur release
fu050409 Nov 30, 2024
ea4e3bb
Merge branch 'alpha' of github.com:swpu-acm/algohub into alpha
fu050409 Nov 30, 2024
2a9babd
release: bump version (#66)
github-actions[bot] Nov 30, 2024
a07cd8d
chore: fix code spell check
fu050409 Nov 30, 2024
539e48f
Merge branch 'alpha' of github.com:swpu-acm/algohub into alpha
fu050409 Nov 30, 2024
3cf98fb
feat: add `NProgress` bar (#67)
fu050409 Nov 30, 2024
053eb9a
release: bump version (#68)
github-actions[bot] Nov 30, 2024
d50148f
chore: fix aur ssh known hosts
fu050409 Nov 30, 2024
9bbb526
chore: fix version check
fu050409 Nov 30, 2024
7b6134b
release: alpha releases (#62)
fu050409 Dec 6, 2024
266bba2
chore: fix ci branches
fu050409 Dec 6, 2024
3f4a486
release: bump version (#96)
github-actions[bot] Dec 6, 2024
a8ceba7
feat(contest): support acc (#97)
fu050409 Dec 6, 2024
e986572
release: bump version (#98)
github-actions[bot] Dec 9, 2024
802cc86
feat(org): inrt ui
luo0602141017 Dec 13, 2024
965d469
feat(org): inrt ui
luo0602141017 Dec 13, 2024
8015f9c
feat(org): inrt ui
luo0602141017 Dec 14, 2024
70abf22
feat(org): inrt ui
luo0602141017 Dec 15, 2024
10b8793
feat(org): inrt ui
luo0602141017 Dec 15, 2024
121e4dc
feat(org): inrt ui
luo0602141017 Dec 16, 2024
3487fd6
Merge branch 'main' into feat/create-org
luo0602141017 Dec 16, 2024
68f03b2
feat(org): inrt ui
luo0602141017 Dec 16, 2024
bae1615
feat(org): inrt ui
luo0602141017 Dec 18, 2024
8cd12ce
Merge branch 'main' into feat/create-org
fu050409 Dec 19, 2024
db58480
feat(org): edit org page
luo0602141017 Dec 19, 2024
a48deac
Merge branch 'feat/create-org' of https://github.com/swpu-acm/algohub…
luo0602141017 Dec 19, 2024
e1b7515
Merge branch 'main' into feat/create-org
fu050409 Dec 19, 2024
19eb942
feat(org): edit org page
luo0602141017 Dec 19, 2024
b90c8bc
Merge branch 'feat/create-org' of https://github.com/swpu-acm/algohub…
luo0602141017 Dec 19, 2024
9dffdc8
Update src/views/org/create.vue
fu050409 Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/release-aur.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const releaseAur = defineCommand({
execSync(`git -C aur config user.name "苏向夜"`, { stdio: "inherit" });
execSync(`git -C aur config user.email "[email protected]"`, {
luo0602141017 marked this conversation as resolved.
Show resolved Hide resolved
stdio: "inherit",
cwd: "aur",
luo0602141017 marked this conversation as resolved.
Show resolved Hide resolved
});

// Test AUR package (skip in CI)
Expand Down
21 changes: 20 additions & 1 deletion src/scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,23 @@ export const fetchRanks = async (id: string, auth: Credentials) => {
} catch (error) {
return handleAxiosError(AxiosError.from(error));
}
}
}

interface OrganizationData {
name: string;
display_name: string;
description: string;
}

export const createOrganization = async (auth: Credentials, form: OrganizationData) => {
try {
const response = await axios.post("/org/create", {
id: auth.id,
token: auth.token,
org: form,
});
return response.data as Response<Credentials>;
} catch (error) {
return handleAxiosError(AxiosError.from(error));
}
};
131 changes: 131 additions & 0 deletions src/views/org/create.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<script setup lang="ts">
import * as api from "@/scripts/api";
import { useRouter } from 'vue-router';
import { useAccountStore } from '@/scripts/store';
import { ref } from 'vue';
import { reactive } from 'vue';
import { useToast } from 'primevue/usetoast';


const path = [{ label: 'New Organization' }];

const router = useRouter();
const toast = useToast();

const accountStore = useAccountStore();
if (!accountStore.isLoggedIn) {
toast.add({ severity: 'error', summary: 'Error', detail: 'Please login first', life: 3000 });
router.push('/login');
}


const initialValues = reactive({
org_name: "",
contact_email: "",
terms: false,
});

interface OrgCreateForm<T> {
org_name?: T;
contact_email?: T;
terms?: T;
}

const resolver = ({ values }: { values: OrgCreateForm<string> }) => {
const errors: OrgCreateForm<{ message: string }[]> = {};

if (!values.org_name) {
errors.org_name = [{ message: 'Organization Name is required.' }];
}

if (!values.contact_email) {
errors.contact_email = [{ message: 'Your Contact Email is required.' }];
}

if (!values.terms) {
errors.terms = [{ message: "You must agree to the terms and conditions." }]
}

return {
errors
};
};

const name = ref('');
const email = ref('');
const description = ref('');
const display_name = ref('');

const inProgress = ref(false);
const onCreateOrg = async () => {
inProgress.value = true;
const res = await api.createOrganization(
accountStore.auth!,
{
name: name.value,
description: description.value,
display_name: display_name.value,
})
if (!res.success) {
toast.add({ severity: 'error', summary: 'Error', detail: res.message, life: 3000 });
};
inProgress.value = false;
router.push("/org/create" + res.data!.id);
fu050409 marked this conversation as resolved.
Show resolved Hide resolved
}
</script>



<template>
<div class="flex-1 flex flex-col">
<UniversalToolBar :path></UniversalToolBar>
<div class="max-w-full w-[768px] md:max-w-[768px] mx-auto">
<Panel class="mt-10 w-full h-full">
<div class="flex flex-col gap-8 w-full">
<div class="mt-10 text-center">
<span class="text-gray-500 mb-4">Tell us about your organization</span>
<h1 class="text-3xl font-bold">Set up your organization</h1>
</div>
<div class="flex flex-col">
<Form v-slot="$form" :initialValues :resolver class="flex flex-col gap-4 w-full ">
<div class="card flex flex-col justify-center">
<div class="flex flex-col">
<label for="name" style="font-size: 20px;">Organization Name *</label>
<InputText v-model="name" name="name"></InputText>
</div>
<Message v-if="$form.org_name?.invalid" severity="error" size="small" variant="simple">
{{
$form.org_name.error.message }}</Message>
<div>
<span class="text-gray-500 mb-4" style="font-size:13px">This will be the name of
your
organization on AlgoHub.</span>
</div>
<div class="mt-6 flex flex-col">
<label for="email" style="font-size: 20px;">Contact Email *</label>
<InputText v-model="email" email="email"></InputText>
</div>
<Message v-if="$form.contact_email?.invalid" severity="error" size="small"
variant="simple">
{{
$form.contact_email.error.message }}</Message>
</div>
<div class="flex flex-col gap-1 w-full">
<div class="flex items-center gap-2">
<Checkbox inputId="terms" name="terms" binary />
<label for="terms" class="text-sm">I have read and agree to the <a href="#"
class="underline">Affero
General Public License v3</a>.</label>
</div>
<Message v-if="$form.terms?.invalid" severity="error" size="small" variant="simple">{{
$form.terms.error.message }}</Message>
</div>
<Button @click="onCreateOrg" :loading="inProgress" label="Next"></Button>
</Form>
</div>
</div>
</Panel>
</div>
<UniversalFooter></UniversalFooter>
</div>
</template>
Loading