<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import ctxRef from "@/utils/ctx_ref.js"
import Context from "./index.js"
import ServerSettingLayout from "@/layouts/ServerSettingLayout.vue";
import WarningMessage from "@/components/common/WarningMessage.vue";
import TMessage from "@/components/ui/TMessage.vue";
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import ServerNameBox from "@/components/server/ServerNameBox.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<ServerSettingLayout :ctx="ctx">
        <!-- 审核中 -->
		<div v-show="ctx.isAuditing">
			<WarningMessage>当前网站域名正在审核中，暂时不能访问，请耐心等待管理员审核。</WarningMessage>
		</div>

		<!-- 审核不通过 -->
		<div class="mb-4" v-if="!ctx.isAuditing && !ctx.auditingResult.isOk">
			<TMessage error="">
				审核不通过，原因：{{ ctx.auditingResult.reason }} （{{ ctx.auditingResult.createdTime }}），请修改后重新提交。
			</TMessage>
		</div>

		<!-- 不在审核中 -->
		<div>
			<PostForm action="$" @success="ctx.success">
				<input type="hidden" name="serverId" :value="ctx.serverId"/>
				<DefinitionTable>
					<tbody>
						<tr>
							<td class="title">已绑定的域名</td>
							<td>
								<ServerNameBox :v-server-names="ctx.serverNames"></ServerNameBox>
							</td>
						</tr>
					</tbody>
				</DefinitionTable>
				<div class="submit-button">
					<SubmitButton></SubmitButton>
				</div>
			</PostForm>
		</div>
	</ServerSettingLayout>
</template>

<style lang="postcss" scoped src="@/views/servers/style/server.pcss"></style>