mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-11 18:26:04 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { SystemSignature } from '@/hooks/Mapper/types';
|
||||
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
||||
import { getState } from './getState.ts';
|
||||
|
||||
export const getActualSigs = (
|
||||
oldSignatures: SystemSignature[],
|
||||
newSignatures: SystemSignature[],
|
||||
): { added: SystemSignature[]; updated: SystemSignature[]; removed: SystemSignature[] } => {
|
||||
const updated: SystemSignature[] = [];
|
||||
const removed: SystemSignature[] = [];
|
||||
|
||||
oldSignatures.forEach(oldSig => {
|
||||
// if old sigs is not contains in newSigs we need mark it as removed
|
||||
// otherwise we check
|
||||
const newSig = newSignatures.find(s => s.eve_id === oldSig.eve_id);
|
||||
if (newSig) {
|
||||
// we take new sig and now we need check that sig has been updated
|
||||
const isNeedUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
|
||||
if (isNeedUpgrade) {
|
||||
updated.push({ ...oldSig, group: newSig.group, name: newSig.name });
|
||||
}
|
||||
} else {
|
||||
removed.push(oldSig);
|
||||
}
|
||||
});
|
||||
|
||||
const oldSignaturesIds = oldSignatures.map(x => x.eve_id);
|
||||
const added = newSignatures.filter(s => !oldSignaturesIds.includes(s.eve_id));
|
||||
|
||||
return { added, updated, removed };
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
TIME_ONE_MINUTE,
|
||||
TIME_TEN_MINUTES,
|
||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
||||
|
||||
export const getRowColorByTimeLeft = (date: Date | undefined) => {
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentDate = new Date();
|
||||
const diff = currentDate.getTime() + currentDate.getTimezoneOffset() * TIME_ONE_MINUTE - date.getTime();
|
||||
|
||||
if (diff < TIME_ONE_MINUTE) {
|
||||
return 'bg-lime-600/50 transition hover:bg-lime-600/60';
|
||||
}
|
||||
|
||||
if (diff < TIME_TEN_MINUTES) {
|
||||
return 'bg-lime-700/40 transition hover:bg-lime-700/50';
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { SystemSignature } from '@/hooks/Mapper/types';
|
||||
|
||||
// also we need detect changes, we need understand that sigs has states
|
||||
// first state when kind is Cosmic Signature or Cosmic Anomaly and group is empty
|
||||
// and we should detect it for ungrade sigs
|
||||
export const getState = (_: string[], newSig: SystemSignature) => {
|
||||
let state = -1;
|
||||
if (!newSig.group || newSig.group === '') {
|
||||
state = 0;
|
||||
} else if (!!newSig.group && newSig.group !== '' && newSig.name === '') {
|
||||
state = 1;
|
||||
} else if (!!newSig.group && newSig.group !== '' && newSig.name !== '') {
|
||||
state = 2;
|
||||
}
|
||||
return state;
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './getState';
|
||||
export * from './getRowColorByTimeLeft';
|
||||
export * from './getActualSigs';
|
||||
Reference in New Issue
Block a user