diff --git a/src/interface.ts b/src/interface.ts index 4b1405e..eef5c8e 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -51,7 +51,6 @@ export interface PaymentDetailData { ID: number, CreatedAt: string, UpdatedAt: string, - user?: UserDetailData, group?: GroupDetailData, is_membership: boolean, paid: boolean, @@ -251,6 +250,11 @@ export interface MailTemplateData { message: string } +export interface MemberTypeTemplateData { + id: string + name: string +} + export interface TunnelEndPointRouterTemplateData { CreatedAt: string DeletedAt: string @@ -304,10 +308,8 @@ export interface GroupDetailData { tel: string, country: string, contract: string, - student: boolean, - student_expired: string, - lock: boolean, - paid: boolean, + coupon_id: string, + member_type: number, member_expired: string, users?: UserDetailData[], tickets?: TicketDetailData[], @@ -339,6 +341,7 @@ export interface TemplateData { user?: UserDetailData[] group?: GroupDetailData[] mail_template?: MailTemplateData[] + member_type?: MemberTypeTemplateData[] } export interface MemoAddData { @@ -587,6 +590,7 @@ export const DefaultTemplateData: TemplateData = { tunnel_endpoint_router_ip: undefined, user: undefined, group: undefined, + member_type: undefined, } export const DefaultGroupDetailData: GroupDetailData = { @@ -607,39 +611,15 @@ export const DefaultGroupDetailData: GroupDetailData = { tel: "", country: "", contract: "", - student: false, - student_expired: "", + coupon_id: "", member_expired: "", - paid: false, - lock: false, + member_type: 1, users: undefined, tickets: undefined, services: undefined, }; export const DefaultGroupDetailDataArray: GroupDetailData[] = [DefaultGroupDetailData] -export const DefaultServiceAddData: ServiceAddData = { - jpnic_admin: undefined, - jpnic_tech: undefined, - service_type: "", - service_comment: "", - org: undefined, - org_en: undefined, - postcode: undefined, - address: undefined, - address_en: undefined, - route_v4: undefined, - route_v6: undefined, - avg_upstream: 10, - max_upstream: 100, - avg_downstream: 10, - max_downstream: 100, - max_bandwidth_as: undefined, - asn: undefined, - ip: undefined, - start_date: "", - end_date: undefined -} export const DefaultServiceJPNICData: JPNICData = { ID: 0, @@ -668,25 +648,6 @@ export const DefaultServiceJPNICData: JPNICData = { lock: false } -export const DefaultServiceAddJPNICData: ServiceAddJPNICData = { - is_group: false, - hidden: false, - org: "", - org_en: "", - mail: "", - postcode: "", - address: "", - address_en: "", - name: "", - name_en: "", - dept: "", - dept_en: "", - title: "", - title_en: "", - country: "", - tel: "", - fax: "", -} export const DefaultServiceAddIPv4PlanData: ServiceAddIPv4PlanData = { name: "", @@ -695,15 +656,6 @@ export const DefaultServiceAddIPv4PlanData: ServiceAddIPv4PlanData = { one_year: 0, } -export const DefaultConnectionAddData: ConnectionAddData = { - address: "", - connection_type: "", - connection_comment: "", - ntt: "", - noc_id: 0, - term_ip: "", - monitor: false -} export const DefaultChatData: ChatData = { time: "", @@ -863,21 +815,6 @@ export const DefaultNoticeRegisterData: NoticeRegisterData = { info: false } -export const DefaultNOCTemplateData: NocTemplateData = { - CreatedAt: "", - DeletedAt: "", - ID: 0, - UpdatedAt: "", - name: "", - bandwidth: "", - bgp_router: undefined, - comment: "", - enable: false, - location: "" -} - -export const DefaultNOCTemplateDataArray: NocTemplateData[] = [DefaultNOCTemplateData] - export const DefaultAddIP: ServiceAddIPData = { version: 0, ip: "", diff --git a/src/pages/Add/style.ts b/src/pages/Add/style.ts index e6606da..4951cd5 100644 --- a/src/pages/Add/style.ts +++ b/src/pages/Add/style.ts @@ -4,6 +4,7 @@ import { Button, Card, Chip, Container, FormControl, InputBase, Paper, + Select, styled, Table, TableRow, @@ -264,6 +265,12 @@ export const StyledTextFieldWrap = styled(TextField)(({theme}) => ({ height: "150px" })) +export const StyledSelect1 = styled(Select)(({theme}) => ({ + width: '30ch', + marginTop: 10, + marginRight: 5, +})) + export const StyledTextFieldShort = styled(TextField)(({theme}) => ({ width: '30ch', marginBottom: 10, diff --git a/src/pages/Group/GroupDetail/Group.tsx b/src/pages/Group/GroupDetail/Group.tsx index 78004d4..c430133 100644 --- a/src/pages/Group/GroupDetail/Group.tsx +++ b/src/pages/Group/GroupDetail/Group.tsx @@ -7,8 +7,7 @@ import { CardContent, Chip, FormControl, - Grid, - InputLabel, + Grid, InputLabel, MenuItem, PropTypes, TextField, Typography @@ -24,11 +23,10 @@ import { StyledButtonSpaceRight, StyledButtonSpaceTop, StyledCardRoot1, - StyledChip1, + StyledChip2, StyledDivLargeHeading, StyledDivRoot1, StyledDivText, - StyledFormControlFormSelect, StyledFormControlFormShort, StyledRootForm, StyledTextFieldMedium, @@ -40,6 +38,7 @@ import {AdapterDateFns} from '@mui/x-date-pickers/AdapterDateFns'; import {useNavigate} from "react-router-dom"; import {useRecoilValue} from "recoil"; import {TemplateState} from "../../../api/Recoil"; +import {StyledSelect1, StyledTextFieldShort} from "../../Add/style"; function ChipAgree(props: { agree: boolean }) { const {agree} = props; @@ -71,34 +70,41 @@ export function GroupProfileInfo(props: { const [lockPersonalInformation, setLockPersonalInformation] = React.useState(true); const template = useRecoilValue(TemplateState); const [group, setGroup] = useState(data); - const [openAddService, setOpenAddService] = React.useState(false); - const [openAddConnection, setOpenAddConnection] = React.useState(false); const [openJPNICRegistration, setOpenJPNICRegistration] = React.useState(false); const {enqueueSnackbar} = useSnackbar(); - const [paymentCoupon, setPaymentCoupon] = React.useState(0); - const [discountRate, setDiscountRate] = React.useState(0); - const [membershipPlan, setMembershipPlan] = React.useState(0); - const monthly = 1000; - const yearly = 12000; + const [paymentCoupon, setPaymentCoupon] = React.useState(""); + const [memberType, setMemberType] = React.useState(0); let nowDate = new Date(); - const [selectedDate, setSelectedDate] = React.useState(nowDate); - const [membershipDate, setMembershipDate] = React.useState(""); + const [memberExpiredDate, setMemberExpiredDate] = React.useState(nowDate); const navigate = useNavigate(); useEffect(() => { if (data.member_expired != null) { const tmp = data.member_expired.split('T'); nowDate = new Date(tmp[0]); - setSelectedDate(nowDate); - handleBeginDateChange(selectedDate); + handleMemberExpiredDateChange(memberExpiredDate); + } + + if (data.coupon_id != null) { + setPaymentCoupon(data.coupon_id) + } + + if (data.member_type != null) { + setMemberType(data.member_type) } }, []); const membershipUpdate = () => { + let dateStr = null + if (memberExpiredDate != null) { + dateStr = memberExpiredDate.getFullYear() + '-' + ('00' + (memberExpiredDate.getMonth() + 1)).slice(-2) + + '-' + ('00' + (memberExpiredDate.getDate())).slice(-2) + 'T00:00:00+09:00' + + } const req = { - payment_coupon_template_id: paymentCoupon, - payment_membership_template_id: membershipPlan, - member_expired: membershipDate + coupon_id: paymentCoupon, + member_type: memberType, + member_expired: dateStr }; console.log(req); @@ -128,27 +134,9 @@ export function GroupProfileInfo(props: { }) } - const handleBeginDateChange = (newDate: Date | null) => { - setSelectedDate(newDate); - if (newDate !== null) { - setMembershipDate(newDate.getFullYear() + '-' + ('00' + (newDate.getMonth() + 1)).slice(-2) + - '-' + ('00' + (newDate.getDate())).slice(-2) + 'T09:00:00Z'); - } + const handleMemberExpiredDateChange = (newDate: Date | null) => { + setMemberExpiredDate(newDate); }; - // const handleChangeMembershipPlan = (event: SelectChangeEvent) => { - // setMembershipPlan(event.target.value as number); - // }; - // const handleChangeCoupon = (event: SelectChangeEvent) => { - // setPaymentCoupon(event.target.value as number); - // const coupon = template.payment_coupon_template?.filter(coupon => coupon.ID === event.target.value as number) - // if (coupon != null) { - // if (coupon.length === 0) { - // setDiscountRate(0); - // } else { - // setDiscountRate(coupon[0].discount_rate); - // } - // } - // }; const clickPersonalInfoLock = () => { setLockPersonalInformation(!lockPersonalInformation); @@ -298,77 +286,54 @@ export function GroupProfileInfo(props: { aria-controls="payment" id="payment" > - 学生会員・支払い + 会員種別・会費関連 - - - Membership Plan - {/**/} - {/* 自動課金無効*/} - {/* {*/} - {/* template.payment_membership_template?.map(tmp =>*/} - {/* */} - {/* {tmp.plan}*/} - {/* */} - {/* )*/} - {/* }*/} - {/**/} - - - {/**/} - {/* Coupon*/} - {/**/} - {/* 割引なし(0%割引)*/} - {/* {*/} - {/* template.payment_coupon_template?.map(coupon =>*/} - {/* */} - {/* {coupon.title}({coupon.discount_rate}%割引)*/} - {/* */} - {/* )*/} - {/* }*/} - {/**/} - {/**/} -
- - - ()} - /> - + setPaymentCoupon(event.target.value)} + variant="outlined" + /> + + ()} + /> + + + Member Type + { + const value = Number(e.target.value) + if (!isNaN(value)) { + setMemberType(value) + } + }} + value={memberType} + > + { + template.member_type?.map((row, index) => ( + {row.id}: {row.name} + )) + + } +
- - {monthly - (discountRate / 100) * monthly}円/月 - - - {yearly - (discountRate / 100) * yearly}円/年 - + + + 支払い画面(User) + + + 解約 + +
@@ -454,7 +435,6 @@ export function GroupMainMenu(props: { return ( -

Menu

@@ -468,8 +448,8 @@ export function GroupStatus(props: { reload: boolean }): any { const {data, reload} = props; - const createDate = "作成日: " + data.CreatedAt; - const updateDate = "更新日: " + data.UpdatedAt; + const [createDate, setCreateDate] = useState(""); + const [updateDate, setUpdateDate] = useState(""); const [membershipLabel, setMembershipLabel] = useState<{ color: Exclude, label: string }>({ color: "primary", label: "" @@ -480,52 +460,70 @@ export function GroupStatus(props: { }); const nowDate = new Date(); + useEffect(() => { + // create date + const tmpCreateDate = new Date(Date.parse(data.CreatedAt)) + setCreateDate("作成日: " + + tmpCreateDate.getFullYear() + "-" + ('00' + (tmpCreateDate.getMonth() + 1)).slice(-2) + + '-' + ('00' + (tmpCreateDate.getDate())).slice(-2) + " " + + ('00' + (tmpCreateDate.getHours())).slice(-2) + ":" + ('00' + (tmpCreateDate.getMinutes())).slice(-2) + + ":" + ('00' + (tmpCreateDate.getSeconds())).slice(-2) + ) + + // update date + const tmpUpdateDate = new Date(Date.parse(data.UpdatedAt)) + setUpdateDate("更新日: " + tmpUpdateDate.getFullYear() + "-" + ('00' + (tmpUpdateDate.getMonth() + 1)).slice(-2) + + '-' + ('00' + (tmpUpdateDate.getDate())).slice(-2) + " " + + ('00' + (tmpUpdateDate.getHours())).slice(-2) + ":" + ('00' + (tmpUpdateDate.getMinutes())).slice(-2) + + ":" + ('00' + (tmpUpdateDate.getSeconds())).slice(-2)) + + // member expired setMembershipLabel({color: "primary", label: ""}); if (data.member_expired != null) { const tmp = data.member_expired.split('T'); - const groupMemberExpired = new Date(tmp[0]); + const memberExpired = new Date(tmp[0]); + const expiredDate = memberExpired.getFullYear() + '-' + ('00' + (memberExpired.getMonth() + 1)).slice(-2) + + '-' + ('00' + (memberExpired.getDate())).slice(-2) - // if (data.payment_coupon_template_id !== 0) { - // setMembershipLabel({ - // color: "primary", - // label: data.payment_coupon_template?.title + ": " + tmp[0] + "まで" - // }); - // } else { - // setMembershipLabel({ - // color: "primary", - // label: "会員: " + tmp[0] + "まで" - // }); - // } - if (groupMemberExpired < nowDate) { - setMembershipLabel({ + nowDate.setDate(nowDate.getDate() + 1) + if (Date.UTC(memberExpired.getFullYear(), memberExpired.getMonth() + 1, memberExpired.getDate(), 0, 0, 0) + >= + Date.UTC(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate(), 0, 0, 0) + ) { + setAutomaticUpdate({ + color: "primary", + label: expiredDate + }) + } else { + setAutomaticUpdate({ color: "secondary", - label: "(未払い) " + membershipLabel.label + label: "未払い " + expiredDate }) } } else { - setMembershipLabel({ + setAutomaticUpdate({ color: "secondary", - label: "未払い状態" + label: "-----" }) } - // if (data.payment_membership_template?.yearly) { - // setAutomaticUpdate({ - // color: membershipLabel.color, - // label: "(年更新)" - // }) - // } else if (data.payment_membership_template?.monthly) { - // setAutomaticUpdate({ - // color: membershipLabel.color, - // label: "(月更新)" - // }) - // } else { - // setAutomaticUpdate({ - // color: membershipLabel.color, - // label: "(更新無効)" - // }) - // } + let paymentMemberStatus = "" + switch (data.member_type) { + case 1: + paymentMemberStatus += "通常会員" + break; + case 70: + paymentMemberStatus += "学生会員" + break; + case 90: + paymentMemberStatus += "運営委員" + break; + } + setMembershipLabel({ + color: "primary", + label: paymentMemberStatus + }) }, [reload]); return ( @@ -533,22 +531,18 @@ export function GroupStatus(props: { -

Status

+

Status

-
- -

Membership

+

Membership

  -
- -

Date

- Date +
- + + - - - - + { - data.lock = lock; + const changeLock = (pass: boolean) => { + data.pass = pass; Put(data.ID, data).then(res => { if (res.error === "") { @@ -111,7 +111,7 @@ export function GroupLockButton(props: { data: GroupDetailData, reload: Dispatch }; - if (data.lock) { + if (data.pass) { return ( -

Memo

{ data.memos?.map(memo => ( @@ -99,6 +98,7 @@ export function GroupMemo(props: { /> }
+
); } diff --git a/src/pages/Group/GroupDetail/Service.tsx b/src/pages/Group/GroupDetail/Service.tsx index 1962b5b..0eb2283 100644 --- a/src/pages/Group/GroupDetail/Service.tsx +++ b/src/pages/Group/GroupDetail/Service.tsx @@ -90,7 +90,7 @@ function RowService(props: { {service.ID} {serviceCode} - {GetServiceWithTemplate(service.service_type)!.name} + {GetServiceWithTemplate(service.service_type)?.name}