File size: 1,217 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import type {
	DomainSuggestion,
	DomainSuggestionQuery,
	DomainCategory,
	DomainAvailability,
} from './types';

export const receiveCategories = ( categories: DomainCategory[] ) =>
	( {
		type: 'RECEIVE_CATEGORIES',
		categories,
	} ) as const;

export const fetchDomainSuggestions = () =>
	( {
		type: 'FETCH_DOMAIN_SUGGESTIONS',
		timeStamp: Date.now(),
	} ) as const;

export const receiveDomainAvailability = ( domainName: string, availability: DomainAvailability ) =>
	( {
		type: 'RECEIVE_DOMAIN_AVAILABILITY',
		domainName,
		availability,
	} ) as const;

export const receiveDomainSuggestionsSuccess = (
	queryObject: DomainSuggestionQuery,
	suggestions: DomainSuggestion[] | undefined
) =>
	( {
		type: 'RECEIVE_DOMAIN_SUGGESTIONS_SUCCESS',
		queryObject,
		suggestions,
		timeStamp: Date.now(),
	} ) as const;

export const receiveDomainSuggestionsError = ( errorMessage: string ) =>
	( {
		type: 'RECEIVE_DOMAIN_SUGGESTIONS_ERROR',
		errorMessage,
		timeStamp: Date.now(),
	} ) as const;

export type Action = ReturnType<
	| typeof receiveCategories
	| typeof fetchDomainSuggestions
	| typeof receiveDomainSuggestionsSuccess
	| typeof receiveDomainSuggestionsError
	| typeof receiveDomainAvailability
>;