mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-19 01:41:55 +08:00
36 lines
730 B
TypeScript
36 lines
730 B
TypeScript
import { NotifyChannel, NotifyChannels, Setting } from "@/domain/settings";
|
|
|
|
type Action =
|
|
| {
|
|
type: "SET_CHANNEL";
|
|
payload: {
|
|
channel: string;
|
|
data: NotifyChannel;
|
|
};
|
|
}
|
|
| {
|
|
type: "SET_CHANNELS";
|
|
payload: Setting<NotifyChannels>;
|
|
};
|
|
|
|
export const notifyReducer = (state: Setting<NotifyChannels>, action: Action) => {
|
|
switch (action.type) {
|
|
case "SET_CHANNEL": {
|
|
const channel = action.payload.channel;
|
|
return {
|
|
...state,
|
|
content: {
|
|
...state.content,
|
|
[channel]: action.payload.data,
|
|
},
|
|
};
|
|
}
|
|
case "SET_CHANNELS": {
|
|
return { ...action.payload };
|
|
}
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
};
|