File size: 889 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
import {
	A4A_MIGRATED_SITE_REJECTED,
	A4A_MIGRATED_SITE_VERIFIED,
	A4A_MIGRATED_STATUS_PAID,
} from './constants';

/**
 * Determines the review status of a migrated site based on its tags.
 *
 * @param tags - An array of tag names associated with the site.
 * @returns The review status: 'paid', 'confirmed', 'rejected', or 'pending'.
 */
export const getSiteReviewStatus = (
	tags: string[]
): 'pending' | 'confirmed' | 'rejected' | 'paid' => {
	// Check for paid status first
	if ( tags.includes( A4A_MIGRATED_STATUS_PAID ) ) {
		return 'paid';
	}
	if ( tags.includes( A4A_MIGRATED_SITE_VERIFIED ) ) {
		return 'confirmed';
	}
	if ( tags.includes( A4A_MIGRATED_SITE_REJECTED ) ) {
		return 'rejected';
	}
	// If none of the above tags are present, assume pending.
	// The presence of A4A_MIGRATED_SITE_TAG is implicitly assumed for sites passed to this function.
	return 'pending';
};