Skip to content

Commit b3fbdf0

Browse files
committed
values from customDomain in Territory Edit, domain string validation
1 parent fa3b9a2 commit b3fbdf0

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

api/typeDefs/sub.js

+7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ export default gql`
1010
}
1111
1212
type CustomDomain {
13+
createdAt: Date!
14+
updatedAt: Date!
1315
domain: String!
16+
subName: String!
17+
sslEnabled: Boolean!
18+
sslCertExpiry: Date
19+
verificationState: String!
20+
lastVerifiedAt: Date
1421
}
1522
1623
type Subs {

components/territory-form.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export default function TerritoryForm ({ sub }) {
9797
billingType: sub?.billingType || 'MONTHLY',
9898
billingAutoRenew: sub?.billingAutoRenew || false,
9999
moderated: sub?.moderated || false,
100-
nsfw: sub?.nsfw || false
100+
nsfw: sub?.nsfw || false,
101+
customDomain: sub?.customDomain?.domain || ''
101102
}}
102103
schema={schema}
103104
onSubmit={onSubmit}
@@ -275,10 +276,32 @@ export default function TerritoryForm ({ sub }) {
275276
name='nsfw'
276277
groupClassName='ms-1'
277278
/>
278-
<BootstrapForm.Label>personalized domains (TODO textbox/status)</BootstrapForm.Label>
279-
<div className='mb-3'>WIP {sub?.customDomain?.domain || 'not set'}</div>
280-
<BootstrapForm.Label>color scheme (TODO 5 options)</BootstrapForm.Label>
281-
<div className='mb-3'>WIP</div>
279+
<Input
280+
label={
281+
<div className='d-flex align-items-center'>[NOT IMPLEMENTED] custom domain
282+
<Info>
283+
<ol>
284+
<li>TODO Immediate infos on Custom Domains</li>
285+
</ol>
286+
</Info>
287+
</div>
288+
}
289+
name='customDomain'
290+
type='text'
291+
required
292+
append={
293+
<>
294+
<InputGroup.Text className='text-monospace'>{sub?.customDomain?.verificationState || 'not verified'}</InputGroup.Text>
295+
</>
296+
}
297+
/>
298+
{sub?.customDomain?.verificationState === 'VERIFIED' &&
299+
<>
300+
<BootstrapForm.Label>[NOT IMPLEMENTED] color scheme</BootstrapForm.Label>
301+
<div className='mb-3'>WIP</div>
302+
<BootstrapForm.Label>[NOT IMPLEMENTED] color scheme</BootstrapForm.Label>
303+
<div className='mb-3'>WIP</div>
304+
</>}
282305
</>
283306

284307
}

fragments/subs.js

+7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ export const SUB_FIELDS = gql`
3636
meSubscription
3737
nsfw
3838
customDomain {
39+
createdAt
40+
updatedAt
3941
domain
42+
subName
43+
sslEnabled
44+
sslCertExpiry
45+
verificationState
46+
lastVerifiedAt
4047
}
4148
}`
4249

lib/validate.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ export function territorySchema (args) {
323323
.max(100000, 'must be at most 100k'),
324324
postTypes: array().of(string().oneOf(POST_TYPES)).min(1, 'must support at least one post type'),
325325
billingType: string().required('required').oneOf(TERRITORY_BILLING_TYPES, 'required'),
326-
nsfw: boolean()
326+
nsfw: boolean(),
327+
customDomain: string().matches(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
328+
message: 'enter a valid domain name (e.g., example.com)'
329+
}).nullable()
327330
})
328331
}
329332

0 commit comments

Comments
 (0)